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

// ─── Approval Templates ──────────────────────────────────────────────────────
export const approvalTemplateApi = {
  getList: (params) => request.get('/office/approval-templates', { params }),
  getDetail: (id) => request.get(`/office/approval-templates/${id}`),
  create: (data) => request.post('/office/approval-templates', data),
  update: (id, data) => request.put(`/office/approval-templates/${id}`, data),
  delete: (id) => request.delete(`/office/approval-templates/${id}`)
}

// ─── Approvals ───────────────────────────────────────────────────────────────
export const approvalApi = {
  getList: (params) => request.get('/office/approvals', { params }),
  getDetail: (id) => request.get(`/office/approvals/${id}`),
  create: (data) => request.post('/office/approvals', data),
  approve: (id, data) => request.put(`/office/approvals/${id}/approve`, data),
  reject: (id, data) => request.put(`/office/approvals/${id}/reject`, data),
  withdraw: (id) => request.put(`/office/approvals/${id}/withdraw`)
}

// ─── Announcements ───────────────────────────────────────────────────────────
export const announcementApi = {
  getList: (params) => request.get('/office/announcements', { params }),
  getDetail: (id) => request.get(`/office/announcements/${id}`),
  create: (data) => request.post('/office/announcements', data),
  update: (id, data) => request.put(`/office/announcements/${id}`, data),
  delete: (id) => request.delete(`/office/announcements/${id}`),
  publish: (id) => request.put(`/office/announcements/${id}/publish`)
}

// ─── Handovers ───────────────────────────────────────────────────────────────
export const handoverApi = {
  getList: (params) => request.get('/office/handovers', { params }),
  create: (data) => request.post('/office/handovers', data),
  confirm: (id) => request.put(`/office/handovers/${id}/confirm`)
}

// ─── Notifications ───────────────────────────────────────────────────────────
export const notificationApi = {
  getList: (params) => request.get('/office/notifications', { params }),
  markRead: (id) => request.put(`/office/notifications/${id}/read`),
  markAllRead: () => request.put('/office/notifications/read-all')
}
