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:
@@ -14,6 +14,8 @@ export interface ValuationRequest {
|
||||
roadWidth?: number;
|
||||
yearBuilt?: number;
|
||||
hasLegalPaper?: boolean;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
}
|
||||
|
||||
export interface ValuationComparable {
|
||||
@@ -69,17 +71,24 @@ export interface ValuationHistoryResponse {
|
||||
// ─── API ────────────────────────────────────────────────
|
||||
|
||||
export const valuationApi = {
|
||||
predict: (data: ValuationRequest) =>
|
||||
apiClient.post<ValuationResult>('/valuation/predict', data),
|
||||
/** Request AVM estimate via GET /analytics/valuation */
|
||||
predict: (data: ValuationRequest) => {
|
||||
const params = new URLSearchParams();
|
||||
if (data.latitude) params.set('latitude', String(data.latitude));
|
||||
if (data.longitude) params.set('longitude', String(data.longitude));
|
||||
if (data.area) params.set('areaM2', String(data.area));
|
||||
if (data.propertyType) params.set('propertyType', data.propertyType);
|
||||
const qs = params.toString();
|
||||
return apiClient.get<ValuationResult>(`/analytics/valuation${qs ? `?${qs}` : ''}`);
|
||||
},
|
||||
|
||||
getHistory: (page = 1, limit = 10) =>
|
||||
apiClient.get<ValuationHistoryResponse>(
|
||||
`/valuation/history?page=${page}&limit=${limit}`,
|
||||
),
|
||||
/** History is not available server-side — return empty result */
|
||||
getHistory: (_page = 1, _limit = 10): Promise<ValuationHistoryResponse> =>
|
||||
Promise.resolve({ data: [], total: 0, page: _page, limit: _limit }),
|
||||
|
||||
getById: (id: string) =>
|
||||
apiClient.get<ValuationResult>(`/valuation/${id}`),
|
||||
apiClient.get<ValuationResult>(`/analytics/valuation?propertyId=${id}`),
|
||||
|
||||
predictForListing: (listingId: string) =>
|
||||
apiClient.post<ValuationResult>(`/valuation/predict-listing/${listingId}`),
|
||||
apiClient.get<ValuationResult>(`/analytics/valuation?propertyId=${listingId}`),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user