diff --git a/src/store/index.js b/src/store/index.js index efaf5b428..1d350a143 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2130,6 +2130,17 @@ export const actions = { }, // Manage promo saving to ensure a promoCode never ends up in both active and inactive saveActiveAndOrInactivePromos(context, { activePromos = null, inactivePromos = null }) { + if (inactivePromos) { + // Clean up inactivePromos + // Remove bundle identifier + inactivePromos = inactivePromos.map((promoCode) => + getPromoCodeWithoutBundleIdentifier(promoCode) + ); + // Remove duplicates + inactivePromos = inactivePromos.filter( + (promoCode, index) => inactivePromos.indexOf(promoCode) === index + ); + } activePromos = activePromos?.slice(0); inactivePromos = inactivePromos?.slice(0); let activePromosToSave;