From 37b876f72c059ccda65d955fe025202de026812a Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 1 Mar 2024 10:59:10 -0500 Subject: [PATCH 1/4] Auto stash before merge of "feature/CSR-1971" and "origin/develop" --- src/fmg-components/cart/cart.vue | 12 ++++++++++-- src/layouts/quote/quote.vue | 7 +++++-- src/store/index.js | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index 8a7714410..f273b724c 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -236,8 +236,6 @@ export default { this.lineItems[category] = this.lineItems[category].filter( (lineItemsToKeep) => lineItemsToKeep.cartItemType != cartItemType ); - - this.$emit("update:modelValue", this.lineItems); }, getPromoCodeList() { if (this.$refs["promoModalQuestion"]) { @@ -245,6 +243,10 @@ export default { } return []; }, + handleAddedPromo(lineItems) { + // NOTE: these lineItems are passed from promo-modal-question + //this.$emit("update:modelValue", lineItems); + }, }, computed: { screenReaderTotalAmountDueText() { @@ -846,6 +848,12 @@ export default { }, deep: true, }, + lineItems: { + handler(newValue) { + console.log('cart emitted a modelValue update'); + this.$emit("update:modelValue", newValue); + } + } }, components: { textBlock, diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index c1dd44145..82c3ad6d3 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -86,6 +86,7 @@ import baseMixin from "@/mixins/base-mixin.js"; import vehicleQuestionsMixin from "../../mixins/vehicle-questions-mixin"; import { settleAllPromises } from "@/helpers/layout-helper"; import { storeActions } from "@/constants/store-actions"; +import { deepClone } from "@/helpers/object-helper"; import store from "@/store"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { required } from "@/helpers/validation-rules"; @@ -149,7 +150,7 @@ export default { ]; const resultMap = await settleAllPromises(promiseResultMap); - const lineItems = store.getters.order.lineItems; + const lineItems = deepClone(store.getters.order.lineItems); const nullSafeGlassParts = lineItems.glassParts ?? []; const availableLineItems = [ resultMap.rainDefense, @@ -180,7 +181,8 @@ export default { const oldInactivePromos = store.getters.order.payment.inactivePromos?.slice(0); const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO); - + console.log("lineItems before sending off for promo"); + console.log(JSON.parse(JSON.stringify(lineItems))); const { validatePromoResponse, revalidatePromoResponse } = await revalidatePromosAndValidateQueryStringPromo( promoCodeFromQueryString, @@ -190,6 +192,7 @@ export default { lineItems.glassParts = nullSafeGlassParts; lineItems.promos = lineItems.promos ?? []; lineItems.vaps = lineItems.vaps ?? []; + console.log("lineItems.vaps", JSON.parse(JSON.stringify(lineItems.vaps))); // End of promo logic // Call the "next" function to complete the transition to this page. diff --git a/src/store/index.js b/src/store/index.js index 06a5631d3..ec3426bd5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2176,6 +2176,7 @@ export const actions = { context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItems); }, saveVaps(context, vaps) { + console.log("saving vaps"); addGuidToLineItemsIfNotAlreadyThere(vaps); context.commit(storeMutations.UPDATE_VAPS, vaps); }, @@ -2426,6 +2427,7 @@ export const actions = { lineItemsToUse = lineItemsToUse ? deepClone(lineItemsToUse) : deepClone(order.lineItems); addGuidToLineItemsIfNotAlreadyThere(lineItemsToUse.vaps); lineItemsToUse.promos = activePromosToUse; + console.log("lineItemsToUse:", lineItemsToUse); inactivePromosToUse = inactivePromosToUse ?? order.payment.inactivePromos; inactivePromosToUse = removeCurrentlyActivePromoCodesFromInactivePromos( From e67b661279b1f84670ce48c99cbf6bbbed20444b Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 1 Mar 2024 15:16:13 -0500 Subject: [PATCH 2/4] CSR-1971 | Reworking quote page --- .../promo-modal-question.vue | 10 ++++----- src/layouts/quote/quote.vue | 22 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-) 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 56d235afc..51eff182c 100644 --- a/src/fmg-components/promo-modal-question/promo-modal-question.vue +++ b/src/fmg-components/promo-modal-question/promo-modal-question.vue @@ -99,7 +99,7 @@ export default { props: { modelValue: Object, modalWidgetName: String, - availableVaps: Object, + addableVaps: Object, pageName: String, taxPromos: { type: Boolean, @@ -192,14 +192,14 @@ export default { resetModalButtonStyle() { this.modal.resetButtonStyle(); }, - async getPromoCodeData(promoCode, lineItems, availableVaps, pageNameToLog = null) { + async getPromoCodeData(promoCode, lineItems, addableVaps, pageNameToLog = null) { const pageName = pageNameToLog ?? this.$options?.name; const promoValidationResponse = await baseMixin.methods.dispatchStoreActionWithLogging( storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA, { promoCode: promoCode, lineItemsToUse: lineItems, - addableVaps: availableVaps, + addableVaps: addableVaps, }, pageName, false @@ -264,7 +264,7 @@ export default { const promoCodeData = await this.getPromoCodeData( this.promoCode, this.lineItems, - this.availableVaps, + this.addableVaps, this.pageName ); if (promoCodeData.isValid) { @@ -298,7 +298,7 @@ export default { ); const taxedVaps = mapTaxedLineItemsToStoreFormat( taxedLineItems, - this.availableVaps + this.addableVaps ); const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos( diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 82c3ad6d3..35ec0451b 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -42,7 +42,7 @@ @@ -149,8 +149,14 @@ export default { }, ]; + // -Check PRs to make sure you've looked at all newly added code + // -Briefly investigate new issue, then ask Sneha to look at it via email + // -Undo the package selection fix sneha did and see if my changes fix that + 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 = [ resultMap.rainDefense, @@ -173,10 +179,11 @@ export default { resultMap.supportingItems, false ); + lineItems.supportingItems = resultMap.supportingItems; // Promo logic // Populate the previous state of promos for toast message usage in "next()" - const availableVaps = [...resultMap.wipers, resultMap.rainDefense]; + const addableVaps = [...resultMap.wipers, resultMap.rainDefense]; const oldActivePromos = store.getters.lineItems.promos?.slice(0); const oldInactivePromos = store.getters.order.payment.inactivePromos?.slice(0); @@ -189,16 +196,13 @@ export default { pricingResults, "quote" ); - lineItems.glassParts = nullSafeGlassParts; - lineItems.promos = lineItems.promos ?? []; - lineItems.vaps = lineItems.vaps ?? []; console.log("lineItems.vaps", JSON.parse(JSON.stringify(lineItems.vaps))); // End of promo logic // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); - vm.availableVaps = availableVaps; + vm.addableVaps = addableVaps; vm.lineItems = lineItems; vm.availableLineItems = pricingResults; vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue(vm.availableLineItems); @@ -228,7 +232,7 @@ export default { isInsuranceSelected: null, availableLineItems: null, lineItems: [], - availableVaps: [], + addableVaps: [], }; }, computed: { @@ -307,7 +311,7 @@ export default { this.$store.getters.order.payment.parentAccountNumber != applicationConfig.CASH_PARENT_ACCOUNT_NUMBER ) { - this.supportingItems = this.filterOutFees(this.supportingItems); + this.lineItems.supportingItems = this.filterOutFees(this.lineItems.supportingItems); } if (this.lineItems.glassParts?.length > 0) { @@ -323,7 +327,7 @@ export default { storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS, { activePromos: this.lineItems.promos, - inactivePromos: this.$store.getters.order.payment.inactivePromos, + inactivePromos: this.$store.getters.order.payment.inactivePromos, // I don't think we need this here }, false ); From b42e436288bf863a1c4d2b781363b2bc2d16e8dd Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Fri, 1 Mar 2024 15:21:38 -0500 Subject: [PATCH 3/4] CSR-1971 | Continue to clean up code --- src/fmg-components/cart/cart.vue | 12 ++---------- src/layouts/quote/quote.vue | 12 ++---------- src/store/index.js | 2 -- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index f273b724c..0ab26e9e5 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -236,6 +236,8 @@ export default { this.lineItems[category] = this.lineItems[category].filter( (lineItemsToKeep) => lineItemsToKeep.cartItemType != cartItemType ); + + this.$emit("update:modelValue", this.lineItems); }, getPromoCodeList() { if (this.$refs["promoModalQuestion"]) { @@ -243,10 +245,6 @@ export default { } return []; }, - handleAddedPromo(lineItems) { - // NOTE: these lineItems are passed from promo-modal-question - //this.$emit("update:modelValue", lineItems); - }, }, computed: { screenReaderTotalAmountDueText() { @@ -847,12 +845,6 @@ export default { this.lineItems = deepClone(newValue); }, deep: true, - }, - lineItems: { - handler(newValue) { - console.log('cart emitted a modelValue update'); - this.$emit("update:modelValue", newValue); - } } }, components: { diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 35ec0451b..94cafb0a4 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -149,10 +149,6 @@ export default { }, ]; - // -Check PRs to make sure you've looked at all newly added code - // -Briefly investigate new issue, then ask Sneha to look at it via email - // -Undo the package selection fix sneha did and see if my changes fix that - const resultMap = await settleAllPromises(promiseResultMap); const lineItems = deepClone(store.getters.order.lineItems); lineItems.promos = lineItems.promos ?? []; @@ -180,23 +176,20 @@ export default { false ); lineItems.supportingItems = resultMap.supportingItems; + const addableVaps = [...resultMap.wipers, resultMap.rainDefense]; // Promo logic // Populate the previous state of promos for toast message usage in "next()" - const addableVaps = [...resultMap.wipers, resultMap.rainDefense]; const oldActivePromos = store.getters.lineItems.promos?.slice(0); const oldInactivePromos = store.getters.order.payment.inactivePromos?.slice(0); const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO); - console.log("lineItems before sending off for promo"); - console.log(JSON.parse(JSON.stringify(lineItems))); const { validatePromoResponse, revalidatePromoResponse } = await revalidatePromosAndValidateQueryStringPromo( promoCodeFromQueryString, pricingResults, "quote" ); - console.log("lineItems.vaps", JSON.parse(JSON.stringify(lineItems.vaps))); // End of promo logic // Call the "next" function to complete the transition to this page. @@ -326,8 +319,7 @@ export default { this.dispatchStoreAction( storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS, { - activePromos: this.lineItems.promos, - inactivePromos: this.$store.getters.order.payment.inactivePromos, // I don't think we need this here + activePromos: this.lineItems.promos }, false ); diff --git a/src/store/index.js b/src/store/index.js index ec3426bd5..06a5631d3 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2176,7 +2176,6 @@ export const actions = { context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItems); }, saveVaps(context, vaps) { - console.log("saving vaps"); addGuidToLineItemsIfNotAlreadyThere(vaps); context.commit(storeMutations.UPDATE_VAPS, vaps); }, @@ -2427,7 +2426,6 @@ export const actions = { lineItemsToUse = lineItemsToUse ? deepClone(lineItemsToUse) : deepClone(order.lineItems); addGuidToLineItemsIfNotAlreadyThere(lineItemsToUse.vaps); lineItemsToUse.promos = activePromosToUse; - console.log("lineItemsToUse:", lineItemsToUse); inactivePromosToUse = inactivePromosToUse ?? order.payment.inactivePromos; inactivePromosToUse = removeCurrentlyActivePromoCodesFromInactivePromos( From a45702a560801afc3cf83593e8a6d2c1ef68f0a0 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Mon, 4 Mar 2024 07:58:22 -0500 Subject: [PATCH 4/4] 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 );