spree
spree copied to clipboard
feat: add getStore function used in nuxt.config.js
Description
This PR adds a helper that fetches the Spree store configuration from the api that is then being passed to the nuxt.config.js. This is done to avoid static VSF configuration as much as possible.
There are a few crucial parts of the configuration that the api response is missing data for:
{
locales: [
{
code: 'de',
iso: 'de-DE',
label: 'German',
file: 'de.js'
}
],
currencies: {
{ code: 'USD', label: 'Dollar' },
},
country: 'US',
}
When it comes to loading this config dynamically on each page load, the available locales for i18n module have to be defined in nuxt.config.js (docs). The currencies and meta tags could be loaded dynamically from the app. But splitting this logic between nuxt.config and components seems a bit messy to me, besides it won't solve the problem of having to restart the vsf server.
We could put all of the store config initialisation into the nuxt.config file (as it is now) and set up a redeployment with webhooks every time the store configuration in Spree changes. Technically only rerunning yarn start
would be enough but that is up to the hosting platform.
Related Issue
Motivation and Context
How Has This Been Tested?
visually
Screenshots (if appropriate):
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the CONTRIBUTING document.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.