From bea71eb1711d5270b32677c0aa4f0ef6acaa6162 Mon Sep 17 00:00:00 2001 From: AdamCaouetteSafelite Date: Thu, 17 Jul 2025 10:30:30 -0400 Subject: [PATCH 1/3] CASH-845: fixing apptType/providerNumber/zipCode conflicts --- src/layouts/schedule/schedule.vue | 123 +++++++++++++++--------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 56c18da12..a6d3d1774 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -156,7 +156,7 @@ @@ -416,9 +416,9 @@ export default { isRecalibrationServiceableDropoff: null, isGlassServiceableMobile: null, isRecalibrationServiceableMobile: null, - appointmentType: this.getAppointmentType(), - appointmentTypeFromAppointmentTypeQuestion: this.getAppointmentType(), - selectedProvider: this.getSelectedProvider(), + appointmentType: this.getAppointmentTypeFromStore(), + appointmentTypeFromAppointmentTypeQuestion: this.getAppointmentTypeFromStore(), + selectedProvider: this.getSelectedProviderFromStore(), mobileFeePart: null, recycleFeePart: null, zipContainsMilitaryBase: false, @@ -583,6 +583,7 @@ export default { const resultMap = await settleAllPromises(promiseResultMap); + // add pricing by day data const pricingByDayUpcharge = showPricingByDay && resultMap.pricingByDayUpchargePart ? await baseMixin.methods.getTotalLineItemPrice( @@ -668,17 +669,7 @@ export default { }; }, set: function (newValue) { - if (newValue.zipCode !== this.zipCode) { - this.resetMobileLocation(); - this.appointmentType = null; - this.selectedProvider = new Provider(); - } - - this.state = newValue.state; - this.zipCode = newValue.zipCode; - this.zipCodeCtu = newValue.zipCodeCtu; - - this.$nextTick(); + this.handleZipCodeChange(newValue); }, }, isMobileSelected() { @@ -835,7 +826,11 @@ export default { }); }; - if (this.selectedProvider && this.selectedProvider.address) { + if ( + this.selectedProvider && + this.selectedProvider.address && + this.selectedProvider?.providerNumber + ) { const provider = this.shopProviderData?.shopProviders?.find( (p) => p.providerNumber === this.selectedProvider?.providerNumber ); @@ -987,13 +982,13 @@ export default { if (shopProviderData) { this.shopProviderData = shopProviderData; + this.updateSelectedProvider(); } var gaLabel = this.GaLabels.NO; if (this.isServiceableMobile) { gaLabel = this.GaLabels.YES; } - this.pushEventToGA( this.GaCategories.APPOINTMENT, this.GaActions.MOBILE_AVAILABLE, @@ -1042,10 +1037,10 @@ export default { getIsVehicleProtectedFromStore() { return store.getters.order.serviceLocation.isVehicleProtected; }, - getAppointmentType() { + getAppointmentTypeFromStore() { return store.getters.order.serviceLocation.appointmentType; }, - getSelectedProvider() { + getSelectedProviderFromStore() { return store.getters.order.serviceLocation.provider; }, resetMobileLocation() { @@ -1584,53 +1579,61 @@ export default { ? AppointmentTypeStrings.DROP_OFF : AppointmentTypeStrings.IN_SHOP; }, + updateSelectedProvider(oldProvider, newProvider) { + if (newProvider) { + this.selectedProvider = newProvider; + } else if ( + // use closest shopProvider if none exists + !this.selectedProvider?.address?.streetAddress && + this.shopProviderData?.shopProviders + ) { + this.selectedProvider = this.shopProviderData.shopProviders[0]; + } + + }, + handleZipCodeChange(newZipCode) { + this.resetMobileLocation(); + this.selectedProvider = new Provider(); + getShopProviderData(newZipCode.zipCode).then(async (result) => { + this.shopProviderData = result.data; + if (this.appointmentType === AppointmentTypeStrings.MOBILE) { + this.updateSelectedProvider( + this.selectedProvider, + new Provider(this.shopProviderData.mobileProviderNumber) + ); + } else { + this.isMobileAddressValid = true; + this.updateSelectedProvider(); + } + }); + this.state = newZipCode.state; + this.zipCode = newZipCode.zipCode; + this.zipCodeCtu = newZipCode.zipCodeCtu; + }, + handleAppointmentTypeChange(newAppointmentType) { + if (newAppointmentType === AppointmentTypeStrings.MOBILE) { + this.appointmentType = AppointmentTypeStrings.MOBILE; + } else { + if (this.selectedTimeSlotInfo?.timeSlot?.routeCode) { + // update appointmentType based on routeCode to determine if it should be dropoff or inshop + this.appointmentType = this.getInShopOrDropOffApptType( + this.selectedTimeSlotInfo.timeSlot.routeCode + ); + } else { + this.appointmentType = AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF; + } + + // make sure a selectedProvider exists + this.updateSelectedProvider(); + } + }, }, watch: { - zipCode: { - handler(newValue) { - if (!this.navigatingForward) { - getShopProviderData(this.zipCode).then(async (result) => { - this.shopProviderData = result.data; - if (this.appointmentType === "Mobile") { - this.selectedProvider = new Provider( - this.shopProviderData.mobileProviderNumber - ); - } else { - this.isMobileAddressValid = true; - } - }); - } - }, - }, - appointmentType: { - handler(newValue, oldValue) { - if (newValue === AppointmentTypeStrings.MOBILE) { - this.selectedProvider = new Provider( - this.shopProviderData.mobileProviderNumber - ); - this.isMobileSelected = true; - } else { - this.selectedProvider = this.shopProviderData.shopProviders[0]; - } - }, - }, appointmentTypeFromAppointmentTypeQuestion: { handler(newValue, oldValue) { - if (newValue === AppointmentTypeStrings.MOBILE) { - this.appointmentType = AppointmentTypeStrings.MOBILE; - } else { - if (this.selectedTimeSlotInfo?.timeSlot?.routeCode) { - // update appointmentType based on routeCode to determine if it should be dropoff or inshop - this.appointmentType = this.getInShopOrDropOffApptType( - this.selectedTimeSlotInfo.timeSlot.routeCode - ); - } else { - this.appointmentType = AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF; - } - } + this.handleAppointmentTypeChange(newValue); }, }, - selectedDate(newValue, oldValue) { // Clear time slot selection if date selected changes if (newValue !== oldValue) { From 583ce61f571e24528ee92f1faaca09e1630ee800 Mon Sep 17 00:00:00 2001 From: AdamCaouetteSafelite Date: Thu, 17 Jul 2025 10:45:19 -0400 Subject: [PATCH 2/3] CASH-845 add comment to explain rationale --- src/layouts/schedule/schedule.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index a6d3d1774..6adda8753 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -982,7 +982,7 @@ export default { if (shopProviderData) { this.shopProviderData = shopProviderData; - this.updateSelectedProvider(); + this.updateSelectedProvider(); // ensure that page loads with non-null selectedProvider } var gaLabel = this.GaLabels.NO; From f08b64bddb5d335c06dc58d308eb3474dce27a21 Mon Sep 17 00:00:00 2001 From: AdamCaouetteSafelite Date: Thu, 17 Jul 2025 11:08:17 -0400 Subject: [PATCH 3/3] CASH-845: prettier caught an extra space --- src/layouts/schedule/schedule.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 6adda8753..c97b654cb 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -1589,7 +1589,6 @@ export default { ) { this.selectedProvider = this.shopProviderData.shopProviders[0]; } - }, handleZipCodeChange(newZipCode) { this.resetMobileLocation();