import { apiClient } from './api-client'; // ─── Types ────────────────────────────────────────────── export type ReportType = | 'RESIDENTIAL_MARKET' | 'INDUSTRIAL_MARKET' | 'DISTRICT_ANALYSIS' | 'INVESTMENT_FEASIBILITY' | 'INDUSTRIAL_LOCATION' | 'PROPERTY_VALUATION' | 'PORTFOLIO'; export type ReportStatus = 'GENERATING' | 'READY' | 'FAILED'; export interface Report { id: string; type: ReportType; title: string; params: Record; content: Record | null; pdfUrl: string | null; status: ReportStatus; errorMsg: string | null; createdAt: string; updatedAt: string; } export interface ListReportsResponse { data: Report[]; total: number; } export interface GenerateReportResponse { reportId: string; } export interface ReportStatusResponse { id: string; status: ReportStatus; errorMsg: string | null; pdfUrl: string | null; } // ─── API Calls ────────────────────────────────────────── export function listReports(params?: { type?: ReportType; limit?: number; offset?: number; }): Promise { const searchParams = new URLSearchParams(); if (params?.type) searchParams.set('type', params.type); if (params?.limit) searchParams.set('limit', String(params.limit)); if (params?.offset) searchParams.set('offset', String(params.offset)); const qs = searchParams.toString(); return apiClient.get(`/reports${qs ? `?${qs}` : ''}`); } export function getReport(id: string): Promise { return apiClient.get(`/reports/${id}`); } export function getReportStatus(id: string): Promise { return apiClient.get(`/reports/${id}/status`); } export function generateReport(data: { type: ReportType; title: string; params: Record; }): Promise { return apiClient.post('/reports/generate', data); } export function deleteReport(id: string): Promise { return apiClient.delete(`/reports/${id}`); }