Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

#16 Update code to be compatible with VSF 1.11+ #17

Merged
merged 4 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ cart": {
}
````

4. Register the extension in `src/modules/index.ts` file and [disable the 'Instant checkout' module](https://github.com/Vendic/vsf-external-checkout/issues/11)
4. Register the extension in `src/modules/client.ts` file and [disable the 'Instant checkout' module](https://github.com/Vendic/vsf-external-checkout/issues/11)
````js
import { ExternalCheckout } from './external-checkout'
// import { InstantCheckout } from './instant-checkout'
Expand Down
23 changes: 8 additions & 15 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import {VueStorefrontModule, VueStorefrontModuleConfig} from '@vue-storefront/core/lib/module'
import {beforeEach} from './router/beforeEach'
import {routes} from './router/routes';
import config from 'config'

const store = {
namespaced: true,
state: {
key: null
}
}
import { StorefrontModule } from '@vue-storefront/core/lib/modules'
import { setupMultistoreRoutes } from '@vue-storefront/core/lib/multistore'
import { beforeEach } from './router/beforeEach'
import { routes } from './router/routes'

export const KEY = 'external-checkout'

const moduleConfig: VueStorefrontModuleConfig = {
key: KEY,
store: {modules: [{key: KEY, module: store}]},
router: {beforeEach, routes}
export const ExternalCheckout: StorefrontModule = function ({ router }) {
router.beforeEach(beforeEach)
setupMultistoreRoutes(config, router, routes, 10)
}

export const ExternalCheckout = new VueStorefrontModule(moduleConfig)
7 changes: 3 additions & 4 deletions router/beforeEach.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {Route} from 'vue-router'
import rootStore from '@vue-storefront/core/store'
import config from 'config'
import {currentStoreView} from '@vue-storefront/core/lib/multistore'
import { Route } from 'vue-router'
import rootStore from '@vue-storefront/core/store'
import { currentStoreView } from '@vue-storefront/core/lib/multistore'

export function beforeEach(to: Route, from: Route, next) {

const cartToken: string = rootStore.state.cart.cartServerToken;
const userToken: string = rootStore.state.user.token;
const externalCheckoutConfig = {...config.externalCheckout};
Expand Down