petstore-admin/src/api/index.ts
2026-08-01 22:56:31 +08:00

73 lines
2.7 KiB
TypeScript

import { apiDelete, apiGet, apiPost, apiPut } from './http'
export const login = (phone: string, code: string) =>
apiPost<{ sessionToken: string; user: Record<string, unknown>; store: Record<string, unknown> | null }>(
'/user/login',
{ phone, code },
)
export const sendSms = (phone: string) => apiPost('/sms/send', { phone })
export const getUserInfo = () => apiGet<Record<string, unknown>>('/user/info')
export const getAppointmentList = (params: Record<string, unknown> = {}) =>
apiGet('/appointment/list', params)
export const getAppointmentDetail = (id: number) => apiGet('/appointment/detail', { id })
export const startAppointment = (appointmentId: number) =>
apiPost('/appointment/start', { appointmentId })
export const cancelAppointment = (id: number) =>
apiPut(`/appointment/status?id=${id}&status=cancel`)
export const getReportList = (params: Record<string, unknown> = {}) =>
apiGet('/report/list', params)
export const startHighlight = (reportId: number) =>
apiPost('/report/highlight/start', { reportId })
export const getLeads = (status = 'pending') =>
apiGet('/report/leads', { status })
export const getServiceCustomers = (params: Record<string, unknown> = {}) =>
apiGet('/admin/service-customers', params)
export const getWorkbenchReportFunnel = (date?: string) =>
apiGet('/admin/workbench/report-funnel', date ? { date } : {})
export const getAdminStore = () => apiGet<Record<string, unknown>>('/admin/store')
export const updateStore = (data: Record<string, unknown>) => apiPut('/store/update', data)
export const getScheduleDay = (date: string) =>
apiGet('/schedule/day', { date })
export const createScheduleBlock = (data: { slotStart: string; durationMinutes: number; blockType: string; note?: string }) =>
apiPost('/schedule/block', data)
export const deleteScheduleBlock = (id: number) =>
apiDelete('/schedule/block', { id })
export const getStore = (id: number) => apiGet('/store/get', { id })
export const getStaffList = () => apiGet('/user/staff-list')
export const createStaff = (data: { name: string; phone: string }) =>
apiPost('/user/create-staff', data)
export const deleteStaff = (staffId: number) =>
apiDelete('/user/staff', { staffId })
export const getServiceTypeList = (storeId?: number | null) =>
apiGet('/service-type/list', storeId != null ? { storeId } : {})
export const createServiceType = (name: string, durationMinutes: number) =>
apiPost('/service-type/create', { name, durationMinutes })
export const updateServiceType = (id: number, name: string, durationMinutes: number) =>
apiPut('/service-type/update', { id, name, durationMinutes })
export const deleteServiceType = (id: number) =>
apiDelete('/service-type/delete', { id })