import service from '@/utils/apiService'
const baseUrl = '/api/sections'

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

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

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

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

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

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

export function lookupAllSections() {
  return service({
    url: `${baseUrl}/lookup/all-sections`,
    method: 'get'
  })
}

export function lookupAllByProject(projectId, params) {
  return service({
    url: `${baseUrl}/lookup/by-project/${projectId}`,
    method: 'get',
    params
  })
}

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

export function lookupSupervisions(projectId, constructionSectionId = null) {
  return service({
    url: `${baseUrl}/lookup-supervisions`,
    method: 'get',
    params: { projectId, constructionSectionId }
  })
}
