From 55b8b67a6e602a29181aae7a4b5b102a6efa8b7d Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Fri, 15 May 2026 20:51:58 -0500 Subject: [PATCH] fix: coerce maintenance cost to number for amount column (refs #239) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Postgres numeric columns come back as strings via node-postgres, so typeof rec.cost === 'number' was false and the amount column rendered as '—'. Coerce with Number() (matching the pattern in MaintenanceRecordsList) so the cost displays as a dollar amount. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/features/vehicles/mobile/VehicleDetailMobile.tsx | 4 +++- frontend/src/features/vehicles/pages/VehicleDetailPage.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/features/vehicles/mobile/VehicleDetailMobile.tsx b/frontend/src/features/vehicles/mobile/VehicleDetailMobile.tsx index bef18a7..b241054 100644 --- a/frontend/src/features/vehicles/mobile/VehicleDetailMobile.tsx +++ b/frontend/src/features/vehicles/mobile/VehicleDetailMobile.tsx @@ -142,7 +142,9 @@ export const VehicleDetailMobile: React.FC = ({ secondaryParts.push(new Date(rec.date).toLocaleDateString()); secondaryParts.push('Maintenance'); const secondary = secondaryParts.join(' • '); - const amount = typeof rec.cost === 'number' ? `$${rec.cost.toFixed(2)}` : undefined; + // Backend returns numeric/decimal columns as strings via node-postgres; coerce. + const costNum = rec.cost != null ? Number(rec.cost) : NaN; + const amount = Number.isFinite(costNum) ? `$${costNum.toFixed(2)}` : undefined; list.push({ id: rec.id, type: 'Maintenance', diff --git a/frontend/src/features/vehicles/pages/VehicleDetailPage.tsx b/frontend/src/features/vehicles/pages/VehicleDetailPage.tsx index 65e7e0f..4bdce5b 100644 --- a/frontend/src/features/vehicles/pages/VehicleDetailPage.tsx +++ b/frontend/src/features/vehicles/pages/VehicleDetailPage.tsx @@ -148,7 +148,9 @@ export const VehicleDetailPage: React.FC = () => { if (subtypeText) parts.push(subtypeText); if (rec.shopName) parts.push(rec.shopName); const summary = parts.join(' • '); - const amount = typeof rec.cost === 'number' ? `$${rec.cost.toFixed(2)}` : undefined; + // Backend returns numeric/decimal columns as strings via node-postgres; coerce. + const costNum = rec.cost != null ? Number(rec.cost) : NaN; + const amount = Number.isFinite(costNum) ? `$${costNum.toFixed(2)}` : undefined; list.push({ id: rec.id, type: 'Maintenance', date: rec.date, summary, amount }); } }