import service from '@/utils/apiService'
const baseUrl = '/api/section-sites'

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

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

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

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

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

export function assignToSupervision(sectionId, siteIds) {
  return service({
    url: `${baseUrl}/assign-to-supervision`,
    method: 'post',
    data: { sectionId, siteIds }
  })
}

export function recallFromSupervision(sectionId, siteIds) {
  return service({
    url: `${baseUrl}/recall-from-supervision`,
    method: 'post',
    data: { sectionId, siteIds }
  })
}

export function assignToBuilding(buildingId, siteIds) {
  return service({
    url: `${baseUrl}/assign-to-building`,
    method: 'post',
    data: { buildingId, siteIds }
  })
}

export function recallFromBuilding(buildingId, siteIds) {
  return service({
    url: `${baseUrl}/recall-from-building`,
    method: 'post',
    data: { buildingId, siteIds }
  })
}

export function lookupBySection(sectionId, params) {
  return service({
    url: `${baseUrl}/lookup/by-section/${sectionId}`,
    method: 'get',
    params
  })
}

export function lookupSupervisionAvailableSites(sectionId, typeId = null) {
  return service({
    url: `${baseUrl}/lookup/sites-availabel-to-supervision`,
    method: 'get',
    params: { sectionId, typeId }
  })
}

export function lookupSupervisionAssignedSites(sectionId, typeId = null) {
  return service({
    url: `${baseUrl}/lookup/sites-assigned-to-supervision`,
    method: 'get',
    params: { sectionId, typeId }
  })
}

export function lookupBuildingAvailableSites(buildingId) {
  return service({
    url: `${baseUrl}/lookup/sites-availabel-to-building`,
    method: 'get',
    params: { buildingId }
  })
}

export function lookupBuildingAssignedSites(buildingId) {
  return service({
    url: `${baseUrl}/lookup/sites-assigned-to-building`,
    method: 'get',
    params: { buildingId }
  })
}

export function lookupByBuild(buildId, params) {
  return service({
    url: `${baseUrl}/lookup/by-build/${buildId}`,
    method: 'get',
    params
  })
}
