CSR-1862 | Avoid clearing valid and active promo on page load
This commit is contained in:
parent
6c3a3ddf85
commit
352f81c426
1 changed files with 19 additions and 10 deletions
|
|
@ -149,6 +149,14 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
||||||
} else if (!excludeFromInactivePromoErrorCodes.includes(validatePromoResponse.errorCode)) {
|
} else if (!excludeFromInactivePromoErrorCodes.includes(validatePromoResponse.errorCode)) {
|
||||||
// Save any valid query string promoCode (not applied) to inactivePromos
|
// Save any valid query string promoCode (not applied) to inactivePromos
|
||||||
// in order to not lose the query string promoCode if back button is pressed
|
// in order to not lose the query string promoCode if back button is pressed
|
||||||
|
const activePromoCodes = store.getters.order.lineItems.promos.map((promoObject) => {
|
||||||
|
return promoObject.promoCode.toUpperCase();
|
||||||
|
});
|
||||||
|
const isErrorPromoAlreadyOnOrder = activePromoCodes.includes(
|
||||||
|
validatePromoResponse.promoCode.toUpperCase()
|
||||||
|
);
|
||||||
|
// Do not save an inactivePromo if it is already active on the order
|
||||||
|
if (!isErrorPromoAlreadyOnOrder) {
|
||||||
const inactivePromoCodes = store.getters.payment.inactivePromos ?? [];
|
const inactivePromoCodes = store.getters.payment.inactivePromos ?? [];
|
||||||
if (!inactivePromoCodes.includes(newPromo)) {
|
if (!inactivePromoCodes.includes(newPromo)) {
|
||||||
inactivePromoCodes.push(newPromo);
|
inactivePromoCodes.push(newPromo);
|
||||||
|
|
@ -162,6 +170,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return { validatePromoResponse, revalidatePromoResponse };
|
return { validatePromoResponse, revalidatePromoResponse };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue