woocommerce/plugins/woocommerce-blocks/storybook/custom-controls/currency.ts

41 lines
817 B
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { Currency, CurrencyResponse } from '@woocommerce/types';
2023-04-28 10:29:45 +00:00
import { snakeCaseKeys } from '@woocommerce/base-utils';
export const currencies: Record< string, Currency > = {
EUR: {
code: 'EUR',
symbol: '€',
thousandSeparator: '.',
decimalSeparator: ',',
minorUnit: 2,
prefix: '',
suffix: '€',
},
USD: {
code: 'USD',
symbol: '$',
thousandSeparator: ',',
decimalSeparator: '.',
minorUnit: 2,
prefix: '$',
suffix: '',
},
} as const;
export const currenciesAPIShape: Record< string, CurrencyResponse > =
Object.fromEntries(
Object.entries( currencies ).map( ( [ key, value ] ) => [
key,
2023-04-28 10:29:45 +00:00
snakeCaseKeys( value ),
] )
);
export const currencyControl = {
control: 'select',
options: currencies,
mapping: Object.keys( currencies ),
};