All files / libs/kernel/intl/components/src/lib/hooks use-currency-symbol-characters.ts

100% Statements 11/11
66.66% Branches 2/3
50% Functions 1/2
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 121x 1x 1x 1x 1x 2x 2x 1x 1x 1x 1x  
import { useIntl } from 'react-intl';
 
import { type CurrencySymbolsEnum } from '@amalia/ext/iso-4217';
 
export const getCurrencySymbolCharacters = (locale: string, currencySymbol: CurrencySymbolsEnum) =>
  new Intl.NumberFormat(locale, { style: 'currency', currency: currencySymbol })
    .formatToParts(1)
    .find((x) => x.type === 'currency')?.value ?? '';
 
export const useCurrencySymbolCharacters = (currencySymbol: CurrencySymbolsEnum) =>
  getCurrencySymbolCharacters(useIntl().locale, currencySymbol);