From 77c007c4447ff5a05db4614605269ea9cb1db4cb Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 3 Apr 2025 13:19:44 -0400 Subject: [PATCH] CASH-462 | Rename and restructure submittedOrder Rename to submittedState Add an applicationUser attribute --- src/constants/store-actions.js | 6 +-- .../add-to-calendar/add-to-calendar.vue | 2 +- src/layouts/confirmation/confirmation.vue | 7 +--- .../payment-pia-return/payment-pia-return.vue | 2 +- src/layouts/payment/payment.vue | 2 +- src/layouts/vehicle/vehicle.vue | 2 +- src/mixins/analytics-mixin.js | 2 +- src/mixins/analytics-mixin.spec.js | 2 +- src/mixins/base-mixin.js | 12 +++++- src/router/index.js | 4 +- src/store/index.js | 39 ++++++++++++------- 11 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index e7cb38953..1e8945c49 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -109,9 +109,9 @@ const storeActions = { SAVE_IS_RECAL_ACK_OPT_IN: "saveIsRecalAckOptIn", SAVE_IS_MSR_FEE_APPLICABLE: "saveIsMSRFeeApplicable", - CREATE_SUBMITTED_ORDER: "createSubmittedOrder", - RESET_SUBMITTED_ORDER: "resetSubmittedOrder", - ADD_DONATION_TO_SUBMITTED_ORDER: "addDonationToSubmittedOrder", + CREATE_SUBMITTED_STATE: "createSubmittedState", + RESET_SUBMITTED_STATE: "resetSubmittedState", + ADD_DONATION_TO_SUBMITTED_STATE: "addDonationToSubmittedState", RESET_EXTERNAL_PARAMETER_STATE: "resetExternalParameterState", UPDATE_EXTERNAL_PARAMETER_MMS: "updateExternalParameterMMS", diff --git a/src/layouts/confirmation/add-to-calendar/add-to-calendar.vue b/src/layouts/confirmation/add-to-calendar/add-to-calendar.vue index 1fef02247..c986e0366 100644 --- a/src/layouts/confirmation/add-to-calendar/add-to-calendar.vue +++ b/src/layouts/confirmation/add-to-calendar/add-to-calendar.vue @@ -115,7 +115,7 @@ export default { }, ServiceType() { const isRepair = this.getSubmittedOrder()?.damage.isRepair; - const funnelHasRecalibrationPart = store.getters.isRecalibrationOnSubmittedOrder; + const funnelHasRecalibrationPart = store.getters.isRecalibrationOnSubmittedState; if (!isRepair) { if (funnelHasRecalibrationPart) { return serviceType.REPLACEMENT_AND_RECALIBRATION; diff --git a/src/layouts/confirmation/confirmation.vue b/src/layouts/confirmation/confirmation.vue index 8e49f298d..7e9cfe71e 100644 --- a/src/layouts/confirmation/confirmation.vue +++ b/src/layouts/confirmation/confirmation.vue @@ -164,7 +164,7 @@ export default { } // Create order - await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_ORDER); // This nulls the Store order + await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_STATE); // This nulls the Store order // Call APIs const submittedOrder = baseMixin.methods.getSubmittedOrder(); @@ -255,11 +255,8 @@ export default { }, ShowCart() { if (this.isPia && this.submittedOrder?.settledTenderAmount == 0) { - // settleTenderAmount always shows 0 via localhost or dev. - // Temporarily set return true to see cart in localhost or dev environment return false; } - return true; }, ScheduleConfirmationText() { @@ -537,7 +534,7 @@ export default { this.showDonationSuccess = true; this.showDonationError = false; await baseMixin.methods.dispatchStoreAction( - storeActions.ADD_DONATION_TO_SUBMITTED_ORDER, + storeActions.ADD_DONATION_TO_SUBMITTED_STATE, parseInt(this.donationAmount), false ); diff --git a/src/layouts/payment-pia-return/payment-pia-return.vue b/src/layouts/payment-pia-return/payment-pia-return.vue index b9f19f64a..f0b4433ea 100644 --- a/src/layouts/payment-pia-return/payment-pia-return.vue +++ b/src/layouts/payment-pia-return/payment-pia-return.vue @@ -192,7 +192,7 @@ export default { } this.$refs.loadingModal.isModalVisible = false; - await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_ORDER); + await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_STATE); this.$router.navigateWithoutSaving(this.navigationScenarios.PIA_SUCCESS, this.$route); }, }, diff --git a/src/layouts/payment/payment.vue b/src/layouts/payment/payment.vue index abf06927b..3c87f85f2 100644 --- a/src/layouts/payment/payment.vue +++ b/src/layouts/payment/payment.vue @@ -683,7 +683,7 @@ export default { submitAfterSave: true, }); - await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_ORDER); + await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_STATE); window.location = applicationConfig.CONFIRMATION_URL; } catch (error) { console.log("error: response from submit work order(payment pg):" + error.message); diff --git a/src/layouts/vehicle/vehicle.vue b/src/layouts/vehicle/vehicle.vue index 12e7268fa..5f769b9b7 100644 --- a/src/layouts/vehicle/vehicle.vue +++ b/src/layouts/vehicle/vehicle.vue @@ -448,7 +448,7 @@ export default { this.displayNoServiceAlert = false; }, async forwardButtonAction() { - await this.dispatchStoreAction(storeActions.RESET_SUBMITTED_ORDER); + await this.dispatchStoreAction(storeActions.RESET_SUBMITTED_STATE); this.dispatchStoreAction( storeActions.SAVE_VEHICLE, { diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index e59ec5039..d6e608d4b 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -337,7 +337,7 @@ export default { // Recalibration if (hasSubmittedOrder) { - payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnSubmittedOrder; + payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnSubmittedState; } else { payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnOrder; } diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index a4b4672bb..711702c4a 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -425,7 +425,7 @@ describe("analyticsMixin.js", () => { workOrderId: "222222222222", }; store.getters.isRecalibrationOnOrder = true; - store.getters.isRecalibrationOnSubmittedOrder = false; + store.getters.isRecalibrationOnSubmittedState = false; }); test("Pushes to data layer if nominal", () => { diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index 151d17dd9..1c33640f8 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -198,10 +198,18 @@ export default { } }, getSubmittedOrder() { - return JSON.parse(window.sessionStorage.getItem("submittedOrder")); + return JSON.parse(window.sessionStorage.getItem("submittedState"))?.order; }, hasSubmittedOrder() { - return window.sessionStorage.getItem("submittedOrder") !== null; + const submittedState = window.sessionStorage.getItem("submittedState"); + return submittedState !== null && submittedState.order !== null; + }, + getSubmittedApplicationUser() { + return JSON.parse(window.sessionStorage.getItem("submittedState"))?.applicationUser; + }, + hasSubmittedApplicationUser() { + const submittedState = window.sessionStorage.getItem("submittedState"); + return submittedState !== null && submittedState.applicationUser !== null; }, }, computed: { diff --git a/src/router/index.js b/src/router/index.js index 345790734..e2263b32d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -93,10 +93,10 @@ const routes = [ log(" --to.query.fmgPage ", to.query?.fmgPage); // Intercept all navigation if a submitted order exists in storage - if (window.sessionStorage.getItem("submittedOrder") !== null) { + if (window.sessionStorage.getItem("submittedState") !== null) { if (to.query.fmgPage !== funnelStartPageName) { to.query.fmgPage = fmgPageValues.CONFIRMATION; - log(" --has submittedOrder go to confirmation"); + log(" --has submittedState go to confirmation"); } } // On entering the funnel "fresh", read cookie information, decide what to do next. diff --git a/src/store/index.js b/src/store/index.js index 032660c6f..cdd81d164 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -822,8 +822,8 @@ export const getters = { }, coverageIsVerified: (state) => { let order; - if (window.sessionStorage.getItem("submittedOrder") !== null) { - order = JSON.parse(window.sessionStorage.getItem("submittedOrder")); + if (window.sessionStorage.getItem("submittedState") !== null) { + order = JSON.parse(window.sessionStorage.getItem("submittedState")).order; } else { order = state.order; } @@ -850,10 +850,10 @@ export const getters = { isRecalibrationOnOrder: (state) => { return getHasRecalibrationPart(state); }, - isRecalibrationOnSubmittedOrder: (state) => { - if (window.sessionStorage.getItem("submittedOrder") !== null) { + isRecalibrationOnSubmittedState: (state) => { + if (window.sessionStorage.getItem("submittedState") !== null) { return getHasRecalibrationPart({ - order: JSON.parse(window.sessionStorage.getItem("submittedOrder")), + order: JSON.parse(window.sessionStorage.getItem("submittedState")).order, }); } @@ -861,8 +861,8 @@ export const getters = { }, shouldHideRecalibration: (state) => { var order; - if (window.sessionStorage.getItem("submittedOrder") !== null) { - order = JSON.parse(window.sessionStorage.getItem("submittedOrder")); + if (window.sessionStorage.getItem("submittedState") !== null) { + order = JSON.parse(window.sessionStorage.getItem("submittedState")).order; } else { order = state.order; } @@ -3257,19 +3257,22 @@ export const actions = { return false; }, - createSubmittedOrder(context) { - if (window.sessionStorage.getItem("submittedOrder") !== null) { + createSubmittedState(context) { + if (window.sessionStorage.getItem("submittedState") !== null) { return; } // create a submitted order object from vuex. - const submittedOrder = context.state.order; + const submittedState = { + order: context.state.order, + applicationUser: context.state.applicationUser + }; const experiments = context.state.applicationUser.experiments; const affiliateCookies = context.state.applicationUser.affiliateCookies; // set to local storage - window.sessionStorage.setItem("submittedOrder", JSON.stringify(submittedOrder)); + window.sessionStorage.setItem("submittedState", JSON.stringify(submittedState)); window.sessionStorage.setItem("createNewSessionForHeritage", true); // clear vuex @@ -3288,10 +3291,11 @@ export const actions = { context.commit(storeMutations.UPDATE_AFFILIATE_COOKIES, affiliateCookies); }, - addDonationToSubmittedOrder(context, donationAmount) { + addDonationToSubmittedState(context, donationAmount) { console.log("running addDonationToSubmittedOrder()... donationAmount: ", donationAmount); const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder()); + const submittedApplicationUser = deepClone(baseMixin.methods.getSubmittedApplicationUser()); if (donationAmount > 0) { console.log( @@ -3320,13 +3324,18 @@ export const actions = { }); submittedOrder.lineItems.supportingItems = nonDonationItems; } + + const submittedState = { + order: submittedOrder, + applicationUser: submittedApplicationUser + } // set to local storage - window.sessionStorage.setItem("submittedOrder", JSON.stringify(submittedOrder)); + window.sessionStorage.setItem("submittedState", JSON.stringify(submittedState)); }, - resetSubmittedOrder(context) { + resetSubmittedState(context) { // clear from local storage - window.sessionStorage.removeItem("submittedOrder"); + window.sessionStorage.removeItem("submittedState"); }, resetExternalParameterState(context) { if (context.getters.isExternalParameter) {