Merge pull request #1638 from Safelite/revert-reverse-pr-1622
Revert "Merge pull request #1636 from Safelite/reverse-pr-1622"
This commit is contained in:
commit
624d270a0c
2 changed files with 30 additions and 0 deletions
|
|
@ -112,6 +112,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
||||||
pageNameToLog,
|
pageNameToLog,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
const revalidationErrorPromoCodes = revalidatePromoResponse.errors.map((x) => x.promoCode);
|
const revalidationErrorPromoCodes = revalidatePromoResponse.errors.map((x) => x.promoCode);
|
||||||
baseMixin.methods.dispatchStoreAction(
|
baseMixin.methods.dispatchStoreAction(
|
||||||
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
||||||
|
|
@ -122,6 +123,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNewPromo) {
|
if (hasNewPromo) {
|
||||||
validatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
validatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||||
|
|
@ -132,6 +134,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
||||||
pageNameToLog,
|
pageNameToLog,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
if (validatePromoResponse.errorCode == null) {
|
if (validatePromoResponse.errorCode == null) {
|
||||||
// Save promo to store
|
// Save promo to store
|
||||||
const activePromos = store.getters.order.lineItems.promos ?? [];
|
const activePromos = store.getters.order.lineItems.promos ?? [];
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ import { defineRule } from "vee-validate";
|
||||||
import { required } from "@/helpers/validation-rules";
|
import { required } from "@/helpers/validation-rules";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||||
|
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
||||||
|
|
||||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||||
|
|
@ -380,6 +381,32 @@ export default {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Because we don't yet have a robust solution for part interchange ...
|
||||||
|
// if there are front wiper line items in the revalidate response, we need to delete any existing front wiper line items from the store
|
||||||
|
// and replace them with those that come back from revalidation.
|
||||||
|
const revalidateResponseHasFrontWiperLineItems =
|
||||||
|
revalidatePromoResponse.promoLineItems.find(
|
||||||
|
(lineItem) => lineItem.partType == partTypeStrings.FRONT_WIPER
|
||||||
|
)?.length > 0;
|
||||||
|
|
||||||
|
if (revalidateResponseHasFrontWiperLineItems) {
|
||||||
|
const frontWiperLineItemsInStore = this.lineItems.vaps.find(
|
||||||
|
(lineItem) => lineItem.partType == partTypeStrings.FRONT_WIPER
|
||||||
|
);
|
||||||
|
if (frontWiperLineItemsInStore.length > 0) {
|
||||||
|
this.lineItems.vaps = this.lineItems.vaps.find(
|
||||||
|
(lineItem) => lineItem.partType != partTypeStrings.FRONT_WIPER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||||
|
revalidatePromoResponse.promoLineItems,
|
||||||
|
this.availableVaps,
|
||||||
|
this.lineItems
|
||||||
|
);
|
||||||
|
this.lineItems.vaps.push(...vapsToAddToCart);
|
||||||
|
|
||||||
this.lineItems.promos = revalidatePromoResponse.promoLineItems;
|
this.lineItems.promos = revalidatePromoResponse.promoLineItems;
|
||||||
this.inactivePromos = revalidatePromoResponse.errors.map((x) =>
|
this.inactivePromos = revalidatePromoResponse.errors.map((x) =>
|
||||||
getPromoCodeWithoutBundleIdentifier(x.promoCode)
|
getPromoCodeWithoutBundleIdentifier(x.promoCode)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue