CASH-462 | Rename and restructure submittedOrder

Rename to submittedState
Add an applicationUser attribute
This commit is contained in:
Scott Kiener 2025-04-03 13:19:44 -04:00
parent d38cc5f2e6
commit 77c007c444
11 changed files with 47 additions and 33 deletions

View file

@ -109,9 +109,9 @@ const storeActions = {
SAVE_IS_RECAL_ACK_OPT_IN: "saveIsRecalAckOptIn", SAVE_IS_RECAL_ACK_OPT_IN: "saveIsRecalAckOptIn",
SAVE_IS_MSR_FEE_APPLICABLE: "saveIsMSRFeeApplicable", SAVE_IS_MSR_FEE_APPLICABLE: "saveIsMSRFeeApplicable",
CREATE_SUBMITTED_ORDER: "createSubmittedOrder", CREATE_SUBMITTED_STATE: "createSubmittedState",
RESET_SUBMITTED_ORDER: "resetSubmittedOrder", RESET_SUBMITTED_STATE: "resetSubmittedState",
ADD_DONATION_TO_SUBMITTED_ORDER: "addDonationToSubmittedOrder", ADD_DONATION_TO_SUBMITTED_STATE: "addDonationToSubmittedState",
RESET_EXTERNAL_PARAMETER_STATE: "resetExternalParameterState", RESET_EXTERNAL_PARAMETER_STATE: "resetExternalParameterState",
UPDATE_EXTERNAL_PARAMETER_MMS: "updateExternalParameterMMS", UPDATE_EXTERNAL_PARAMETER_MMS: "updateExternalParameterMMS",

View file

@ -115,7 +115,7 @@ export default {
}, },
ServiceType() { ServiceType() {
const isRepair = this.getSubmittedOrder()?.damage.isRepair; const isRepair = this.getSubmittedOrder()?.damage.isRepair;
const funnelHasRecalibrationPart = store.getters.isRecalibrationOnSubmittedOrder; const funnelHasRecalibrationPart = store.getters.isRecalibrationOnSubmittedState;
if (!isRepair) { if (!isRepair) {
if (funnelHasRecalibrationPart) { if (funnelHasRecalibrationPart) {
return serviceType.REPLACEMENT_AND_RECALIBRATION; return serviceType.REPLACEMENT_AND_RECALIBRATION;

View file

@ -164,7 +164,7 @@ export default {
} }
// Create order // 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 // Call APIs
const submittedOrder = baseMixin.methods.getSubmittedOrder(); const submittedOrder = baseMixin.methods.getSubmittedOrder();
@ -255,11 +255,8 @@ export default {
}, },
ShowCart() { ShowCart() {
if (this.isPia && this.submittedOrder?.settledTenderAmount == 0) { 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 false;
} }
return true; return true;
}, },
ScheduleConfirmationText() { ScheduleConfirmationText() {
@ -537,7 +534,7 @@ export default {
this.showDonationSuccess = true; this.showDonationSuccess = true;
this.showDonationError = false; this.showDonationError = false;
await baseMixin.methods.dispatchStoreAction( await baseMixin.methods.dispatchStoreAction(
storeActions.ADD_DONATION_TO_SUBMITTED_ORDER, storeActions.ADD_DONATION_TO_SUBMITTED_STATE,
parseInt(this.donationAmount), parseInt(this.donationAmount),
false false
); );

View file

@ -192,7 +192,7 @@ export default {
} }
this.$refs.loadingModal.isModalVisible = false; 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); this.$router.navigateWithoutSaving(this.navigationScenarios.PIA_SUCCESS, this.$route);
}, },
}, },

View file

@ -683,7 +683,7 @@ export default {
submitAfterSave: true, submitAfterSave: true,
}); });
await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_ORDER); await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_STATE);
window.location = applicationConfig.CONFIRMATION_URL; window.location = applicationConfig.CONFIRMATION_URL;
} catch (error) { } catch (error) {
console.log("error: response from submit work order(payment pg):" + error.message); console.log("error: response from submit work order(payment pg):" + error.message);

View file

@ -448,7 +448,7 @@ export default {
this.displayNoServiceAlert = false; this.displayNoServiceAlert = false;
}, },
async forwardButtonAction() { async forwardButtonAction() {
await this.dispatchStoreAction(storeActions.RESET_SUBMITTED_ORDER); await this.dispatchStoreAction(storeActions.RESET_SUBMITTED_STATE);
this.dispatchStoreAction( this.dispatchStoreAction(
storeActions.SAVE_VEHICLE, storeActions.SAVE_VEHICLE,
{ {

View file

@ -337,7 +337,7 @@ export default {
// Recalibration // Recalibration
if (hasSubmittedOrder) { if (hasSubmittedOrder) {
payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnSubmittedOrder; payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnSubmittedState;
} else { } else {
payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnOrder; payload.isRecalibrationOnOrder = store.getters.isRecalibrationOnOrder;
} }

View file

@ -425,7 +425,7 @@ describe("analyticsMixin.js", () => {
workOrderId: "222222222222", workOrderId: "222222222222",
}; };
store.getters.isRecalibrationOnOrder = true; store.getters.isRecalibrationOnOrder = true;
store.getters.isRecalibrationOnSubmittedOrder = false; store.getters.isRecalibrationOnSubmittedState = false;
}); });
test("Pushes to data layer if nominal", () => { test("Pushes to data layer if nominal", () => {

View file

@ -198,10 +198,18 @@ export default {
} }
}, },
getSubmittedOrder() { getSubmittedOrder() {
return JSON.parse(window.sessionStorage.getItem("submittedOrder")); return JSON.parse(window.sessionStorage.getItem("submittedState"))?.order;
}, },
hasSubmittedOrder() { 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: { computed: {

View file

@ -93,10 +93,10 @@ const routes = [
log(" --to.query.fmgPage ", to.query?.fmgPage); log(" --to.query.fmgPage ", to.query?.fmgPage);
// Intercept all navigation if a submitted order exists in storage // 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) { if (to.query.fmgPage !== funnelStartPageName) {
to.query.fmgPage = fmgPageValues.CONFIRMATION; 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. // On entering the funnel "fresh", read cookie information, decide what to do next.

View file

@ -822,8 +822,8 @@ export const getters = {
}, },
coverageIsVerified: (state) => { coverageIsVerified: (state) => {
let order; let order;
if (window.sessionStorage.getItem("submittedOrder") !== null) { if (window.sessionStorage.getItem("submittedState") !== null) {
order = JSON.parse(window.sessionStorage.getItem("submittedOrder")); order = JSON.parse(window.sessionStorage.getItem("submittedState")).order;
} else { } else {
order = state.order; order = state.order;
} }
@ -850,10 +850,10 @@ export const getters = {
isRecalibrationOnOrder: (state) => { isRecalibrationOnOrder: (state) => {
return getHasRecalibrationPart(state); return getHasRecalibrationPart(state);
}, },
isRecalibrationOnSubmittedOrder: (state) => { isRecalibrationOnSubmittedState: (state) => {
if (window.sessionStorage.getItem("submittedOrder") !== null) { if (window.sessionStorage.getItem("submittedState") !== null) {
return getHasRecalibrationPart({ 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) => { shouldHideRecalibration: (state) => {
var order; var order;
if (window.sessionStorage.getItem("submittedOrder") !== null) { if (window.sessionStorage.getItem("submittedState") !== null) {
order = JSON.parse(window.sessionStorage.getItem("submittedOrder")); order = JSON.parse(window.sessionStorage.getItem("submittedState")).order;
} else { } else {
order = state.order; order = state.order;
} }
@ -3257,19 +3257,22 @@ export const actions = {
return false; return false;
}, },
createSubmittedOrder(context) { createSubmittedState(context) {
if (window.sessionStorage.getItem("submittedOrder") !== null) { if (window.sessionStorage.getItem("submittedState") !== null) {
return; return;
} }
// create a submitted order object from vuex. // 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 experiments = context.state.applicationUser.experiments;
const affiliateCookies = context.state.applicationUser.affiliateCookies; const affiliateCookies = context.state.applicationUser.affiliateCookies;
// set to local storage // set to local storage
window.sessionStorage.setItem("submittedOrder", JSON.stringify(submittedOrder)); window.sessionStorage.setItem("submittedState", JSON.stringify(submittedState));
window.sessionStorage.setItem("createNewSessionForHeritage", true); window.sessionStorage.setItem("createNewSessionForHeritage", true);
// clear vuex // clear vuex
@ -3288,10 +3291,11 @@ export const actions = {
context.commit(storeMutations.UPDATE_AFFILIATE_COOKIES, affiliateCookies); context.commit(storeMutations.UPDATE_AFFILIATE_COOKIES, affiliateCookies);
}, },
addDonationToSubmittedOrder(context, donationAmount) { addDonationToSubmittedState(context, donationAmount) {
console.log("running addDonationToSubmittedOrder()... donationAmount: ", donationAmount); console.log("running addDonationToSubmittedOrder()... donationAmount: ", donationAmount);
const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder()); const submittedOrder = deepClone(baseMixin.methods.getSubmittedOrder());
const submittedApplicationUser = deepClone(baseMixin.methods.getSubmittedApplicationUser());
if (donationAmount > 0) { if (donationAmount > 0) {
console.log( console.log(
@ -3320,13 +3324,18 @@ export const actions = {
}); });
submittedOrder.lineItems.supportingItems = nonDonationItems; submittedOrder.lineItems.supportingItems = nonDonationItems;
} }
const submittedState = {
order: submittedOrder,
applicationUser: submittedApplicationUser
}
// set to local storage // 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 // clear from local storage
window.sessionStorage.removeItem("submittedOrder"); window.sessionStorage.removeItem("submittedState");
}, },
resetExternalParameterState(context) { resetExternalParameterState(context) {
if (context.getters.isExternalParameter) { if (context.getters.isExternalParameter) {