import { apiClient } from './api-client'; export interface MarketReportDistrict { district: string; city: string; propertyType: string; period: string; medianPrice: string; avgPriceM2: number; totalListings: number; daysOnMarket: number; inventoryLevel: number; absorptionRate: number | null; yoyChange: number | null; } export interface MarketReportResponse { city: string; period: string; districts: MarketReportDistrict[]; } export interface HeatmapDataPoint { district: string; city: string; avgPriceM2: number; totalListings: number; medianPrice: string; } export interface HeatmapResponse { city: string; period: string; dataPoints: HeatmapDataPoint[]; } export interface PriceTrendPoint { period: string; medianPrice: string; avgPriceM2: number; totalListings: number; } export interface PriceTrendResponse { district: string; city: string; propertyType: string; trend: PriceTrendPoint[]; } export interface DistrictStats { district: string; city: string; propertyType: string; medianPrice: string; avgPriceM2: number; totalListings: number; daysOnMarket: number; inventoryLevel: number; absorptionRate: number | null; yoyChange: number | null; } export interface DistrictStatsResponse { city: string; period: string; districts: DistrictStats[]; } export type NearbyPOICategory = | 'school' | 'hospital' | 'transit' | 'shopping' | 'restaurant' | 'park'; export interface NearbyPOI { id: string; name: string; type: string; category: NearbyPOICategory; lat: number; lng: number; distance: number; address: string | null; } export interface NearbyPOIsResponse { pois: NearbyPOI[]; center: { lat: number; lng: number }; } export const analyticsApi = { getMarketReport: (city: string, period: string, propertyType?: string) => { const params = new URLSearchParams({ city, period }); if (propertyType) params.set('propertyType', propertyType); return apiClient.get(`/analytics/market-report?${params}`); }, getHeatmap: (city: string, period: string) => { const params = new URLSearchParams({ city, period }); return apiClient.get(`/analytics/heatmap?${params}`); }, getPriceTrend: (district: string, city: string, propertyType: string, periods: string[]) => { const params = new URLSearchParams({ district, city, propertyType, periods: periods.join(',') }); return apiClient.get(`/analytics/price-trend?${params}`); }, getDistrictStats: (city: string, period: string) => { const params = new URLSearchParams({ city, period }); return apiClient.get(`/analytics/district-stats?${params}`); }, getNearbyPOIs: (lat: number, lng: number, radius = 2000, limit = 30) => apiClient.get( `/analytics/pois/nearby?lat=${lat}&lng=${lng}&radius=${radius}&limit=${limit}`, ), };