CASH-1209: Auto select pre-selected timeslot

This commit is contained in:
Chris Redelinghuys 2025-07-28 08:33:56 -04:00
parent 6f31d1bfb9
commit f5d4da065c

View file

@ -449,8 +449,6 @@ export default {
); );
} }
this.resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate);
return availableTimeSlots; return availableTimeSlots;
}, },
getPremiumAppointmentTimeSlot(timeSlotData) { getPremiumAppointmentTimeSlot(timeSlotData) {
@ -548,15 +546,20 @@ export default {
}, },
resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate) { resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate) {
if (this.selectedRouteCode) { if (this.selectedRouteCode) {
const selectedRouteCodeString = this.selectedRouteCode.replace( const selectedRouteCodeString = this.removePremiumFlagFromInput(
PREMIUM_TIME_SLOT_ID_FLAG, this.selectedRouteCode
""
); );
const matchingTimeSlot = timeSlotsForSelectedDate.find((slot) => { const availableTimeSlotsForSelectedDate =
timeSlotsForSelectedDate.timeSlots || timeSlotsForSelectedDate;
const matchingTimeSlot = availableTimeSlotsForSelectedDate.find((slot) => {
return slot.id === selectedRouteCodeString; return slot.id === selectedRouteCodeString;
}); });
if (!matchingTimeSlot) { if (!matchingTimeSlot) {
this.resetSelectedTimeSlot(); if (selectedRouteCodeString !== this.answersForDropOffQuestion[0].value) {
this.resetSelectedTimeSlot();
}
} else {
this.setSelectedTimeSlot();
} }
} }
}, },
@ -580,9 +583,7 @@ export default {
}, },
selectedDate: { selectedDate: {
handler() { handler() {
this.resetSelectedTimeSlot(); this.resetSelectedTimeSlotIfDateChange(this.timeSlotsForSelectedDate);
this.selectedAnswerForDropOffOrInshop = null;
this.selectedAnswerForTimeSlots = null;
this.autoSelectTimeSlotIfOnlyOneIsAvailable(); this.autoSelectTimeSlotIfOnlyOneIsAvailable();
}, },
}, },