mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-02 12:22:40 +02:00
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:
parent
38faf59d1e
commit
262a91b558
2 changed files with 11 additions and 7 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue