import service from '@/utils/apiService'
const baseUrl = '/api/organization-units'

export function get(id) {
  return service({
    url: `${baseUrl}/${id}`,
    method: 'get'
  })
}

export function getList(params) {
  return service({
    url: `${baseUrl}`,
    method: 'get',
    params
  })
}

export function getChildren(id, params) {
  return service({
    url: `${baseUrl}/${id}/children`,
    method: 'get',
    params
  })
}

export function create(data) {
  return service({
    url: `${baseUrl}`,
    method: 'post',
    data
  })
}

export function update(id, data) {
  return service({
    url: `${baseUrl}/${id}`,
    method: 'put',
    data
  })
}

export function remove(id) {
  return service({
    url: `${baseUrl}/${id}`,
    method: 'delete'
  })
}

// export function getUnitDepartments(id) {
//   return service({
//     url: `${baseUrl}/${id}/departments`,
//     method: 'get'
//   })
// }

// export function getUnitDepartmentTree(id) {
//   return service({
//     url: `${baseUrl}/${id}/departments-tree`,
//     method: 'get'
//   })
// }

// export function getTreeByProject(projectId) {
//   return service({
//     url: `${baseUrl}/tree/by-project/${projectId}`,
//     method: "get"
//   });
// }

export function lookupUnits(params) {
  return service({
    url: `${baseUrl}/lookup-units`,
    method: 'get',
    params
  })
}
