import axios from '@/common/services/axios-instance'

class HandoverService {
  getHandoverResources(params) {
    return axios({
      url: `api/framework/v1/work-handover/resource/user/${params.id}`,
      method: 'get',
    })
  }

  saveDoc(params) {
    return axios({
      url: `api/framework/v1/work-handover/task`,
      method: 'post',
      data: {
        ...params,
      },
    })
  }

  getDetail(params) {
    let reqSuffix = ''
    switch (params.type) {
      case 'todo':
        reqSuffix = 'todo'
        break
      case 'toread':
        reqSuffix = 'inform'
        break
      case 'processed':
        reqSuffix = 'processed'
        break
      case 'readed':
        reqSuffix = 'replied-inform'
        break
    }
    return axios({
      url: `api/framework/v1/work-handover/detail/${reqSuffix}`,
      method: 'get',
      params: {
        ids: params.ids,
      },
    })
  }
}

export default new HandoverService()
