summaryrefslogtreecommitdiff
path: root/storefront/lib/format.js
blob: 2f44c2ed3179b5116bb774e20198f4cc33f2d4b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
export const formatAmount = (amount, currencyCode = "EUR") => {
  if (typeof amount !== "number") {
    return ""
  }

  const normalizedCurrency = currencyCode.toUpperCase()
  return new Intl.NumberFormat("fr-FR", {
    style: "currency",
    currency: normalizedCurrency,
  }).format(amount / 100)
}