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 globalMethods from "@/global-methods";
const issPageValues = require("./router-constants/issPage-values");
const routes = [
{
path: '/',
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.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 }),
@ -88,7 +99,7 @@ async function navigate(scenario, currentRoute, optionalQuery = {}, optionalPara
router.push({
name: "root",
query: Object.assign(optionalQuery, {
fmgPage: destinationIssPageValue,
issPage: destinationIssPageValue,
}),
params: optionalParams
});
@ -113,7 +124,7 @@ function getNavigationMap(scenario, currentRoute) {
}
function GoToStartOn404(next) {
const errorPageName = "error-404"
const errorPageName = issPageValues.issPageValues.ERROR_404;
router.addRoute({
path: "/",
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",
};
export { issPageValues };

View file

@ -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"
}
]
}
];
};