Note: This does NOT currently affect Quotes, it's only purpose currently is to track the selected currency so that content can be rendered/updated.
npm i @wearejh/m2-pwa-currency
This modules gives you a register
function for state & events,
along with an apollo link
that will add a header to outgoing requests.
import { init } from '@wearejh/m2-pwa-engine/lib/browser';
import { createCurrencyBrowser } from '@wearejh/m2-pwa-currency';
const { link, register } = createCurrencyBrowser();
const createApp = init({
features: [register()],
links: [link],
// the rest of the params to init
});
For initial rendering, you'll want to read the content-currency
cookie and
use that to set some initial state.
import { createCurrencySSR } from '@wearejh/m2-pwa-currency';
const { reducers, state } = createCurrencySSR(req.cookies['content-currency']);
const { App, Inner } = getSsrInit({
state: {
...state,
},
reducers: {
...reducers,
},
});