diff --git a/src/constants/submit-type.js b/src/constants/submit-type.js new file mode 100644 index 00000000..8b0ac575 --- /dev/null +++ b/src/constants/submit-type.js @@ -0,0 +1,6 @@ +const submitType = Object.freeze({ + REFERRAL: 0, + TPA: 1 +}); + +export default submitType; diff --git a/src/iss-components/vehicle-banner/vehicle-banner.vue b/src/iss-components/vehicle-banner/vehicle-banner.vue index fd4010f9..bb9fef13 100644 --- a/src/iss-components/vehicle-banner/vehicle-banner.vue +++ b/src/iss-components/vehicle-banner/vehicle-banner.vue @@ -54,7 +54,10 @@ export default { }, methods: { getUnmatchedVehicleIcon() { - switch (this.mainStore.order.vehicle.category) { + const category = this.mainStore.hasSubmittedOrder() + ? this.mainStore.submittedOrder.vehicle.category + : this.mainStore.order.vehicle.category; + switch (category) { case this.vehicleCategories.CAR: return this.carUnmatchedVehicleIcon; case this.vehicleCategories.SUV: diff --git a/src/layouts/order-confirmation/order-confirmation.vue b/src/layouts/order-confirmation/order-confirmation.vue index 1d858c9a..8a870b9a 100644 --- a/src/layouts/order-confirmation/order-confirmation.vue +++ b/src/layouts/order-confirmation/order-confirmation.vue @@ -105,6 +105,7 @@ import { import { toTitleCase } from '@/helpers/text-helper.js'; import { AppointmentTypeStrings } from '@/constants/schedule-constants'; import applicationConfig from '@/constants/application-config'; +import submitType from '@/constants/submit-type'; export default { name: 'order-confirmation', @@ -119,7 +120,7 @@ export default { }, mixins: [BaseFormMixin], async beforeRouteEnter(to, from, next) { - useMainStore().createSubmittedOrder(); + useMainStore().createSubmittedOrder(submitType.REFERRAL); // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); diff --git a/src/layouts/payment-return/payment-return.vue b/src/layouts/payment-return/payment-return.vue index 4a29f2ea..5ddf8234 100644 --- a/src/layouts/payment-return/payment-return.vue +++ b/src/layouts/payment-return/payment-return.vue @@ -15,6 +15,7 @@ import getQueryStringParameter from '@/helpers/querystring-helper.js'; import { paymentMethods } from '@/constants/payment-method-constants.js'; import { submitWorkOrder } from '@/helpers/order-helper.js'; import showIssLoadingModal from '@/helpers/loading-modal-helper'; +import submitType from '@/constants/submit-type'; export default { name: 'payment-return', @@ -133,7 +134,7 @@ export default { } showIssLoadingModal(false); - useMainStore().createSubmittedOrder(); + useMainStore().createSubmittedOrder(submitType.REFERRAL); this.$router.navigate( this.navigationScenarios.PAY_IN_ADVANCE_SUCCESS, this.$route diff --git a/src/layouts/tpa-confirmation/tpa-confirmation.spec.js b/src/layouts/tpa-confirmation/tpa-confirmation.spec.js index b719facc..3ac32ed9 100644 --- a/src/layouts/tpa-confirmation/tpa-confirmation.spec.js +++ b/src/layouts/tpa-confirmation/tpa-confirmation.spec.js @@ -3,7 +3,7 @@ import tpaConfirmation from '@/layouts/tpa-confirmation/tpa-confirmation.vue'; // Supporting Files import { getEnumName, getMountOptions } from '@/helpers/unit-test-helper.js'; -import { useMainStore } from '@/store/index.js'; +import { getDefaultState, useMainStore } from '@/store/index.js'; import settleAllPromises from '@/helpers/layout-helper.js'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { mount } from '@vue/test-utils'; @@ -53,7 +53,14 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu main: mainInitialState } }); - useMainStore(testingPinia); + const store = useMainStore(testingPinia); + store.submittedOrder = { + ...JSON.parse(JSON.stringify(store.order)), + isVerified: store.isVerified, + isUnverified: store.isUnverified + }; + store.order = getDefaultState().order; + store.hasSubmittedOrder = jest.fn().mockReturnValue(true); methodToRun(); mountOptions.global.plugins = [testingPinia]; diff --git a/src/layouts/tpa-confirmation/tpa-confirmation.vue b/src/layouts/tpa-confirmation/tpa-confirmation.vue index 0d6ed119..b36a2282 100644 --- a/src/layouts/tpa-confirmation/tpa-confirmation.vue +++ b/src/layouts/tpa-confirmation/tpa-confirmation.vue @@ -133,7 +133,8 @@ export default { }, setup() { const mainStore = useMainStore(); - return { mainStore }; + const { submittedOrder } = mainStore; + return { mainStore, submittedOrder }; }, computed: { tpaConfirmationHeaderText() { @@ -193,16 +194,16 @@ export default { : VERIFYING_COVERAGE; }, currentDeductible() { - return useMainStore().order.currentDeductible; + return this.submittedOrder.currentDeductible; }, preferredShopName() { - return toTitleCase(useMainStore().order.serviceLocation.provider.companyName); + return toTitleCase(this.submittedOrder.serviceLocation.provider.companyName); }, preferredShopPhoneNumber() { - return this.toDisplayPhoneNumber(useMainStore().order.serviceLocation.provider.phoneNumber); + return this.toDisplayPhoneNumber(this.submittedOrder.serviceLocation.provider.phoneNumber); }, isVerified() { - return useMainStore().isVerified; + return this.submittedOrder.isVerified; }, carrierName() { return this.mainStore.issConfig.clientName; @@ -211,7 +212,7 @@ export default { return this.mainStore.issConfig.successReturnURL; }, carrierPhoneNumber() { - return this.toDisplayPhoneNumber(useMainStore().order.carrierPhoneNumber); + return this.toDisplayPhoneNumber(this.submittedOrder.carrierPhoneNumber); } }, mounted() { diff --git a/src/layouts/tpa-submit/tpa-submit.vue b/src/layouts/tpa-submit/tpa-submit.vue index 381e63ca..0c1593a5 100644 --- a/src/layouts/tpa-submit/tpa-submit.vue +++ b/src/layouts/tpa-submit/tpa-submit.vue @@ -137,6 +137,7 @@ import { import damageLocationsSelected from '@/constants/damage-locations-selected.js'; import { submitWorkOrder } from '@/helpers/order-helper.js'; import bailoutMessage from '@/constants/bailoutMessage'; +import submitType from '@/constants/submit-type'; const VERIFYING_COVERAGE = 'Verifying coverage'; @@ -357,6 +358,7 @@ export default { pageNameToLog: 'tpa-submit', submitAfterSave: true }).then(() => { + useMainStore().createSubmittedOrder(submitType.TPA); this.navigate(this.navigationScenarios.CLICKED_FORWARD); }).catch((submitError) => { useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data)); diff --git a/src/router/index.js b/src/router/index.js index 388a978c..ee51a177 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -19,6 +19,7 @@ import routerParams from '@/router/router-constants/router-params'; import canBailoutNavigateBack from '@/helpers/bailout-helper'; import bailoutMessage from '@/constants/bailoutMessage'; import navigationScenarios from './router-constants/navigation-scenarios'; +import submitType from '@/constants/submit-type'; const routes = [ { @@ -49,7 +50,7 @@ const routes = [ // Intercept all navigation if a submitted order exists in storage if (useMainStore().hasSubmittedOrder()) { if (to.query.issPage !== issPageValues.ENTRY_PAGE) { - return await GoToOrderConfirmationPage(next); + return await GoToConfirmationPage(next, useMainStore().submittedOrder); } } @@ -365,8 +366,8 @@ async function GoToAccessIsDenied(next) { }); } -async function GoToOrderConfirmationPage(next) { - const nextPageName = issPageValues.ORDER_CONFIRMATION; +async function GoToConfirmationPage(next, order) { + const nextPageName = getConfirmationPageFromOrder(order); router.addRoute({ path: '/', name: nextPageName, @@ -379,6 +380,17 @@ async function GoToOrderConfirmationPage(next) { }); } +function getConfirmationPageFromOrder(order) { + switch (order.submitType) { + case submitType.REFERRAL: + return issPageValues.ORDER_CONFIRMATION; + case submitType.TPA: + return issPageValues.TPA_CONFIRMATION; + default: + return issPageValues.ORDER_CONFIRMATION; + } +} + async function GoToStartOn404(next, msgCopy = null, msgHeadline = null) { const errorPageName = issPageValues.WELCOME_PAGE; router.addRoute({ diff --git a/src/store/index.js b/src/store/index.js index 1570bf3b..5bc5ae7b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2566,7 +2566,7 @@ export const useMainStore = defineStore({ return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null; }, - createSubmittedOrder() { + createSubmittedOrder(submitType) { if (this.hasSubmittedOrder()) { return; } @@ -2575,6 +2575,8 @@ export const useMainStore = defineStore({ const { issConfig } = this; submittedOrder.isUnverified = this.isUnverified; + submittedOrder.isVerified = this.isVerified; + submittedOrder.submitType = submitType; // set to local storage window.sessionStorage.setItem(webStorageConstants.SUBMITTED_ORDER, JSON.stringify(submittedOrder));