Welcome Page Placeholder
+ + + + + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index c76f41bf..c3cddaf1 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,5 +1,7 @@ -import { storeActions } from "@/constants/store-actions"; import { createWebHistory, createRouter } from "vue-router"; +import { lazyLoadComponent } from "./dynamic-routing/component-loader"; +import { endpoints } from "../constants/mock-endpoints"; +import globalMethods from "@/global-methods"; const routes = [ { @@ -12,6 +14,11 @@ const routes = [ } const routeData = await GetRouteInfoFromPageName(to.query.issPage); + if(routeData[0].name.toLowerCase() === "error") + { + throw("Page not found!") + } + // Add our dynamic route. router.addRoute({ path: routeData[0].path, // Always the same path, because we control it with query strings. @@ -19,7 +26,6 @@ const routes = [ component: routeData[0].component, }); - // Assign current query string parameters, as well as our fmgPage one. next({ name: routeData[0].name, @@ -29,7 +35,7 @@ const routes = [ } catch (error) { console.log(error); - await GoToStartOn404(next); + GoToStartOn404(next); } } }]; @@ -42,9 +48,15 @@ const router = createRouter({ // 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) { + + //move to store actions later? + /* const response = await store.dispatch(storeActions.GET_ROUTE_INFO_ACTION, { pageName: pageName, }); + */ + + const response = await globalMethods.mockCallHttpClient("GET", endpoints.GetRouteInfo.url + "?route=" + pageName) const jsonFromResponse = JSON.parse(response.data.Result); let routeData = []; @@ -100,4 +112,19 @@ function getNavigationMap(scenario, currentRoute) { return matchedQueryValue[0]; } +function GoToStartOn404(next) { + const errorPageName = "error-404" + router.addRoute({ + path: "/", + name: errorPageName, + component: lazyLoadComponent(errorPageName), + }); + + next({ + name: errorPageName, + query: {issPage: errorPageName }, + }); + +}; + export default router; \ No newline at end of file