The location to look up (e.g., 'US', 'GB')
The corresponding currency code (e.g., 'USD', 'GBP')
getCurrencyCodeFromLocation('US') // Returns 'USD'
getCurrencyCodeFromLocation('GB') // Returns 'GBP'
getCurrencyCodeFromLocation('OTHER') // Returns 'USD'
export function getCurrencyCodeFromLocation(location: CountryCode): CurrencyCode {
return findCountryByIso2(String(location))?.currency?.code ?? 'USD';
}
Maps a location to its corresponding currency code. Looks the country up in
country-list-jsby its two-letter code and reads the associated currency. Falls back to 'USD' for unknown locations (e.g. the synthetic 'OTHER' option).