Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { defaultLocale, formatCurrencyAmount, type CurrencyAmount } from "@hivegrid/i18n";
|
||||
|
||||
// HiveGrid v1 operational amounts are EUR; punctuation and currency placement
|
||||
// follow the request/viewer locale supplied by the server-side VM builder.
|
||||
const EURO_PRICE_OPTIONS = {
|
||||
currency: "EUR",
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
} as const;
|
||||
|
||||
function isCurrencyAmount(value: unknown): value is CurrencyAmount {
|
||||
return (
|
||||
typeof value === "number" ||
|
||||
typeof value === "bigint" ||
|
||||
typeof value === "string" ||
|
||||
(typeof value === "object" && value !== null && "toString" in value && typeof value.toString === "function")
|
||||
);
|
||||
}
|
||||
|
||||
export function formatEuroAmount(value: unknown, locale: string = defaultLocale): string | null {
|
||||
if (value == null) return null;
|
||||
if (!isCurrencyAmount(value)) return null;
|
||||
return formatCurrencyAmount(value, { ...EURO_PRICE_OPTIONS, locale });
|
||||
}
|
||||
Reference in new issue
Block a user