From 59dfb0c4fb5067006f08e7b0813d4ed0c21b74ad Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Tue, 28 Nov 2023 15:30:35 -0500 Subject: [PATCH] CSR-1841 | Ensure saving promos cleans up inactivePromos --- src/store/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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;