diff --git a/src/router/index.js b/src/router/index.js index 2cb551af..93fb1a71 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,6 +2,8 @@ import { createWebHistory, createRouter } from "vue-router"; import { lazyLoadComponent } from "./dynamic-routing/component-loader"; import { endpoints } from "../constants/mock-endpoints"; import globalMethods from "@/global-methods"; +import {issPageValues} from '@/router/router-constants/issPage-values'; + const routes = [ { @@ -9,10 +11,19 @@ const routes = [ name: 'root', async beforeEnter(to, from, next) { try { - if (router.hasRoute(to.query.issPage)) { - return next({ name: to.query.issPage, query: to.query, params: to.params }); + + let issPage = to.query.issPage; + + if(issPage === undefined) + { + issPage = issPageValues.WELCOME_PAGE; } - const routeData = await GetRouteInfoFromPageName(to.query.issPage); + + if (router.hasRoute(issPage)) { + return next({ name: issPage, query: to.query, params: to.params }); + } + + const routeData = await GetRouteInfoFromPageName(issPage); if(routeData[0].name.toLowerCase() === "error") { @@ -26,7 +37,7 @@ const routes = [ component: routeData[0].component, }); - // Assign current query string parameters, as well as our fmgPage one. + // Assign current query string parameters, as well as our issPage one. next({ name: routeData[0].name, query: Object.assign(to.query, { issPage: routeData[0].name }), @@ -89,7 +100,7 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara router.push({ name: "root", query: Object.assign(optionalQuery, { - fmgPage: destinationIssPageValue, + issPage: destinationIssPageValue, }), params: optionalParams }); @@ -114,7 +125,7 @@ function getNavigationMap(scenario, currentRoute) { } function GoToStartOn404(next) { - const errorPageName = "error-404" + const errorPageName = issPageValues.ERROR_404; router.addRoute({ path: "/", name: errorPageName, diff --git a/src/router/router-constants/issPage-values.js b/src/router/router-constants/issPage-values.js index 1c1bbde6..8bdc935c 100644 --- a/src/router/router-constants/issPage-values.js +++ b/src/router/router-constants/issPage-values.js @@ -1,5 +1,7 @@ -const issPageValues = { +export const issPageValues = { + ERROR_404: "error-404", + WELCOME_PAGE: "welcome-page", + VEHICLE_MAKE: "vehicle-make", VEHICLE_YEAR: "vehicle-year", }; - - export { issPageValues }; \ No newline at end of file + \ No newline at end of file diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 5e11bbc6..edce4e74 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -5,14 +5,23 @@ import { navigationScenarios } from "@/router/router-constants/navigation-scenar const routingTable = function(store) { return [ { - issPageValue: issPageValues.VEHICLE_YEAR, + issPageValue: issPageValues.VEHICLE_MAKE, maps: [ { - scenario: navigationScenarios.SELECTED_YEAR, - issPageValue: "PageOne" + scenario: navigationScenarios.CLICKED_BACK, + issPageValue: "WELCOME_PAGE" }, ], }, + { + issPageVlue: issPageValues.WELCOME_PAGE, + maps: [ + { + scenario: navigationScenarios.CLICKED_FORWARD, + issPageValue: "VEHICLE_MAKE" + } + ] + } ]; };