formatCurrency.tsx 369 B

123456789101112131415161718
  1. import {displayPrice} from 'getsentry/views/amCheckout/utils';
  2. /**
  3. * Converts from cents to human-readable string
  4. *
  5. * 0 => $0
  6. * 1 => $0.01
  7. * 50 => $0.50
  8. * 100 => $1
  9. * 101 => $1.01
  10. * 150 => $1.50
  11. */
  12. const formatCurrency = (value: number | string) => {
  13. const cents = Number(value);
  14. return `${displayPrice({cents})}`;
  15. };
  16. export default formatCurrency;