diff options
Diffstat (limited to 'storefront/lib/format.js')
| -rw-r--r-- | storefront/lib/format.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/storefront/lib/format.js b/storefront/lib/format.js new file mode 100644 index 0000000..9e92a8b --- /dev/null +++ b/storefront/lib/format.js @@ -0,0 +1,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)
+}
|
