CASH-462 | Rename and restructure submittedOrder
Rename to submittedState Add an applicationUser attribute
This commit is contained in:
parent
d38cc5f2e6
commit
77c007c444
11 changed files with 47 additions and 33 deletions
|
|
@ -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",
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue