diff --git a/src/constants/events.js b/src/constants/events.js index f416eeff1..892c62b0c 100644 --- a/src/constants/events.js +++ b/src/constants/events.js @@ -4,6 +4,7 @@ const globalEvents = { }, SubCategories: { PAGE_NOT_FOUND: "PAGE_NOT_FOUND", + UNKNOWN_ERROR: "UNKNOWN_ERROR", }, }; diff --git a/src/fmg-components/funnel-header/funnel-header.vue b/src/fmg-components/funnel-header/funnel-header.vue index 4a0936fd5..24e12d549 100644 --- a/src/fmg-components/funnel-header/funnel-header.vue +++ b/src/fmg-components/funnel-header/funnel-header.vue @@ -72,6 +72,17 @@ export default { alertEvent.displayAlert = true; this.globalAlertMessages.push(alertEvent); } + + //Uknown alerts most likely were added by a failed api call in global-methods + const unknownAlertEvent = eventBus.readAndPopEventFromBus( + globalEvents.Categories.GLOBAL_ALERT, + globalEvents.SubCategories.UNKNOWN_ERROR + ); + + if (unknownAlertEvent !== undefined) { + unknownAlertEvent.displayAlert = true; + this.globalAlertMessages.push(unknownAlertEvent); + } }, }; diff --git a/src/global-methods.js b/src/global-methods.js index 301fded68..c5e6102dc 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -61,6 +61,7 @@ export default { ); } + router.navigateError(); return reject(error.response); } ); diff --git a/src/router/index.js b/src/router/index.js index 04c934769..8c5c83b4c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -239,6 +239,10 @@ router.navigateToExternalUrl = (url, optionalQuery = {}) => { navigateToUrl(url, optionalQuery); }; +router.navigateError = () => { + DisplayPageError(); +}; + //Use this navigation when you need to call next() explicitly. beforeRouteEnter is a good example. router.overrideNavigation = ( scenario, @@ -403,6 +407,23 @@ function GoToFunnelStartOn404(next) { }); } +async function DisplayPageError() { + // Put item on the bus + eventBus.addEventToBus( + globalEvents.Categories.GLOBAL_ALERT, + globalEvents.SubCategories.UNKNOWN_ERROR, + { + isDismissible: true, + messageCopy: "", + messageHeadline: "We're sorry, something went wrong.", + type: globalEventTypes.Danger, + } + ); + + baseMixin.methods.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); + location.reload(); +} + function isExistingFmgPageName(pageName) { const names = Object.values(fmgPageValues);