From c8db19a73b001b25044f7fbdae801aecd23de493 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 6 Aug 2025 11:01:57 -0400 Subject: [PATCH] Fix early bird issues, auto-select, and general clean up --- .../time-slot-question/time-slot-question.vue | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 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 2cc89be17..8332886b8 100644 --- a/src/layouts/schedule/time-slot-question/time-slot-question.vue +++ b/src/layouts/schedule/time-slot-question/time-slot-question.vue @@ -115,7 +115,6 @@ export default { name: "time-slot-question", emits: ["update:modelValue", "time-slot-selection-changed",], props: { - cmsWidgetName: String, mobileCmsWidgetName: String, mobilePremiumCmsWidgetName: String, dropoffCmsWidgetName: String, @@ -134,10 +133,14 @@ export default { data() { return { timeSlotModalListButton: timeSlotModalListButton, + selectedAnswerForTimeSlots: null, selectedAnswerForDropOffOrInshop: null, - selectedAnswerForTimeSlots: null }; }, + mounted() { + this.updateDropoffAndTimeSlotAnswersFromSelectedRouteCodeData(this.selectedRouteCodeData); + this.autoSelectTimeSlotIfOnlyOneIsAvailable(); + }, setup(props) { const uuid = uuidv4(); const componentId = !props.customComponentId @@ -181,10 +184,10 @@ export default { timeSlotsForSelectedDate() { this.selectedAnswerForDropOffOrInshop = null; this.selectedAnswerForTimeSlots = null; + this.autoSelectTimeSlotIfOnlyOneIsAvailable(); } }, computed: { - supplementalInformationBlock() { let appointmentTypeCmsWidgetName; @@ -193,9 +196,6 @@ export default { this.appointmentType === AppointmentTypeStrings.IN_SHOP || this.appointmentType === AppointmentTypeStrings.DROP_OFF ) { - if (!this.selectedAnswerForTimeSlots && !this.selectedAnswerForDropOffOrInshop) { - this.autoSelectTimeSlotIfOnlyOneIsAvailable(); - } return null; // This is planned to be used again for drop-off // Wrote this to be ready for that eventuality, is untested and no HTML work done yet @@ -390,11 +390,15 @@ export default { methods: { updateDropoffAndTimeSlotAnswersFromSelectedRouteCodeData(selectedRouteCodeData) { if (selectedRouteCodeData?.routeCode) { - if (isDropOffRouteCode(selectedRouteCodeData.routeCode)) { - this.selectedAnswerForDropOffOrInshop = selectedRouteCodeData.routeCode; + let routeCode = selectedRouteCodeData.routeCode; + if (isDropOffRouteCode(routeCode)) { + this.selectedAnswerForDropOffOrInshop = routeCode; } else { this.selectedAnswerForDropOffOrInshop = PICK_A_TIME_BUTTON_VALUE; - this.selectedAnswerForTimeSlots = selectedRouteCodeData.routeCode; + if (this.selectedRouteCodeData.isPremiumAppointment) { + routeCode = this.addPremiumFlagToInput(routeCode); + } + this.selectedAnswerForTimeSlots = routeCode; } } else { this.selectedAnswerForDropOffOrInshop = null; @@ -413,7 +417,6 @@ export default { this.$emit("time-slot-selection-changed", newSelectedRouteCodeData); }, timeSlotSelectionChanged(newValue) { - console.log('heard time slot change', newValue); if(newValue) { let routeCode = newValue; let isPremiumAppointment = routeCode.includes( @@ -428,18 +431,19 @@ export default { }) } }, - getRelevantDropOffCmsWidgetNameForSelectedTimeSlot( - selectedRouteCode, - isSameDayRelevant = false - ) { - if (selectedRouteCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) { - return this.overnightDropOffCmsWidgetName; - } else if (selectedRouteCode.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) { - return this.isSameDay && isSameDayRelevant - ? this.sameDayDropOffCmsWidgetName - : this.dropoffCmsWidgetName; - } - }, + // This is unused but planned to be used again + // getRelevantDropOffCmsWidgetNameForSelectedTimeSlot( + // selectedRouteCode, + // isSameDayRelevant = false + // ) { + // if (selectedRouteCode.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) { + // return this.overnightDropOffCmsWidgetName; + // } else if (selectedRouteCode.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) { + // return this.isSameDay && isSameDayRelevant + // ? this.sameDayDropOffCmsWidgetName + // : this.dropoffCmsWidgetName; + // } + // }, getAvailableTimeSlotsForInshop(timeSlotsForSelectedDate) { return timeSlotsForSelectedDate .filter((timeSlot) => { @@ -491,15 +495,16 @@ export default { getWaitListRequestedFromStore() { return store.getters.order.customer?.waitListRequested; }, - autoSelectTimeSlotIfOnlyOneIsAvailable() { // this needs to be fixed + autoSelectTimeSlotIfOnlyOneIsAvailable() { const numberOfOptions = this.timeSlotsForSelectedDate?.timeSlots?.length; - if (this.appointmentType && numberOfOptions === 1) { + if (numberOfOptions === 1) { if (this.availableTimeSlots.length > 0) { + // this.availableTimeSlots only returns mobile/inshop slots so we know + // the only available slot is not dropOFf this.selectedAnswerForTimeSlots = this.availableTimeSlots[0].value; } else { this.selectedAnswerForDropOffOrInshop = this.answersForDropOffQuestion[0].value; } - this.setSelectedTimeSlot(); } }, addPremiumFlagToInput(routeCode) {