19 lines
480 B
TypeScript
19 lines
480 B
TypeScript
import { CustomFormatConfig } from '@formatjs/intl';
|
|
|
|
interface CurrencyProps {
|
|
currencyOptions?: CustomFormatConfig;
|
|
value?: number | bigint;
|
|
}
|
|
|
|
export function currencyFormatter(props: CurrencyProps) {
|
|
const { currencyOptions, value } = props;
|
|
if (!value) return 'Rp 0,00';
|
|
return new Intl.NumberFormat('id', {
|
|
style: 'currency',
|
|
currency: 'IDR',
|
|
minimumFractionDigits: 0,
|
|
currencyDisplay: 'narrowSymbol',
|
|
...currencyOptions,
|
|
}).format(value);
|
|
}
|