fix(web): unwrap {data} envelope in getNeighborhoodScore (TEC-3093)

apiClient.get returns the raw JSON body { data, cacheMeta }, so callers
were storing the envelope in state and reading totalScore as undefined,
crashing ListingDetailClient via undefined.toFixed(1).

Unwrap .data inside getNeighborhoodScore so consumers receive the bare
NeighborhoodScoreResult as the existing type expects.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-21 13:17:49 +07:00
parent 53580d444b
commit 912121cf09

View File

@@ -298,7 +298,9 @@ export const listingsApi = {
apiClient.get<ListingSimilarItem[]>(`/listings/${listingId}/similar?limit=${limit}`),
getNeighborhoodScore: (district: string, city: string = 'Hồ Chí Minh') =>
apiClient.get<NeighborhoodScoreResult>(
`/analytics/neighborhoods/${encodeURIComponent(district)}/score?city=${encodeURIComponent(city)}`,
),
apiClient
.get<{ data: NeighborhoodScoreResult }>(
`/analytics/neighborhoods/${encodeURIComponent(district)}/score?city=${encodeURIComponent(city)}`,
)
.then((res) => res.data),
};