Fix notification history crash when prices are strings

PostgreSQL DECIMAL fields are returned as strings by node-postgres.
Convert to numbers before calling toFixed() to prevent TypeError.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
clucraft 2026-01-24 03:10:06 -05:00
parent 38faf59d1e
commit 262a91b558
2 changed files with 11 additions and 7 deletions

View file

@ -47,10 +47,12 @@ function getNotificationTitle(notification: NotificationHistoryEntry): string {
}
}
function formatPrice(price: number | null, currency: string | null): string {
if (price === null) return '';
function formatPrice(price: number | string | null, currency: string | null): string {
if (price === null || price === undefined) return '';
const numPrice = typeof price === 'string' ? parseFloat(price) : price;
if (isNaN(numPrice)) return '';
const symbol = currency === 'EUR' ? '\u20AC' : currency === 'GBP' ? '\u00A3' : '$';
return `${symbol}${price.toFixed(2)}`;
return `${symbol}${numPrice.toFixed(2)}`;
}
export default function NotificationBell() {