From a45702a560801afc3cf83593e8a6d2c1ef68f0a0 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Mon, 4 Mar 2024 07:58:22 -0500 Subject: [PATCH] CSR-1971 | sync local and store promos --- src/fmg-components/cart/cart.vue | 4 ++-- src/layouts/quote/quote.vue | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index 0ab26e9e5..8a7714410 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -236,7 +236,7 @@ export default { this.lineItems[category] = this.lineItems[category].filter( (lineItemsToKeep) => lineItemsToKeep.cartItemType != cartItemType ); - + this.$emit("update:modelValue", this.lineItems); }, getPromoCodeList() { @@ -845,7 +845,7 @@ export default { this.lineItems = deepClone(newValue); }, deep: true, - } + }, }, components: { textBlock, diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 94cafb0a4..27093cfdf 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -29,7 +29,7 @@ :availableLineItems="availableLineItems" :isInsuranceSelected="isInsuranceSelected" @vapsItemsSelected="vapsItemsSelectedAction" - :activePromos="allActivePromos" + :activePromos="lineItems.promos" v-on="{ 'buttonEvent.openModal': openModalAction }" validationRules="option-required" isRequired /> @@ -151,7 +151,6 @@ export default { const resultMap = await settleAllPromises(promiseResultMap); const lineItems = deepClone(store.getters.order.lineItems); - lineItems.promos = lineItems.promos ?? []; lineItems.vaps = lineItems.vaps ?? []; const nullSafeGlassParts = lineItems.glassParts ?? []; const availableLineItems = [ @@ -190,6 +189,8 @@ export default { pricingResults, "quote" ); + // Sync local promos with any new promos added by validate/revalidate + lineItems.promos = store.getters.lineItems.promos ?? []; // End of promo logic // Call the "next" function to complete the transition to this page. @@ -229,9 +230,6 @@ export default { }; }, computed: { - allActivePromos() { - return this.lineItems.promos ?? []; - }, lineItemsCloneForWatcher() { return Object.assign({}, this.lineItems); }, @@ -319,7 +317,7 @@ export default { this.dispatchStoreAction( storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS, { - activePromos: this.lineItems.promos + activePromos: this.lineItems.promos, }, false );