Merge pull request #1786 from Safelite/feature/CSR-1971
CSR-1971 | Re-work quote page promos
This commit is contained in:
commit
b842e5804f
2 changed files with 17 additions and 20 deletions
|
|
@ -99,7 +99,7 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
modelValue: Object,
|
modelValue: Object,
|
||||||
modalWidgetName: String,
|
modalWidgetName: String,
|
||||||
availableVaps: Object,
|
addableVaps: Object,
|
||||||
pageName: String,
|
pageName: String,
|
||||||
taxPromos: {
|
taxPromos: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
@ -186,14 +186,14 @@ export default {
|
||||||
resetModalButtonStyle() {
|
resetModalButtonStyle() {
|
||||||
this.modal.resetButtonStyle();
|
this.modal.resetButtonStyle();
|
||||||
},
|
},
|
||||||
async getPromoCodeData(promoCode, lineItems, availableVaps, pageNameToLog = null) {
|
async getPromoCodeData(promoCode, lineItems, addableVaps, pageNameToLog = null) {
|
||||||
const pageName = pageNameToLog ?? this.$options?.name;
|
const pageName = pageNameToLog ?? this.$options?.name;
|
||||||
const promoValidationResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
const promoValidationResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
promoCode: promoCode,
|
promoCode: promoCode,
|
||||||
lineItemsToUse: lineItems,
|
lineItemsToUse: lineItems,
|
||||||
addableVaps: availableVaps,
|
addableVaps: addableVaps,
|
||||||
},
|
},
|
||||||
pageName,
|
pageName,
|
||||||
false
|
false
|
||||||
|
|
@ -258,7 +258,7 @@ export default {
|
||||||
const promoCodeData = await this.getPromoCodeData(
|
const promoCodeData = await this.getPromoCodeData(
|
||||||
this.promoCode,
|
this.promoCode,
|
||||||
this.lineItems,
|
this.lineItems,
|
||||||
this.availableVaps,
|
this.addableVaps,
|
||||||
this.pageName
|
this.pageName
|
||||||
);
|
);
|
||||||
if (promoCodeData.isValid) {
|
if (promoCodeData.isValid) {
|
||||||
|
|
@ -292,7 +292,7 @@ export default {
|
||||||
);
|
);
|
||||||
const taxedVaps = mapTaxedLineItemsToStoreFormat(
|
const taxedVaps = mapTaxedLineItemsToStoreFormat(
|
||||||
taxedLineItems,
|
taxedLineItems,
|
||||||
this.availableVaps
|
this.addableVaps
|
||||||
);
|
);
|
||||||
|
|
||||||
const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
:availableLineItems="availableLineItems"
|
:availableLineItems="availableLineItems"
|
||||||
:isInsuranceSelected="isInsuranceSelected"
|
:isInsuranceSelected="isInsuranceSelected"
|
||||||
@vapsItemsSelected="vapsItemsSelectedAction"
|
@vapsItemsSelected="vapsItemsSelectedAction"
|
||||||
:activePromos="allActivePromos"
|
:activePromos="lineItems.promos"
|
||||||
v-on="{ 'buttonEvent.openModal': openModalAction }"
|
v-on="{ 'buttonEvent.openModal': openModalAction }"
|
||||||
validationRules="option-required"
|
validationRules="option-required"
|
||||||
isRequired />
|
isRequired />
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<promoModalQuestion
|
<promoModalQuestion
|
||||||
class="small mt-4"
|
class="small mt-4"
|
||||||
v-model="lineItems"
|
v-model="lineItems"
|
||||||
:availableVaps="availableVaps"
|
:addableVaps="addableVaps"
|
||||||
pageName="quote"
|
pageName="quote"
|
||||||
:taxPromos="false"
|
:taxPromos="false"
|
||||||
modalWidgetName="PromoModalWidget" />
|
modalWidgetName="PromoModalWidget" />
|
||||||
|
|
@ -86,6 +86,7 @@ import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import vehicleQuestionsMixin from "../../mixins/vehicle-questions-mixin";
|
import vehicleQuestionsMixin from "../../mixins/vehicle-questions-mixin";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { required } from "@/helpers/validation-rules";
|
import { required } from "@/helpers/validation-rules";
|
||||||
|
|
@ -149,7 +150,8 @@ export default {
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
const lineItems = store.getters.order.lineItems;
|
const lineItems = deepClone(store.getters.order.lineItems);
|
||||||
|
lineItems.vaps = lineItems.vaps ?? [];
|
||||||
const nullSafeGlassParts = lineItems.glassParts ?? [];
|
const nullSafeGlassParts = lineItems.glassParts ?? [];
|
||||||
const availableLineItems = [
|
const availableLineItems = [
|
||||||
resultMap.rainDefense,
|
resultMap.rainDefense,
|
||||||
|
|
@ -172,30 +174,29 @@ export default {
|
||||||
resultMap.supportingItems,
|
resultMap.supportingItems,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
lineItems.supportingItems = resultMap.supportingItems;
|
||||||
|
const addableVaps = [...resultMap.wipers, resultMap.rainDefense];
|
||||||
|
|
||||||
// Promo logic
|
// Promo logic
|
||||||
// Populate the previous state of promos for toast message usage in "next()"
|
// Populate the previous state of promos for toast message usage in "next()"
|
||||||
const availableVaps = [...resultMap.wipers, resultMap.rainDefense];
|
|
||||||
const oldActivePromos = store.getters.lineItems.promos?.slice(0);
|
const oldActivePromos = store.getters.lineItems.promos?.slice(0);
|
||||||
const oldInactivePromos = store.getters.order.payment.inactivePromos?.slice(0);
|
const oldInactivePromos = store.getters.order.payment.inactivePromos?.slice(0);
|
||||||
|
|
||||||
const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO);
|
const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO);
|
||||||
|
|
||||||
const { validatePromoResponse, revalidatePromoResponse } =
|
const { validatePromoResponse, revalidatePromoResponse } =
|
||||||
await revalidatePromosAndValidateQueryStringPromo(
|
await revalidatePromosAndValidateQueryStringPromo(
|
||||||
promoCodeFromQueryString,
|
promoCodeFromQueryString,
|
||||||
pricingResults,
|
pricingResults,
|
||||||
"quote"
|
"quote"
|
||||||
);
|
);
|
||||||
lineItems.glassParts = nullSafeGlassParts;
|
// Sync local promos with any new promos added by validate/revalidate
|
||||||
lineItems.promos = lineItems.promos ?? [];
|
lineItems.promos = store.getters.lineItems.promos ?? [];
|
||||||
lineItems.vaps = lineItems.vaps ?? [];
|
|
||||||
// End of promo logic
|
// End of promo logic
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.availableVaps = availableVaps;
|
vm.addableVaps = addableVaps;
|
||||||
vm.lineItems = lineItems;
|
vm.lineItems = lineItems;
|
||||||
vm.availableLineItems = pricingResults;
|
vm.availableLineItems = pricingResults;
|
||||||
vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue(vm.availableLineItems);
|
vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue(vm.availableLineItems);
|
||||||
|
|
@ -225,13 +226,10 @@ export default {
|
||||||
isInsuranceSelected: null,
|
isInsuranceSelected: null,
|
||||||
availableLineItems: null,
|
availableLineItems: null,
|
||||||
lineItems: [],
|
lineItems: [],
|
||||||
availableVaps: [],
|
addableVaps: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
allActivePromos() {
|
|
||||||
return this.lineItems.promos ?? [];
|
|
||||||
},
|
|
||||||
lineItemsCloneForWatcher() {
|
lineItemsCloneForWatcher() {
|
||||||
return Object.assign({}, this.lineItems);
|
return Object.assign({}, this.lineItems);
|
||||||
},
|
},
|
||||||
|
|
@ -304,7 +302,7 @@ export default {
|
||||||
this.$store.getters.order.payment.parentAccountNumber !=
|
this.$store.getters.order.payment.parentAccountNumber !=
|
||||||
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER
|
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER
|
||||||
) {
|
) {
|
||||||
this.supportingItems = this.filterOutFees(this.supportingItems);
|
this.lineItems.supportingItems = this.filterOutFees(this.lineItems.supportingItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.lineItems.glassParts?.length > 0) {
|
if (this.lineItems.glassParts?.length > 0) {
|
||||||
|
|
@ -320,7 +318,6 @@ export default {
|
||||||
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
||||||
{
|
{
|
||||||
activePromos: this.lineItems.promos,
|
activePromos: this.lineItems.promos,
|
||||||
inactivePromos: this.$store.getters.order.payment.inactivePromos,
|
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue