From 846ea652d857d4dc74bc09f85294d3d0b1ca0734 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Tue, 21 Apr 2026 12:41:30 +0700 Subject: [PATCH] fix(web): align PriceChangePct keys with API (d1/d7/d30) API's market-snapshot returns priceChangePct with keys d1/d7/d30 but the FE interface and KpiStrip accessor used day1/day7/day30, causing a TypeError crash on the home page for authenticated users. Rename the FE type, update KpiStrip accessors, and fix the landing test fixture. Fixes TEC-3091. Co-Authored-By: Paperclip --- apps/web/app/[locale]/(public)/__tests__/landing.spec.tsx | 2 +- apps/web/app/[locale]/(public)/page.tsx | 4 ++-- apps/web/lib/analytics-api.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/app/[locale]/(public)/__tests__/landing.spec.tsx b/apps/web/app/[locale]/(public)/__tests__/landing.spec.tsx index f1034b7..88b7f0f 100644 --- a/apps/web/app/[locale]/(public)/__tests__/landing.spec.tsx +++ b/apps/web/app/[locale]/(public)/__tests__/landing.spec.tsx @@ -84,7 +84,7 @@ vi.mock('@/lib/hooks/use-analytics', () => ({ activeCount: 1234, avgPrice: 5_000_000_000, medianPrice: 3_500_000_000, - priceChangePct: { day1: 0.1, day7: 1.5, day30: 3.2 }, + priceChangePct: { d1: 0.1, d7: 1.5, d30: 3.2 }, avgPricePerM2: 85_000_000, daysOnMarket: 28, newListings24h: 15, diff --git a/apps/web/app/[locale]/(public)/page.tsx b/apps/web/app/[locale]/(public)/page.tsx index 50d941f..e35a8ec 100644 --- a/apps/web/app/[locale]/(public)/page.tsx +++ b/apps/web/app/[locale]/(public)/page.tsx @@ -139,7 +139,7 @@ function KpiStrip({ city }: { city: string }) { } loading={isLoading} @@ -147,7 +147,7 @@ function KpiStrip({ city }: { city: string }) { } loading={isLoading} diff --git a/apps/web/lib/analytics-api.ts b/apps/web/lib/analytics-api.ts index 6b98467..d6e7d05 100644 --- a/apps/web/lib/analytics-api.ts +++ b/apps/web/lib/analytics-api.ts @@ -139,9 +139,9 @@ export interface ProjectAiAdvice { /* ------------------------------------------------------------------ */ export interface PriceChangePct { - day1: number; - day7: number; - day30: number; + d1: number; + d7: number; + d30: number; } export interface MarketSnapshotResponse {