// Customers domain — HTTP calls only (no hooks). Moved from lib/api/customers.ts. import apiClient from '../../lib/api/client'; import type { Customer, CustomerListParams, CreateCustomerRequest, UpdateCustomerRequest, PagedCustomerResponse, } from './types'; export const customersApi = { /** GET /api/customers?query= — search autocomplete (unchanged). */ search: async (query?: string): Promise => { const params = query ? `?query=${encodeURIComponent(query)}` : ''; const res = await apiClient.get(`/customers${params}`); return res.data; }, /** GET /api/customers/list?page=&pageSize= — paginated management list (admin/sysadmin). */ list: async (params: CustomerListParams = {}): Promise => { const qs = new URLSearchParams(); if (params.page) qs.append('page', String(params.page)); if (params.pageSize) qs.append('pageSize', String(params.pageSize)); if (params.search) qs.append('search', params.search); const res = await apiClient.get(`/customers/list?${qs.toString()}`); return res.data; }, /** POST /api/customers — create a new customer. */ create: async (data: CreateCustomerRequest): Promise => { const res = await apiClient.post('/customers', data); return res.data; }, /** PUT /api/customers/{id} — update an existing customer (admin/sysadmin). */ update: async (id: string, data: UpdateCustomerRequest): Promise => { const res = await apiClient.put(`/customers/${id}`, data); return res.data; }, };