import request from '@/utils/request.js'

// ─── Service Items ───────────────────────────────────────────────────────────
export const serviceItemApi = {
  getList: (params) => request.get('/service/items', { params }),
  getDetail: (id) => request.get(`/service/items/${id}`),
  create: (data) => request.post('/service/items', data),
  update: (id, data) => request.put(`/service/items/${id}`, data),
  delete: (id) => request.delete(`/service/items/${id}`)
}

// ─── Service Packages ────────────────────────────────────────────────────────
export const servicePackageApi = {
  getList: (params) => request.get('/service/packages', { params }),
  getDetail: (id) => request.get(`/service/packages/${id}`),
  create: (data) => request.post('/service/packages', data),
  update: (id, data) => request.put(`/service/packages/${id}`, data),
  delete: (id) => request.delete(`/service/packages/${id}`)
}

// ─── Service Orders ──────────────────────────────────────────────────────────
export const serviceOrderApi = {
  getList: (params) => request.get('/service/orders', { params }),
  getDetail: (id) => request.get(`/service/orders/${id}`),
  create: (data) => request.post('/service/orders', data),
  update: (id, data) => request.put(`/service/orders/${id}`, data),
  delete: (id) => request.delete(`/service/orders/${id}`),
  pay: (id, data) => request.put(`/service/orders/${id}/pay`, data),
  complete: (id) => request.put(`/service/orders/${id}/complete`)
}

// ─── Service Executions ──────────────────────────────────────────────────────
export const serviceExecutionApi = {
  getList: (params) => request.get('/service/executions', { params }),
  create: (data) => request.post('/service/executions', data),
  start: (id) => request.put(`/service/executions/${id}/start`),
  finish: (id) => request.put(`/service/executions/${id}/finish`)
  // complete → finish (backend only has /finish, removed duplicate)
}
