'use client'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import type { ValuationResult } from '@/lib/valuation-api'; interface ValuationResultsProps { result: ValuationResult; } function formatPrice(num: number): string { if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(2)} tỷ`; if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(0)} triệu`; return num.toLocaleString('vi-VN'); } function formatPriceM2(price: number): string { if (price >= 1_000_000) return `${(price / 1_000_000).toFixed(1)} tr/m²`; return `${price.toLocaleString('vi-VN')} đ/m²`; } export function ValuationResults({ result }: ValuationResultsProps) { const confidencePct = Math.round(result.confidence * 100); return (
{/* Main estimate */} Giá ước tính bởi AI {formatPrice(result.estimatedPriceVND)} VNĐ

Độ tin cậy

{confidencePct}%

Giá/m²

{formatPriceM2(result.pricePerM2)}

Khoảng giá

{formatPrice(result.priceRangeLow)} – {formatPrice(result.priceRangeHigh)}

{/* Price drivers */} {result.priceDrivers.length > 0 && ( Yếu tố ảnh hưởng giá Các yếu tố chính tác động đến giá trị bất động sản
{result.priceDrivers.map((driver) => (
{driver.direction === 'positive' ? '+' : '-'} {Math.abs(driver.impact).toFixed(1)}%
{driver.feature}
))}
)} {/* Comparables */} {result.comparables.length > 0 && ( Bất động sản tương tự {result.comparables.length} bất động sản có đặc điểm tương tự trong khu vực
{result.comparables.map((comp) => (

{comp.title}

{comp.district} · {comp.areaM2} m²

{formatPrice(Number(comp.priceVND))}

{formatPriceM2(comp.pricePerM2)}

{Math.round(comp.similarity * 100)}% tương tự
))}
)}
); }