2021-12-15 16:30:17 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Currency, CurrencyResponse } from '@woocommerce/types';
|
2023-04-28 10:29:45 +00:00
|
|
|
import { snakeCaseKeys } from '@woocommerce/base-utils';
|
2021-12-15 16:30:17 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-06-15 09:56:52 +00:00
|
|
|
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 ),
|
2022-06-15 09:56:52 +00:00
|
|
|
] )
|
|
|
|
);
|
2021-12-15 16:30:17 +00:00
|
|
|
|
|
|
|
export const currencyControl = {
|
|
|
|
control: 'select',
|
2022-02-25 08:58:09 +00:00
|
|
|
options: currencies,
|
|
|
|
mapping: Object.keys( currencies ),
|
2021-12-15 16:30:17 +00:00
|
|
|
};
|