diff --git a/apps/portal/src/utils/offers/currency/index.tsx b/apps/portal/src/utils/offers/currency/index.tsx new file mode 100644 index 00000000..c2cfcb05 --- /dev/null +++ b/apps/portal/src/utils/offers/currency/index.tsx @@ -0,0 +1,14 @@ +import type { Money } from '~/components/offers/types'; + +export function convertCurrencyToString({ currency, value }: Money) { + if (!value) { + return '-'; + } + const formatter = new Intl.NumberFormat('en-US', { + currency, + maximumFractionDigits: 0, // (this suffices for whole numbers, but will print 2500.10 as $2,500.1) + minimumFractionDigits: 0, // (causes 2500.99 to be printed as $2,501) + style: 'currency', + }); + return `${formatter.format(10000)}`; /* $2,500.00 */ +}