UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

27 lines (26 loc) 919 B
"use client"; import { useCallback, useContext } from 'react'; import SharedContext from "../../../../shared/Context.js"; import { getCurrencyData } from "../../Field/SelectCurrency/index.js"; export default function useCurrency() { const { locale } = useContext(SharedContext); const getCurrencyDisplayNameByIso = useCallback(iso => { var _getCurrencyData; if (!iso) { return null; } const lang = locale === null || locale === void 0 ? void 0 : locale.split('-')[0]; return (_getCurrencyData = getCurrencyData({ lang, filter: currency => { return currency.iso === iso; } })) === null || _getCurrencyData === void 0 || (_getCurrencyData = _getCurrencyData.at(0)) === null || _getCurrencyData === void 0 ? void 0 : _getCurrencyData.selected_value; }, [locale]); return { getCurrencyDisplayNameByIso }; } //# sourceMappingURL=useCurrency.js.map