import api, { PageResponse, unwrap } from './request'; export interface ComplaintRow extends Record { complaintId: number; contractNo: string; agentId: number; agentName: string; complaintType: string; content: string; receivedDate: string; status: string; closedAt?: string; chargebackTriggered: boolean; chargebackAmount?: number; processNote?: string; createdAt: string; } export interface ComplaintSaveReq { contractNo: string; agentId: number; complaintType: string; content: string; receivedDate: string; chargebackTriggered: boolean; } export interface ComplaintSearchParam { contractNo?: string; agentId?: number; agentName?: string; complaintType?: string; status?: string; startDate?: string; endDate?: string; pageNum?: number; pageSize?: number; } export const complaintApi = { list: (p: ComplaintSearchParam) => unwrap>( api.get('/api/complaints', { params: p }), ), create: (body: ComplaintSaveReq) => unwrap(api.post('/api/complaints', body)), update: (id: number, body: Partial) => unwrap(api.put(`/api/complaints/${id}`, body)), close: (id: number, processNote: string) => unwrap(api.post(`/api/complaints/${id}/close`, { processNote })), delete: (id: number) => unwrap(api.delete(`/api/complaints/${id}`)), };