From f5d4da065c097d1a4c81d187d7e87d39c436d9c8 Mon Sep 17 00:00:00 2001 From: Chris Redelinghuys Date: Mon, 28 Jul 2025 08:33:56 -0400 Subject: [PATCH] CASH-1209: Auto select pre-selected timeslot --- .../time-slot-question/time-slot-question.vue | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/layouts/schedule/time-slot-question/time-slot-question.vue b/src/layouts/schedule/time-slot-question/time-slot-question.vue index 97b334821..1714f4906 100644 --- a/src/layouts/schedule/time-slot-question/time-slot-question.vue +++ b/src/layouts/schedule/time-slot-question/time-slot-question.vue @@ -449,8 +449,6 @@ export default { ); } - this.resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate); - return availableTimeSlots; }, getPremiumAppointmentTimeSlot(timeSlotData) { @@ -548,15 +546,20 @@ export default { }, resetSelectedTimeSlotIfDateChange(timeSlotsForSelectedDate) { if (this.selectedRouteCode) { - const selectedRouteCodeString = this.selectedRouteCode.replace( - PREMIUM_TIME_SLOT_ID_FLAG, - "" + const selectedRouteCodeString = this.removePremiumFlagFromInput( + this.selectedRouteCode ); - const matchingTimeSlot = timeSlotsForSelectedDate.find((slot) => { + const availableTimeSlotsForSelectedDate = + timeSlotsForSelectedDate.timeSlots || timeSlotsForSelectedDate; + const matchingTimeSlot = availableTimeSlotsForSelectedDate.find((slot) => { return slot.id === selectedRouteCodeString; }); if (!matchingTimeSlot) { - this.resetSelectedTimeSlot(); + if (selectedRouteCodeString !== this.answersForDropOffQuestion[0].value) { + this.resetSelectedTimeSlot(); + } + } else { + this.setSelectedTimeSlot(); } } }, @@ -580,9 +583,7 @@ export default { }, selectedDate: { handler() { - this.resetSelectedTimeSlot(); - this.selectedAnswerForDropOffOrInshop = null; - this.selectedAnswerForTimeSlots = null; + this.resetSelectedTimeSlotIfDateChange(this.timeSlotsForSelectedDate); this.autoSelectTimeSlotIfOnlyOneIsAvailable(); }, },