2
0

📄 Add Commercial License for ee folder (#1532)

This commit is contained in:
Baptiste Arnaud
2024-05-23 10:42:23 +02:00
committed by GitHub
parent 5680829906
commit 0eacbebbbe
246 changed files with 1472 additions and 1588 deletions

View File

@ -0,0 +1,21 @@
import { guessIfUserIsEuropean } from './guessIfUserIsEuropean'
type FormatPriceParams = {
currency?: 'eur' | 'usd'
maxFractionDigits?: number
}
export const formatPrice = (
price: number,
{ currency, maxFractionDigits = 0 }: FormatPriceParams = {
maxFractionDigits: 0,
}
) => {
const isEuropean = guessIfUserIsEuropean()
const formatter = new Intl.NumberFormat(isEuropean ? 'fr-FR' : 'en-US', {
style: 'currency',
currency: currency?.toUpperCase() ?? (isEuropean ? 'EUR' : 'USD'),
maximumFractionDigits: maxFractionDigits,
})
return formatter.format(price)
}