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

@@ -58,9 +58,9 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
return (
<Card>
<CardHeader>
<CardTitle>Dinh gia bat dong san</CardTitle>
<CardTitle>Đnh giá bt đng sn</CardTitle>
<CardDescription>
Nhap thong tin bat dong san de nhan uoc tinh gia tu AI
Nhp thông tin bt đng sn đ nhn ưc tính giá t AI
</CardDescription>
</CardHeader>
<CardContent>
@@ -68,9 +68,9 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
{/* Row 1: Property type + City */}
<div className="grid gap-4 sm:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="propertyType">Loai bat dong san *</Label>
<Label htmlFor="propertyType">Loi bt đng sn *</Label>
<Select id="propertyType" {...register('propertyType')}>
<option value="">-- Chon loai --</option>
<option value="">-- Chn loi --</option>
{VALUATION_PROPERTY_TYPES.map((t) => (
<option key={t.value} value={t.value}>
{t.label}
@@ -83,7 +83,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="city">Tinh/Thanh pho *</Label>
<Label htmlFor="city">Tnh/Thành ph *</Label>
<Select id="city" {...register('city')}>
{CITIES.map((c) => (
<option key={c.value} value={c.value}>
@@ -100,10 +100,10 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
{/* Row 2: District + Area */}
<div className="grid gap-4 sm:grid-cols-2">
<div className="space-y-2">
<Label htmlFor="district">Quan/Huyen *</Label>
<Label htmlFor="district">Qun/Huyn *</Label>
<Input
id="district"
placeholder="VD: Quan 1, Binh Thanh..."
placeholder="VD: Qun 1, Bình Thnh..."
{...register('district')}
/>
{errors.district && (
@@ -112,7 +112,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="area">Dien tich (m2) *</Label>
<Label htmlFor="area">Din tích (m²) *</Label>
<Input
id="area"
type="number"
@@ -129,7 +129,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
{/* Row 3: Bedrooms + Bathrooms + Floors */}
<div className="grid gap-4 sm:grid-cols-3">
<div className="space-y-2">
<Label htmlFor="bedrooms">Phong ngu</Label>
<Label htmlFor="bedrooms">Phòng ng</Label>
<Input
id="bedrooms"
type="number"
@@ -139,7 +139,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="bathrooms">Phong tam</Label>
<Label htmlFor="bathrooms">Phòng tm</Label>
<Input
id="bathrooms"
type="number"
@@ -149,7 +149,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="floors">So tang</Label>
<Label htmlFor="floors">S tng</Label>
<Input
id="floors"
type="number"
@@ -162,7 +162,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
{/* Row 4: Frontage + Road Width + Year Built */}
<div className="grid gap-4 sm:grid-cols-3">
<div className="space-y-2">
<Label htmlFor="frontage">Mat tien (m)</Label>
<Label htmlFor="frontage">Mt tin (m)</Label>
<Input
id="frontage"
type="number"
@@ -173,7 +173,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="roadWidth">Do rong duong (m)</Label>
<Label htmlFor="roadWidth">Đ rng đưng (m)</Label>
<Input
id="roadWidth"
type="number"
@@ -184,7 +184,7 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="yearBuilt">Nam xay dung</Label>
<Label htmlFor="yearBuilt">Năm xây dng</Label>
<Input
id="yearBuilt"
type="number"
@@ -202,11 +202,11 @@ export function ValuationForm({ onSubmit, isLoading }: ValuationFormProps) {
className="h-4 w-4 rounded border-input"
{...register('hasLegalPaper')}
/>
<Label htmlFor="hasLegalPaper">Co so do/giay to hop phap</Label>
<Label htmlFor="hasLegalPaper">Có s đ/giấy tờ hợp pháp</Label>
</div>
<Button type="submit" disabled={isLoading} className="w-full sm:w-auto">
{isLoading ? 'Dang dinh gia...' : 'Dinh gia ngay'}
{isLoading ? 'Đang định giá...' : 'Định giá ngay'}
</Button>
</form>
</CardContent>