'use client'; import { Building, CalendarDays, TrendingDown, TrendingUp, Users, Warehouse, } from 'lucide-react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card'; import { formatPrice, formatPricePerM2 } from '@/lib/currency'; import type { MarketContext } from '@/lib/valuation-api'; interface MarketContextCardProps { context: MarketContext; } export function MarketContextCard({ context }: MarketContextCardProps) { const isGrowthPositive = context.priceGrowthYoY >= 0; const stats = [ { label: 'Giá trung bình/m²', value: formatPricePerM2(context.avgPricePerM2), icon: Building, }, { label: 'Giá trung vị', value: formatPrice(context.medianPrice), icon: Warehouse, }, { label: 'Tăng trưởng YoY', value: `${isGrowthPositive ? '+' : ''}${context.priceGrowthYoY.toFixed(1)}%`, icon: isGrowthPositive ? TrendingUp : TrendingDown, color: isGrowthPositive ? 'text-green-600' : 'text-red-600', }, { label: 'Chỉ số nhu cầu', value: `${context.demandIndex.toFixed(0)}/100`, icon: Users, }, { label: 'Nguồn cung', value: `${context.supplyCount.toLocaleString('vi-VN')} BĐS`, icon: Building, }, { label: 'Thời gian bán TB', value: `${context.avgDaysOnMarket} ngày`, icon: CalendarDays, }, ]; return ( Bối cảnh thị trường {context.district}, {context.city} — {context.period}
{stats.map((stat) => { const Icon = stat.icon; return (

{stat.label}

{stat.value}

); })}
); }