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);
}
