import apiClient from './client'; export interface Customer { id: string; name: string; addresses: string[]; /** Contact email for proposal delivery. Null when not set. */ contactEmail?: string | null; createdAt: string; } export interface CustomerListParams { page?: number; pageSize?: number; search?: string; } export interface PagedCustomerResponse { items: Customer[]; totalCount: number; page: number; pageSize: number; } export interface CreateCustomerRequest { name: string; address: string; contactEmail?: string; } export interface UpdateCustomerRequest { name: string; address: string; contactEmail?: string; } 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; }, };