fix: valuation page Vietnamese diacritics, correct API routes, update tests

- Add proper Vietnamese diacritics to all valuation components
  (form, results, history) and their test assertions
- Fix valuation API client to use /analytics/valuation endpoint
- Return empty history gracefully (no server endpoint yet)

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ho Ngoc Hai
2026-04-13 12:03:47 +07:00
parent f373f7b1e2
commit ccfc176e40
8 changed files with 108 additions and 99 deletions

View File

@@ -14,17 +14,17 @@ interface ValuationHistoryProps {
}
function formatPrice(num: number): string {
if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(2)} ty`;
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(0)} trieu`;
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)} triu`;
return num.toLocaleString('vi-VN');
}
const PROPERTY_TYPE_LABELS: Record<string, string> = {
APARTMENT: 'Can ho',
HOUSE: 'Nha rieng',
VILLA: 'Biet thu',
LAND: 'Dat nen',
OFFICE: 'Van phong',
APARTMENT: 'Căn h',
HOUSE: 'Nhà riêng',
VILLA: 'Bit th',
LAND: 'Đất nn',
OFFICE: 'Văn phòng',
SHOPHOUSE: 'Shophouse',
};
@@ -41,19 +41,19 @@ export function ValuationHistory({
return (
<Card>
<CardHeader>
<CardTitle className="text-lg">Lich su dinh gia</CardTitle>
<CardTitle className="text-lg">Lch s đnh giá</CardTitle>
<CardDescription>
{total} lan dinh gia truoc do
{total} ln đnh giá trước đó
</CardDescription>
</CardHeader>
<CardContent>
{isLoading ? (
<div className="flex h-32 items-center justify-center text-muted-foreground">
Dang tai...
Đang ti...
</div>
) : items.length === 0 ? (
<div className="flex h-32 items-center justify-center text-muted-foreground">
Chua co lich su dinh gia
Chưa có lch s đnh giá
</div>
) : (
<>
@@ -70,7 +70,7 @@ export function ValuationHistory({
{PROPERTY_TYPE_LABELS[item.propertyType] || item.propertyType}
</p>
<p className="text-sm text-muted-foreground">
{item.district}, {item.city} &middot; {item.area} m2
{item.district}, {item.city} &middot; {item.area} m²
</p>
</div>
<div className="text-right">
@@ -93,7 +93,7 @@ export function ValuationHistory({
disabled={page <= 1}
onClick={() => onPageChange(page - 1)}
>
Truoc
Trước
</Button>
<span className="text-sm text-muted-foreground">
Trang {page}/{totalPages}
@@ -104,7 +104,7 @@ export function ValuationHistory({
disabled={page >= totalPages}
onClick={() => onPageChange(page + 1)}
>
Tiep
Tiếp
</Button>
</div>
)}