mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 21:27:20 +01:00
add dropdown logic for revenue report, defaults to USD for unknown currency code
This commit is contained in:
parent
214396f4b6
commit
be50e8a575
8 changed files with 155 additions and 12 deletions
|
|
@ -83,10 +83,22 @@ export function stringToColor(str: string) {
|
|||
}
|
||||
|
||||
export function formatCurrency(value: number, currency: string, locale = 'en-US') {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
}).format(value);
|
||||
let formattedValue;
|
||||
|
||||
try {
|
||||
formattedValue = new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
});
|
||||
} catch (error) {
|
||||
// Fallback to default currency format if an error occurs
|
||||
formattedValue = new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
});
|
||||
}
|
||||
|
||||
return formattedValue.format(value);
|
||||
}
|
||||
|
||||
export function formatLongCurrency(value: number, currency: string, locale = 'en-US') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue