import { get, post, put, del } from './request'

export interface ProjectParams {
  projectName: string
  projectType: string
  customerName: string
  customerPhone: string
  address: string
  servicePoints?: { address?: string; contactName?: string; contactPhone?: string }[]
  contacts?: { name?: string; phone?: string; role?: string }[]
}

export function getProjectList(pageNum = 1, pageSize = 10) {
  return get('/project/list', { pageNum, pageSize })
}

export function getProjectDetail(projectId: number) {
  return get(`/project/${projectId}`)
}

export function createProject(data: ProjectParams) {
  return post('/project', data)
}

export function updateProject(data: ProjectParams & { projectId: number }) {
  return put('/project', data)
}

export function deleteProject(projectId: number) {
  return del(`/project/${projectId}`)
}
