nl_tokens: TODO : Update this for performance if needed . As - is it will cause frequent recalculations .
pl_tokens: function productVariationUpdated ( state , action ) { const { data : productVariation , productId } = <mask> ; const productVariations = state . productVariations || [ ] ; const index = findIndex ( productVariations , { id : productVariation . id } ) ; const newProductVariation = { ... productVariation , productId } ; const newProductVariations = [ ... productVariations ] ; if ( - 1 < index ) { newProductVariations [ index ] = newProductVariation ; } else { newProductVariations . push ( newProductVariation ) ; } const promotions = calculatePromotions ( state . coupons , state . products , newProductVariations ) ; return { ... state , productVariations : newProductVariations , promotions } ; }