CSR-746 & CSR-889 | State management for quote page selections
This commit is contained in:
parent
6e55fcd1e7
commit
5f7154db25
6 changed files with 103 additions and 13 deletions
|
|
@ -41,7 +41,6 @@ const storeActions = {
|
|||
RESET_SAVE_SESSION_PROMISE: "resetSaveSessionPromise",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||
RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies",
|
||||
RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies",
|
||||
|
|
@ -65,6 +64,7 @@ const storeActions = {
|
|||
"resetMoldingAndCapabilityQuestionAnswersIfNeeded",
|
||||
SAVE_MOLDING_QUESTION_ANSWERS: "saveMoldingQuestionAnswers",
|
||||
SAVE_CAPABILITY_QUESTION_ANSWERS: "saveCapabilityQuestionAnswers",
|
||||
SAVE_QUOTE_PAGE_SELECTIONS: "saveQuotePageSelections",
|
||||
};
|
||||
|
||||
export { storeActions };
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ const storeMutations = {
|
|||
UPDATE_MOLDING_QUESTION_ANSWERS: "updateMoldingQuestionAnswers",
|
||||
UPDATE_CAPABILITY_QUESTION_ANSWERS: "updateCapabilityQuestionAnswers",
|
||||
UPDATE_GLASS_PARTS: "updateGlassParts",
|
||||
UPDATE_OTHER_PARTS: "updateOtherParts",
|
||||
UPDATE_VAPS: "updateVaps",
|
||||
UPDATE_SUPPORTING_ITEMS: "updateSupportingItems",
|
||||
|
||||
UPDATE_REGISTRATION_LICENSE_PLATE: "updateRegistrationLicensePlate",
|
||||
UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress",
|
||||
|
|
@ -42,6 +43,7 @@ const storeMutations = {
|
|||
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
|
||||
UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber",
|
||||
UPDATE_EON: "updateEON",
|
||||
UPDATE_IS_INSURANCE: "updateIsInsurance",
|
||||
UPDATE_SAVED_SESSION_ID: "updateSavedSessionId",
|
||||
UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId",
|
||||
|
||||
|
|
@ -54,6 +56,8 @@ const storeMutations = {
|
|||
RESET_DAMAGE_STATE: "resetDamageState",
|
||||
RESET_REGISTRATION_STATE: "resetRegistrationState",
|
||||
RESET_GLASS_PARTS_STATE: "resetGlassPartsState",
|
||||
RESET_SUPPORTING_ITEMS_STATE: "resetSupportingItemsState",
|
||||
RESET_VAPS_STATE: "resetVapsState",
|
||||
RESET_STATE: "resetState",
|
||||
RESET_SAVE_SESSION_PROMISE: "resetSaveSessionPromise",
|
||||
|
||||
|
|
|
|||
|
|
@ -109,16 +109,17 @@ export default {
|
|||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(cmsContent);
|
||||
vm.supportingItems = resultMap.supportingItems;
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue();
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pricingRequestResult: null,
|
||||
isInsuranceSelected: null,
|
||||
selectedPackage: null,
|
||||
availableLineItems: null,
|
||||
supportingItems: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -139,6 +140,19 @@ export default {
|
|||
backButtonAction() {
|
||||
vehicleQuestionsMixin.methods.navigateBack(this);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
await this.dispatchStoreAction(
|
||||
this.storeActions.SAVE_QUOTE_PAGE_SELECTIONS,
|
||||
{
|
||||
isInsuranceSelected: this.isInsuranceSelected,
|
||||
vapsItemsToAdd: this.selectedPackage,
|
||||
supportingItemsToAdd: this.supportingItems,
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
//return this.navigateForward();
|
||||
},
|
||||
},
|
||||
components: {
|
||||
funnelHeader,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ export default {
|
|||
return this.modelValue;
|
||||
},
|
||||
set: function (newValue) {
|
||||
this.$emit("update:modelValue", newValue);
|
||||
const VapsProductsInSelectedPackage =
|
||||
this.getVapsLineItemsForSelectedPackage(newValue);
|
||||
this.$emit("update:modelValue", VapsProductsInSelectedPackage);
|
||||
},
|
||||
},
|
||||
nullSafeAvailableLineItems() {
|
||||
|
|
@ -206,6 +208,38 @@ export default {
|
|||
});
|
||||
return vapsPrice;
|
||||
},
|
||||
getVapsLineItemsForSelectedPackage(packageName) {
|
||||
const vapsLineItemsForSelectedPackage = [];
|
||||
if (packageName === packageNames.TIER_TWO) {
|
||||
if (this.frontWipersApplicableForTierTwo) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.FRONT_WIPER)
|
||||
);
|
||||
}
|
||||
if (this.rearWiperApplicableForTierTwo) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.REAR_WIPER)
|
||||
);
|
||||
}
|
||||
} else if (packageName === packageNames.TIER_THREE) {
|
||||
if (this.frontWipersApplicableForTierThree) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.FRONT_WIPER)
|
||||
);
|
||||
}
|
||||
if (this.rearWiperApplicableForTierThree) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.REAR_WIPER)
|
||||
);
|
||||
}
|
||||
if (this.rainDefenseApplicableForTierThree) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.RAIN_DEFENSE)
|
||||
);
|
||||
}
|
||||
}
|
||||
return vapsLineItemsForSelectedPackage;
|
||||
},
|
||||
getCustomValueFromString(str) {
|
||||
switch (str) {
|
||||
case "isRecalibrationOnOrder":
|
||||
|
|
@ -224,10 +258,14 @@ export default {
|
|||
return null;
|
||||
}
|
||||
},
|
||||
lineItemsContainsPartType(partType) {
|
||||
getLineItemsContainingPartType(partType) {
|
||||
const partTypeMatches = this.nullSafeAvailableLineItems.filter(
|
||||
(lineItem) => lineItem.partType.toUpperCase() === partType
|
||||
);
|
||||
return partTypeMatches;
|
||||
},
|
||||
lineItemsContainsPartType(partType) {
|
||||
const partTypeMatches = this.getLineItemsContainingPartType(partType);
|
||||
return !!partTypeMatches.length;
|
||||
},
|
||||
glassToReplaceContainsGlassLocation(glassLocation) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange">
|
||||
<baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange" v-model="selectedValue">
|
||||
<div class="package-label" for="testradio">
|
||||
<div class="package-specs">
|
||||
<p :class="[this.buttonLabelSubCopy ? 'mb-2' : 'm-0']">
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ const getDefaultState = () => {
|
|||
},
|
||||
lineItems: {
|
||||
glassParts: null,
|
||||
supportingItems: null,
|
||||
vaps: null,
|
||||
serverData: null,
|
||||
},
|
||||
payment: {
|
||||
isInsurance: null,
|
||||
|
|
@ -143,8 +146,11 @@ export const mutations = {
|
|||
updateGlassParts(state, partsData) {
|
||||
state.order.lineItems.glassParts = partsData;
|
||||
},
|
||||
updateOtherParts(state, partsData) {
|
||||
state.order.lineItems.otherParts = partsData;
|
||||
updateVaps(state, partsData) {
|
||||
state.order.lineItems.vaps = partsData;
|
||||
},
|
||||
updateSupportingItems(state, partsData) {
|
||||
state.order.lineItems.supportingItems = partsData;
|
||||
},
|
||||
updatePageData(state, pageData) {
|
||||
state.applicationUser.pageData[pageData.page] = pageData.data;
|
||||
|
|
@ -296,6 +302,12 @@ export const mutations = {
|
|||
state.applicationUser.pageData[fmgPageValues.MOLDING_QUESTIONS] = null;
|
||||
state.applicationUser.pageData[fmgPageValues.CAPABILITY_QUESTIONS] = null;
|
||||
},
|
||||
resetSupportingItemsState(state) {
|
||||
state.order.lineItems.supportingItems = null;
|
||||
},
|
||||
resetVapsState(state) {
|
||||
state.order.lineItems.vaps = null;
|
||||
},
|
||||
resetState(state) {
|
||||
Object.assign(state, getDefaultState());
|
||||
},
|
||||
|
|
@ -343,6 +355,9 @@ export const mutations = {
|
|||
state.order.damage.numberOfChips = sessionInformation.order.damage.numberOfChips;
|
||||
|
||||
state.order.lineItems.glassParts = sessionInformation.order.lineItems.glassParts;
|
||||
state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems;
|
||||
state.order.lineItems.vapsItems = sessionInformation.order.lineItems.vapsItems;
|
||||
state.order.lineItems.serverData = sessionInformation.order.lineItems.serverData;
|
||||
state.order.accountNumber = sessionInformation.order.accountNumber;
|
||||
state.order.providerNumber = sessionInformation.order.providerNumber;
|
||||
(state.order.serviceLocation.address =
|
||||
|
|
@ -572,21 +587,22 @@ export const actions = {
|
|||
},
|
||||
|
||||
// Dependency Actions
|
||||
resetVehicleAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_VEHICLE_STATE);
|
||||
context.commit(storeMutations.RESET_DAMAGE_STATE);
|
||||
context.commit(storeMutations.RESET_REGISTRATION_STATE);
|
||||
},
|
||||
resetDamageAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_DAMAGE_STATE);
|
||||
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
},
|
||||
resetRegistrationAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_REGISTRATION_STATE);
|
||||
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
},
|
||||
resetPartsAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
},
|
||||
resetState(context) {
|
||||
context.commit(storeMutations.RESET_STATE);
|
||||
|
|
@ -994,6 +1010,9 @@ export const actions = {
|
|||
},
|
||||
lineItems: {
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vapsItems: lineItems.vapsItems,
|
||||
serverData: lineItems.serverData,
|
||||
},
|
||||
payment: {
|
||||
InsuranceCoverage: {
|
||||
|
|
@ -1245,6 +1264,7 @@ export const actions = {
|
|||
|
||||
if (havePartQuestionAnswersChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||
|
|
@ -1290,6 +1310,7 @@ export const actions = {
|
|||
|
||||
if (haveSelectedVehiclePartsChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||
|
|
@ -1319,6 +1340,7 @@ export const actions = {
|
|||
|
||||
if (haveMoldingQuestionAnswersChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||
page: fmgPageValues.CAPABILITY_QUESTIONS,
|
||||
|
|
@ -1346,6 +1368,7 @@ export const actions = {
|
|||
|
||||
if (haveCapabilityQuestionAnswersChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
}
|
||||
|
||||
//Save new values
|
||||
|
|
@ -1354,6 +1377,17 @@ export const actions = {
|
|||
capabilityQuestionAnswers
|
||||
);
|
||||
},
|
||||
// Quote Page
|
||||
saveQuotePageSelections(
|
||||
context,
|
||||
{ isInsuranceSelected, vapsItemsToAdd, supportingItemsToAdd }
|
||||
) {
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
context.commit(storeMutations.UPDATE_IS_INSURANCE, isInsuranceSelected);
|
||||
context.commit(storeMutations.UPDATE_VAPS, vapsItemsToAdd);
|
||||
context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItemsToAdd);
|
||||
},
|
||||
// Price order actions
|
||||
// PLACEHOLDER, WILL CHANGE WHEN PRICING END POINT IS IMPLEMENTED
|
||||
priceOrderItems(context, availableLineItems) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue