CSR-1841 | Ensure saving promos cleans up inactivePromos
This commit is contained in:
parent
9c39a50af9
commit
59dfb0c4fb
1 changed files with 11 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue