fix: avoid localizing currencies and default missing value to N/A

This commit is contained in:
Christel Westerberg
2025-01-07 15:48:44 +01:00
parent 5018cba623
commit a3331850a2
12 changed files with 22 additions and 68 deletions

View File

@@ -16,17 +16,9 @@ export function getSingleDecimal(n: Number | string) {
* @param currency - currency code
* @returns localized and formatted number in string type with currency
*/
export function formatPrice(
intl: IntlShape,
price: number,
currency?: string | null
) {
if (!currency) {
return intl.formatNumber(price)
}
return intl.formatNumber(price, {
style: "currency",
currency,
export function formatPrice(intl: IntlShape, price: number, currency: string) {
const localizedPrice = intl.formatNumber(price, {
minimumFractionDigits: 0,
})
return `${localizedPrice} ${currency}`
}