Revert "Merge pull request #1636 from Safelite/reverse-pr-1622"

This reverts commit 438e63e780, reversing
changes made to 811a317369.
This commit is contained in:
Adam Caouette 2023-12-12 14:09:47 -05:00
parent fa82201f21
commit 614f50a533
2 changed files with 30 additions and 0 deletions

View file

@ -112,6 +112,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
pageNameToLog,
false
);
const revalidationErrorPromoCodes = revalidatePromoResponse.errors.map((x) => x.promoCode);
baseMixin.methods.dispatchStoreAction(
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
@ -122,6 +123,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
false
);
}
if (hasNewPromo) {
validatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
@ -132,6 +134,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
pageNameToLog,
false
);
if (validatePromoResponse.errorCode == null) {
// Save promo to store
const activePromos = store.getters.order.lineItems.promos ?? [];

View file

@ -112,6 +112,7 @@ import { defineRule } from "vee-validate";
import { required } from "@/helpers/validation-rules";
import { errorMessages } from "@/constants/error-messages";
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
import { partTypeStrings } from "@/constants/part-type-strings";
import { mapTaxedLineItemsToStoreFormat } from "../../store";
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.inactivePromos = revalidatePromoResponse.errors.map((x) =>
getPromoCodeWithoutBundleIdentifier(x.promoCode)