From 6a7d3b86267e4b0a7afa855f5a558baf3d591c55 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 7 Jun 2023 13:51:19 -0400 Subject: [PATCH] WIP --- src/constants/store-actions.js | 1 + src/constants/store-mutations.js | 1 + src/layouts/quote/quote.vue | 6 +++- src/mixins/vehicle-questions-mixin.js | 5 +++- src/mixins/vehicle-questions-mixin.spec.js | 6 ++-- src/store/index.js | 32 ++++++++++++++-------- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index c44a6fe85..2064f4880 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -70,6 +70,7 @@ const storeActions = { SAVE_VIN: "saveVin", SAVE_REGISTRATION_ADDRESS_LOOKUP: "saveRegistrationAddressLookup", SAVE_GLASS_PARTS: "saveGlassParts", + SAVE_GLASS_PART_PRICES: "saveGlassPartPrices", SAVE_PART_QUESTION_ANSWERS: "savePartQuestionAnswers", RESET_MOLDING_AND_CAPABILITY_QUESTIONS_IF_NEEDED: "resetMoldingAndCapabilityQuestionAnswersIfNeeded", diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index d11459a00..df23d8e65 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -60,6 +60,7 @@ const storeMutations = { RESET_SAVE_SESSION_PROMISE: "resetSaveSessionPromise", RESET_SERVICE_LOCATION_APPOINTMENT_TYPE: "resetServiceLocationAppointmentType", RESET_SERVICE_LOCATION_PROVIDER: "resetServiceLocationProvider", + RESET_SERVICE_LOCATION_MOBILE_ADDRESS: "resetServiceLocationMobileAddress", // OTHER MUTATIONS UPDATE_PAGE_DATA: "updatePageData", diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 06b8ecb9a..3aba56913 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -182,6 +182,7 @@ export default { this.isInsuranceSelected, false ); + if (!this.isInsuranceSelected) { this.dispatchStoreAction( this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER, @@ -196,18 +197,21 @@ export default { ) { this.supportingItems = this.filterOutFees(this.supportingItems); } + if (this.pricedGlassParts.length > 0) { this.dispatchStoreAction( - this.storeActions.SAVE_GLASS_PARTS, + this.storeActions.SAVE_GLASS_PART_PRICES, this.pricedGlassParts, false ); } + this.dispatchStoreAction( this.storeActions.SAVE_SUPPORTING_ITEMS, this.supportingItems, false ); + this.dispatchStoreAction(this.storeActions.SAVE_VAPS, this.selectedVaps, false); const payment = this.$store.getters.payment; diff --git a/src/mixins/vehicle-questions-mixin.js b/src/mixins/vehicle-questions-mixin.js index 718f8fc50..cb967210b 100644 --- a/src/mixins/vehicle-questions-mixin.js +++ b/src/mixins/vehicle-questions-mixin.js @@ -442,7 +442,10 @@ export default { const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions); // save to store lineItems.glassParts - self.$store.commit(storeMutations.UPDATE_GLASS_PARTS, collectedGlassParts); + await baseMixin.methods.dispatchStoreAction( + storeActions.SAVE_GLASS_PARTS, + collectedGlassParts + ) const payment = store.getters.payment; diff --git a/src/mixins/vehicle-questions-mixin.spec.js b/src/mixins/vehicle-questions-mixin.spec.js index a9bf6f313..f87d7efdc 100644 --- a/src/mixins/vehicle-questions-mixin.spec.js +++ b/src/mixins/vehicle-questions-mixin.spec.js @@ -2240,15 +2240,17 @@ describe("vehicle-questions-mixin", () => { // Assert expect(wrapper.vm.$store.commit).toHaveBeenCalledTimes(1); - expect(wrapper.vm.$store.commit).toHaveBeenCalledWith( - storeMutations.UPDATE_GLASS_PARTS, + expect(wrapper.vm.$store.dispatch).toHaveBeenCalledWith( + storeActions.SAVE_GLASS_PARTS, collectedGlassParts ); + expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledTimes(1); expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalledWith( navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS, { query: { fmgPage: "vin-lookup" } } ); + expect(wrapper.vm.$router.navigateWithoutSaving).not.toHaveBeenCalled(); }); }); diff --git a/src/store/index.js b/src/store/index.js index d7b48ba8e..312f4f997 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -253,16 +253,7 @@ export const mutations = { state.order.serviceLocation.isVehicleProtected = serviceLocationInfo.isVehicleProtected; if (serviceLocationInfo.provider) { - state.order.serviceLocation.provider.providerNumber = - serviceLocationInfo.provider?.providerNumber; - state.order.serviceLocation.provider.address.streetAddress = - serviceLocationInfo.provider?.address?.streetAddress; - state.order.serviceLocation.provider.address.city = - serviceLocationInfo.provider?.address?.city; - state.order.serviceLocation.provider.address.state = - serviceLocationInfo.provider?.address?.state; - state.order.serviceLocation.provider.address.zip = - serviceLocationInfo.provider?.address?.zip; + state.order.serviceLocation.provider = serviceLocationInfo.provider; } }, updateSchedule(state, scheduleInfo) { @@ -354,6 +345,14 @@ export const mutations = { resetServiceLocationProvider(state) { state.order.serviceLocation.provider = null; }, + resetServiceLocationMobileAddress(state) { + state.order.serviceLocation.address = null; + state.order.serviceLocation.address2 = null; + state.order.serviceLocation.city = null; + state.order.serviceLocation.state = null; + state.order.serviceLocation.zipCode = null; + state.order.serviceLocation.isVehicleProtected = null; + }, // Misc Mutations updateStateWithOrderInformation(state, sessionInformation) { state.order.referralNumber = sessionInformation.order.referralNumber; @@ -1825,6 +1824,13 @@ export const actions = { }, saveServiceLocation(context, serviceLocationInfo) { + if ( + context.state.order.serviceLocation && + serviceLocationInfo.zipCode !== context.state.order.serviceLocation.zipCode + ) { + context.commit(storeMutations.RESET_SERVICE_LOCATION_MOBILE_ADDRESS); + } + context.commit(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocationInfo); }, @@ -1846,7 +1852,7 @@ export const actions = { }, saveGlassParts(context, parts) { - if (!deepEqual(parts, context.getters.order.lineItems.glassParts)) { + if (!deepEqual(parts, context.state.order.lineItems.glassParts)) { context.commit(storeMutations.RESET_SERVICE_LOCATION_APPOINTMENT_TYPE); context.commit(storeMutations.RESET_SERVICE_LOCATION_PROVIDER); } @@ -1854,6 +1860,10 @@ export const actions = { context.commit(storeMutations.UPDATE_GLASS_PARTS, parts); }, + saveGlassPartPrices(context, parts) { + context.commit(storeMutations.UPDATE_GLASS_PARTS, parts); + }, + clearVin(context) { context.commit(storeMutations.UPDATE_VEHICLE_VIN, null); },