Add setting to toggle rounding of prices

This commit is contained in:
Erik Michelson
2024-12-30 01:07:38 +01:00
parent 276fd1e733
commit e93f89aa51
8 changed files with 59 additions and 46 deletions

View File

@@ -17,3 +17,15 @@ export function getCurrencySymbol(locale: string | undefined, currency: string)
.replace(/\d/g, "")
.trim();
}
export function useCurrencyFormatter() {
const currency = useCurrency();
const roundPrices = JSON.parse(useGetSetting("round_prices").data?.value ?? "false");
return new Intl.NumberFormat(undefined, {
style: "currency",
currency: currency,
currencyDisplay: "narrowSymbol",
notation: roundPrices ? "compact" : "standard",
});
}