2019-11-21 21:51:52 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { CURRENCY } from '@woocommerce/wc-admin-settings';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce dependencies
|
|
|
|
*/
|
|
|
|
import Currency from '@woocommerce/currency';
|
|
|
|
|
|
|
|
// Pass the site currency settings to our instance.
|
|
|
|
const storeCurrency = new Currency( CURRENCY );
|
|
|
|
|
|
|
|
// Allow our exported API to be called without knowing about the Currency instance.
|
|
|
|
const formatCurrency = storeCurrency.formatCurrency.bind( storeCurrency );
|
|
|
|
const formatDecimal = storeCurrency.formatDecimal.bind( storeCurrency );
|
2020-02-14 02:23:21 +00:00
|
|
|
const formatDecimalString = storeCurrency.formatDecimalString.bind(
|
|
|
|
storeCurrency
|
|
|
|
);
|
2019-11-21 21:51:52 +00:00
|
|
|
const render = storeCurrency.render.bind( storeCurrency );
|
2019-12-03 23:32:13 +00:00
|
|
|
const setCurrency = storeCurrency.setCurrency.bind( storeCurrency );
|
2019-11-21 21:51:52 +00:00
|
|
|
|
|
|
|
// Export the expected API for the consuming app, along with the instance.
|
|
|
|
export {
|
|
|
|
storeCurrency as Currency,
|
|
|
|
formatCurrency,
|
|
|
|
formatDecimal as getCurrencyFormatDecimal,
|
|
|
|
formatDecimalString as getCurrencyFormatString,
|
|
|
|
render as renderCurrency,
|
2019-12-03 23:32:13 +00:00
|
|
|
setCurrency,
|
2019-11-21 21:51:52 +00:00
|
|
|
};
|