CASH-1214: Reset selected timeslot on date change

This commit is contained in:
Chris Redelinghuys 2025-07-23 14:04:30 -04:00
parent 4a3a84689c
commit 84f7911c1a

View file

@ -183,6 +183,7 @@ export default {
let appointmentTypeCmsWidgetName; let appointmentTypeCmsWidgetName;
if ( if (
this.selectedDate == null ||
this.appointmentType === AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF || this.appointmentType === AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF ||
this.appointmentType === AppointmentTypeStrings.IN_SHOP || this.appointmentType === AppointmentTypeStrings.IN_SHOP ||
this.appointmentType === AppointmentTypeStrings.DROP_OFF this.appointmentType === AppointmentTypeStrings.DROP_OFF
@ -440,6 +441,8 @@ export default {
); );
} }
this.resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate);
return availableTimeSlots; return availableTimeSlots;
}, },
getPremiumAppointmentTimeSlot(timeSlotData) { getPremiumAppointmentTimeSlot(timeSlotData) {
@ -535,6 +538,20 @@ export default {
successMessageElement.scrollIntoView({ behavior: "smooth" }); successMessageElement.scrollIntoView({ behavior: "smooth" });
} }
}, },
resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate) {
if (this.selectedRouteCode) {
const selectedRouteCodeString = this.selectedRouteCode.replace(
PREMIUM_TIME_SLOT_ID_FLAG,
""
);
const matchingTimeSlot = timeSlotsForSelectedDate.find((slot) => {
return slot.id === selectedRouteCodeString;
});
if (!matchingTimeSlot) {
this.selectedRouteCode = null;
}
}
},
}, },
watch: { watch: {
waitListRequested(newVal) { waitListRequested(newVal) {