From bb221a19588d38180d974cfd5e2d1acf98cc6aec Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 6 Nov 2024 08:59:16 -0500 Subject: [PATCH] CSR-2323 save vaps to store when promo added CSR-2323 save vaps to store when promo added. This should allow an update to the package name in the review dropdown --- src/fmg-components/cart/cart.vue | 10 +++++-- .../promo-modal-question.vue | 5 +++- src/layouts/confirmation/confirmation.spec.js | 26 +++++++++++-------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index c718c2d4c..0a3b3576a 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -134,7 +134,8 @@ v-model="lineItems" :addableVaps="availableVaps" :pageName="pageName" - modalWidgetName="PromoModalWidget" /> + modalWidgetName="PromoModalWidget" + @promoAdded="saveVaps" />
lineItemsToKeep.cartItemType != cartItemType ); - + + await this.dispatchStoreAction(storeActions.SAVE_VAPS, this.lineItems.vaps, false); + }, + + async saveVaps(vaps) { + this.lineItems.vaps = [...vaps]; await this.dispatchStoreAction(storeActions.SAVE_VAPS, this.lineItems.vaps, false); }, diff --git a/src/fmg-components/promo-modal-question/promo-modal-question.vue b/src/fmg-components/promo-modal-question/promo-modal-question.vue index cf5e52f21..4a32b03fc 100644 --- a/src/fmg-components/promo-modal-question/promo-modal-question.vue +++ b/src/fmg-components/promo-modal-question/promo-modal-question.vue @@ -220,7 +220,7 @@ export default { additionalInfo: promoValidationResponse?.additionalInfo, }; }, - removeItem(promo) { + async removeItem(promo) { this.lineItems[cartItemCategories.PROMOS] = this.lineItems[ cartItemCategories.PROMOS ].filter( @@ -320,6 +320,9 @@ export default { this.lineItems.vaps?.push(...getVaps); } this.lineItems?.promos.push(...promoCodeData.promoCode); + + this.$emit('promoAdded', this.lineItems.vaps); + this.closeModal(); } else { this.getErrorMessage(promoCodeData.errorCode, promoCodeData.additionalInfo); diff --git a/src/layouts/confirmation/confirmation.spec.js b/src/layouts/confirmation/confirmation.spec.js index c4e048ef0..2141d0591 100644 --- a/src/layouts/confirmation/confirmation.spec.js +++ b/src/layouts/confirmation/confirmation.spec.js @@ -72,7 +72,7 @@ beforeEach(() => { }, policy: { isNoComp: false, - } + }, }, damage: {}, payment: { @@ -616,9 +616,11 @@ describe("computed properties...", () => { //Arrange const { wrapper } = setupMocks({}); const lineItems = { - glassParts: [{ - partType: "RECALIBRATION", - }] + glassParts: [ + { + partType: "RECALIBRATION", + }, + ], }; wrapper.vm.submittedOrder = { @@ -639,7 +641,7 @@ describe("computed properties...", () => { lineItems: { glassParts: { partType: "Recalibration", - } + }, }, serviceLocation: store.getters.order.serviceLocation, }; @@ -653,13 +655,15 @@ describe("computed properties...", () => { // Assert expect(testValue).toEqual(true); }); - test ("Itac/NoComp with Recal should return false for shouldHideRecalibration", async () => { + test("Itac/NoComp with Recal should return false for shouldHideRecalibration", async () => { //Arrange const { wrapper } = setupMocks({}); const lineItems = { - glassParts: [{ - partType: "RECALIBRATION", - }] + glassParts: [ + { + partType: "RECALIBRATION", + }, + ], }; wrapper.vm.submittedOrder = { @@ -688,7 +692,7 @@ describe("computed properties...", () => { // Assert expect(testValue).toEqual(false); - }); + }); }); function setupMocks({ customMountOptions }) { @@ -706,7 +710,7 @@ function setupMocks({ customMountOptions }) { if (settingName === experimentSettings.RECAL_PRICE_REMOVE) { return "true"; } - + return "false"; }), },