add function and linting
This commit is contained in:
parent
b1b852520c
commit
03fd9ff0f5
1 changed files with 22 additions and 9 deletions
|
|
@ -13,9 +13,9 @@ import { experimentTriggers } from '@/constants/experiments';
|
|||
import applicationConfig from '@/constants/application-config';
|
||||
|
||||
import analyticsMixin from '@/mixins/analytics-mixin';
|
||||
import navigationScenarios from './router-constants/navigation-scenarios';
|
||||
import { saveSession } from "@/helpers/order-helper.js";
|
||||
import { saveSession } from '@/helpers/order-helper.js';
|
||||
import routerParams from '@/router/router-constants/router-params';
|
||||
import navigationScenarios from './router-constants/navigation-scenarios';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
|
|
@ -123,20 +123,21 @@ router.afterEach(async (to, from) => {
|
|||
const store = useMainStore();
|
||||
// Update lastPageVisited in the store
|
||||
store.updateLastPageVisited(to.name);
|
||||
|
||||
if (from.redirectedFrom === undefined){
|
||||
|
||||
if (from.redirectedFrom === undefined) {
|
||||
store.clearSaveSessionPromise();
|
||||
}
|
||||
|
||||
const saveSessionSynchronous = !!from.params[routerParams.SAVE_SESSION_SYNCHRONOUS];
|
||||
await saveSession({shouldAwaitSaveSessionQueue: saveSessionSynchronous}).catch((error) => {
|
||||
await saveSession({ shouldAwaitSaveSessionQueue: saveSessionSynchronous }).catch((error) => {
|
||||
if (from.name === issPageValues.WELCOME_PAGE) {
|
||||
router.navigate(
|
||||
navigationScenarios.SAVE_SESSION_FAILED,
|
||||
{query: {issPage: issPageValues.WELCOME_PAGE}});
|
||||
{ query: { issPage: issPageValues.WELCOME_PAGE } }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
|
||||
// Push page view to GA
|
||||
analyticsMixin.methods.pushPageViewToGA();
|
||||
|
|
@ -146,6 +147,16 @@ router.afterEach(async (to, from) => {
|
|||
}
|
||||
});
|
||||
|
||||
router.navigateWithoutSaving = (
|
||||
scenario,
|
||||
currentRoute,
|
||||
optionalQuery = {},
|
||||
optionalParams = {},
|
||||
optionalPageData = {}
|
||||
) => {
|
||||
navigate(scenario, currentRoute, false, optionalQuery, optionalParams, optionalPageData);
|
||||
};
|
||||
|
||||
// Get route information by page name.
|
||||
// This will reach out to the Cms and there is a 1:1 relationship between page names and route names.
|
||||
async function GetRouteInfoFromPageName(pageName) {
|
||||
|
|
@ -174,8 +185,10 @@ router.overrideNavigation = (
|
|||
isSavingNavigation,
|
||||
optionalQuery = {},
|
||||
optionalParams = {},
|
||||
optionalPageData) => {
|
||||
navigate(scenario,
|
||||
optionalPageData
|
||||
) => {
|
||||
navigate(
|
||||
scenario,
|
||||
currentRoute,
|
||||
isSavingNavigation,
|
||||
optionalQuery,
|
||||
|
|
|
|||
Loading…
Reference in a new issue