CASH-845: fixing apptType/providerNumber/zipCode conflicts

This commit is contained in:
AdamCaouetteSafelite 2025-07-17 10:30:30 -04:00
parent 2839081866
commit bea71eb171

View file

@ -156,7 +156,7 @@
<navbar
cmsWidgetName="FunnelFooterWidget"
ref="navbar"
:isForwardActionDisabled="!meta.valid"
:isForwardActionDisabled="!meta.valid || isForwardActionDisabled"
@back-clicked="backButtonAction"
@ForwardClicked="forwardButtonAction" />
</div>
@ -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) {