fix: coerce maintenance cost to number for amount column (refs #239)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 1m11s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 42s
Deploy to Staging / Verify Staging (pull_request) Successful in 4s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 3s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped

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) <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-05-15 20:51:58 -05:00
parent a49f419eab
commit 55b8b67a6e
2 changed files with 6 additions and 2 deletions

View File

@@ -142,7 +142,9 @@ export const VehicleDetailMobile: React.FC<VehicleDetailMobileProps> = ({
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',

View File

@@ -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 });
}
}