/** Keep in sync with `backend/src/Common/Constants/SupportedCurrencyCodes.php`. */ export const SUPPORTED_CURRENCIES = [ { code: 'USD', symbol: '$', label: 'USD' }, { code: 'EUR', symbol: '€', label: 'EUR' }, { code: 'GBP', symbol: '£', label: 'GBP' }, { code: 'CAD', symbol: '$', label: 'CAD' }, { code: 'AUD', symbol: '$', label: 'AUD' }, { code: 'JPY', symbol: '¥', label: 'JPY' }, { code: 'CHF', symbol: 'Fr', label: 'CHF' }, { code: 'SEK', symbol: 'kr', label: 'SEK' }, { code: 'NOK', symbol: 'kr', label: 'NOK' }, { code: 'DKK', symbol: 'kr', label: 'DKK' }, { code: 'PLN', symbol: 'zł', label: 'PLN' }, { code: 'CZK', symbol: 'Kč', label: 'CZK' }, { code: 'HUF', symbol: 'Ft', label: 'HUF' }, { code: 'NZD', symbol: '$', label: 'NZD' }, { code: 'SGD', symbol: '$', label: 'SGD' }, { code: 'HKD', symbol: '$', label: 'HKD' }, { code: 'INR', symbol: '₹', label: 'INR' }, { code: 'BRL', symbol: 'R$', label: 'BRL' }, { code: 'MXN', symbol: '$', label: 'MXN' }, { code: 'ZAR', symbol: 'R', label: 'ZAR' }, ] as const export type CurrencyCode = (typeof SUPPORTED_CURRENCIES)[number]['code'] export const DEFAULT_CURRENCY_CODE: CurrencyCode = 'USD' export function isCurrencyCode(value: string): value is CurrencyCode { return SUPPORTED_CURRENCIES.some((c) => c.code === value) } export function getCurrencyOption(code: CurrencyCode): (typeof SUPPORTED_CURRENCIES)[number] { const found = SUPPORTED_CURRENCIES.find((c) => c.code === code) return found ?? SUPPORTED_CURRENCIES[0] } export function getCurrencySymbolForCode(code: CurrencyCode): string { return getCurrencyOption(code).symbol } export function formatCurrencySelectLabel(code: CurrencyCode): string { const o = getCurrencyOption(code) return `${o.symbol} ${o.label}` }