diff --git a/src/layouts/bailout-success/bailout-success.vue b/src/layouts/bailout-success/bailout-success.vue index 97f186ca6..5def1ae22 100644 --- a/src/layouts/bailout-success/bailout-success.vue +++ b/src/layouts/bailout-success/bailout-success.vue @@ -13,7 +13,8 @@ id="btn-vehicle-not-listed" :isPrimary="true" :buttonText="ReturnToHomeButtonText" - class="mb-3" + loaderColor="white" + class="w-100 mb-3" @click-event="forwardButtonAction" /> @@ -27,6 +28,8 @@ import funnelHeader from "@/fmg-components/funnel-header/funnel-header"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import buttonMain from "@/ux-components/button-main/button-main"; import store from "@/store"; +import baseMixin from "@/mixins/base-mixin.js"; +import { storeActions } from "@/constants/store-actions"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; @@ -39,6 +42,9 @@ export default { }, async beforeRouteEnter(to, from, next) { + // Clear order + await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_STATE); + // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.name); @@ -67,10 +73,11 @@ export default { }, arePagePrerequisitesValid() { return ( - store.getters.order.customer.firstName && - store.getters.order.customer.lastName && - store.getters.order.customer.emailAddress && - store.getters.order.customer.phoneNumber + (store.getters.order.customer.firstName && + store.getters.order.customer.lastName && + store.getters.order.customer.emailAddress && + store.getters.order.customer.phoneNumber) || + baseMixin.methods.hasSubmittedOrder() ); }, }, diff --git a/src/layouts/bailout/bailout.spec.js b/src/layouts/bailout/bailout.spec.js index 905f9e5a0..f71899e49 100644 --- a/src/layouts/bailout/bailout.spec.js +++ b/src/layouts/bailout/bailout.spec.js @@ -36,9 +36,21 @@ describe("bailout.vue", () => { expect(wrapper.findComponent({ name: "navbar" }).exists()).toBe(true); }); + test("arePagePrerequisitesValid should be false ", async () => { + //Arrange + const { wrapper } = setupMocks(); + + //Act + let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + + //Assert + expect(arePagePrerequisitesValid).toBe(false); + }); + test("arePagePrerequisitesValid should be true ", async () => { //Arrange const { wrapper } = setupMocks(); + wrapper.vm.getBailoutCodeFromStore = jest.fn().mockReturnValue("BAILOUT_CODE"); //Act let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); diff --git a/src/layouts/bailout/bailout.vue b/src/layouts/bailout/bailout.vue index ae5600e08..7c5edf07c 100644 --- a/src/layouts/bailout/bailout.vue +++ b/src/layouts/bailout/bailout.vue @@ -43,6 +43,8 @@ validationRules="phone-number-required" /> to.name === name) && !isVirtualRoute(to.name)) { - router.push({ - name: routeData.CONFIRMATION.name, - }); - return false; + if (isBailout) { + router.push({ + name: routeData.BAILOUT_SUCCESS.name, + }); + return false; + } else { + router.push({ + name: routeData.CONFIRMATION.name, + }); + return false; + } } } @@ -142,3 +155,8 @@ export async function beforeEach(to, from) { return; } } + +function getIsBailout(submittedState) { + const submittedStateObj = JSON.parse(submittedState); + return !!submittedStateObj?.applicationUser?.bailoutCode; +} diff --git a/src/router/methods/navigate.js b/src/router/methods/navigate.js index 1cdd87aac..63e20d96c 100644 --- a/src/router/methods/navigate.js +++ b/src/router/methods/navigate.js @@ -1,7 +1,8 @@ -import { saveSession } from "@/helpers/heritage-integration/order-helper"; +import { saveSession, submitBailout } from "@/helpers/heritage-integration/order-helper"; import { buildManualUrl } from "@/router/methods/helpers/build-manual-url"; import { getDestination } from "@/router/methods/helpers/get-destination"; import { savePageData } from "@/router/methods/helpers/save-page-data"; +import { navigationScenarios } from "@/router/constants/navigation-scenarios"; import router from "@/router"; import store from "@/store"; @@ -39,7 +40,14 @@ async function navigate(scenario, currentPageName, withSaving = false, forceTopL store.getters?.applicationUser?.savedSessionId || store.getters?.order?.customer?.emailAddress ) { - await saveSession({ pageNameToLog: nextPage.name }); + if ( + scenario.toUpperCase() === navigationScenarios.CLICKED_FORWARD && + currentPageName.toUpperCase() === navigationScenarios.BAILOUT + ) { + await submitBailout({ pageNameToLog: nextPage.name }); + } else { + await saveSession({ pageNameToLog: nextPage.name }); + } } } diff --git a/src/store/index.js b/src/store/index.js index 5b7449c4b..9fe220fcc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1949,21 +1949,21 @@ export const actions = { pageNameToLog: pageNameToLog, }) .catch((error) => { - if (error.status == 500) { - return { PartsNotFound: true }; - } + // if (error.status == 500) { + // return { PartsNotFound: true }; + // } }); // Triggers bailout - if (response.PartsNotFound) { - return response; - } + // if (response.PartsNotFound) { + // return response; + // } // Check if we only have MISC parts to trigger bailout - const miscPartsResponse = checkIfMiscParts(response.data.partsOrQuestions); - if (miscPartsResponse.PartsNotFound) { - return miscPartsResponse; - } + // const miscPartsResponse = checkIfMiscParts(response.data.partsOrQuestions); + // if (miscPartsResponse.PartsNotFound) { + // return miscPartsResponse; + // } // Flatten location and name properties response.data.partsOrQuestions = convertGlassPieceNamingFromApi(