feat(industrial): update TypeScript types for Float→Decimal USD field migration (GOO-27)
Migration SQL (20260422120000_industrial_usd_to_decimal) and Prisma schema already reflected Decimal(18,4). This commit completes the TypeScript / frontend layer. API changes: - Domain repo interfaces (IndustrialListingListItem, IndustrialListingDetailData, IndustrialParkListItem, IndustrialParkDetailData, IndustrialMarketData): USD money fields changed from number|null → string|null (PostgreSQL numeric serialises as string in raw query results) - Raw DB interface types in Prisma repositories updated to string|null for Decimal columns - toDomain() mappers: parseFloat() added where entity props require number|null for business-logic arithmetic - estimate-industrial-rent handler: Number() cast on Prisma ORM Decimal objects before arithmetic and comparisons Web changes: - khu-cong-nghiep-api.ts: IndustrialParkListItem, IndustrialParkDetail, IndustrialListingItem, IndustrialMarketData USD fields → string|null with JSDoc - listing-card.tsx: parseFloat() wrapping for priceUsdM2/totalLeasePrice display - park-compare-client.tsx: parseFloat() for landRentUsdM2Year in radar score Note: pre-existing test failures in filter-bar/login/search specs are unrelated to this migration (confirmed present on branch before this change). Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -15,9 +15,9 @@ interface ListingCardProps {
|
||||
|
||||
export function IndustrialListingCard({ listing }: ListingCardProps) {
|
||||
const priceText = listing.priceUsdM2
|
||||
? `$${listing.priceUsdM2}/${listing.pricingUnit ?? 'm²/tháng'}`
|
||||
? `$${parseFloat(listing.priceUsdM2)}/${listing.pricingUnit ?? 'm²/tháng'}`
|
||||
: listing.totalLeasePrice
|
||||
? `$${listing.totalLeasePrice.toLocaleString()}`
|
||||
? `$${parseFloat(listing.totalLeasePrice).toLocaleString()}`
|
||||
: 'Liên hệ';
|
||||
|
||||
const leaseTermText =
|
||||
|
||||
@@ -45,7 +45,7 @@ function normalizeScore(park: IndustrialParkDetail, metric: string): number {
|
||||
case 'area':
|
||||
return Math.min((park.totalAreaHa / 1000) * 100, 100);
|
||||
case 'rent': {
|
||||
const rent = park.landRentUsdM2Year ?? 0;
|
||||
const rent = park.landRentUsdM2Year != null ? parseFloat(park.landRentUsdM2Year) : 0;
|
||||
return rent > 0 ? Math.min((rent / 150) * 100, 100) : 0;
|
||||
}
|
||||
case 'infrastructure': {
|
||||
|
||||
Reference in New Issue
Block a user