Updated router to handle root navigation and began to reference iss-page-values

This commit is contained in:
Jason Wheeler 2022-09-19 15:52:44 -04:00
parent 34ebb9f921
commit 243cc0406f
3 changed files with 34 additions and 12 deletions

View file

@ -3,16 +3,27 @@ import { lazyLoadComponent } from "./dynamic-routing/component-loader";
import { endpoints } from "../constants/mock-endpoints"; import { endpoints } from "../constants/mock-endpoints";
import globalMethods from "@/global-methods"; import globalMethods from "@/global-methods";
const issPageValues = require("./router-constants/issPage-values");
const routes = [ const routes = [
{ {
path: '/', path: '/',
name: 'root', name: 'root',
async beforeEnter(to, from, next) { async beforeEnter(to, from, next) {
try { 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.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") if(routeData[0].name.toLowerCase() === "error")
{ {
@ -26,7 +37,7 @@ const routes = [
component: routeData[0].component, 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({ next({
name: routeData[0].name, name: routeData[0].name,
query: Object.assign(to.query, { issPage: routeData[0].name }), query: Object.assign(to.query, { issPage: routeData[0].name }),
@ -88,7 +99,7 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
router.push({ router.push({
name: "root", name: "root",
query: Object.assign(optionalQuery, { query: Object.assign(optionalQuery, {
fmgPage: destinationIssPageValue, issPage: destinationIssPageValue,
}), }),
params: optionalParams params: optionalParams
}); });
@ -113,7 +124,7 @@ function getNavigationMap(scenario, currentRoute) {
} }
function GoToStartOn404(next) { function GoToStartOn404(next) {
const errorPageName = "error-404" const errorPageName = issPageValues.issPageValues.ERROR_404;
router.addRoute({ router.addRoute({
path: "/", path: "/",
name: errorPageName, name: errorPageName,

View file

@ -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", VEHICLE_YEAR: "vehicle-year",
}; };
export { issPageValues };

View file

@ -5,14 +5,23 @@ import { navigationScenarios } from "@/router/router-constants/navigation-scenar
const routingTable = function(store) { const routingTable = function(store) {
return [ return [
{ {
issPageValue: issPageValues.VEHICLE_YEAR, issPageValue: issPageValues.VEHICLE_MAKE,
maps: [ maps: [
{ {
scenario: navigationScenarios.SELECTED_YEAR, scenario: navigationScenarios.CLICKED_BACK,
issPageValue: "PageOne" issPageValue: "WELCOME_PAGE"
}, },
], ],
}, },
{
issPageVlue: issPageValues.WELCOME_PAGE,
maps: [
{
scenario: navigationScenarios.CLICKED_FORWARD,
issPageValue: "VEHICLE_MAKE"
}
]
}
]; ];
}; };