Files
flyer-crawler.projectium.com/src/utils/formatUtils.ts
Torben Sorensen 4e20b1b430
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 54s
even more and more test fixes
2026-01-05 01:26:12 -08:00

14 lines
628 B
TypeScript

// src/utils/formatUtils.ts
/**
* Formats a numeric value in cents into a currency string (e.g., $4.99).
* Handles different locales and currency symbols gracefully.
*
* @param amountInCents The amount in cents to format. Can be null or undefined.
* @returns A formatted currency string (e.g., "$4.99"), or 'N/A' if the input is null/undefined.
*/
export const formatCurrency = (amountInCents: number | null | undefined): string => {
if (amountInCents === null || amountInCents === undefined) return 'N/A';
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(amountInCents / 100);
};