From 819e1df086baf86eabe3c367f3d7957a4955cc9b Mon Sep 17 00:00:00 2001 From: AdamCaouetteSafelite Date: Fri, 18 Jul 2025 08:21:51 -0400 Subject: [PATCH] CASH-845: fix preselected dates to work with new schedule code --- src/layouts/schedule/schedule.vue | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index e0ddf92dd..979ed9355 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -397,6 +397,7 @@ export default { showPricingByDay: null, selectableDatesInshop: [], selectableDatesMobile: [], + preSelectedDate: null, streetAddress: this.getServiceAddressFromStore(), apartmentNumberOrBusinessName: this.getServiceAddress2FromStore(), @@ -466,11 +467,11 @@ export default { let appointmentType = store.getters.order.serviceLocation.appointmentType; // Check to see if date should be pre-selected - let preSelectedSlot = await store.getters.order.schedule; + let scheduleFromStore = await store.getters.order.schedule; let preSelectedDate; - if (preSelectedSlot.date && preSelectedSlot.date.length > 0) { - preSelectedDate = preSelectedSlot.date; + if (scheduleFromStore.date && scheduleFromStore.date.length > 0) { + preSelectedDate = scheduleFromStore.date; if (appointmentType === AppointmentTypeStrings.MOBILE) { preSelectedDate += "-mobile"; @@ -479,7 +480,7 @@ export default { // Check to see if pre-selected date should have pricing by day upcharge if (showPricingByDay) { // is this preSelectedDate a higher priced pricingByDay day? - const dayIndex = convertDateStringToDate(preSelectedSlot?.date).getDay(); + const dayIndex = convertDateStringToDate(scheduleFromStore?.date).getDay(); const dayObject = DAYS_OF_WEEK[dayIndex]; if (dayObject.isPricingByDayUpchargeDay) { includePricingByDayUpcharge = true; @@ -588,7 +589,7 @@ export default { vm.pricingByDayBasePrice = pricingByDayBasePrice; vm.pricingByDayUpcharge = pricingByDayUpcharge; vm.showPricingByDay = showPricingByDay; - + vm.preSelectedDate = preSelectedDate; vm.appointmentType = appointmentType; vm.setData( resultMap.zipCodeData, @@ -1139,7 +1140,7 @@ export default { selectableDatesSetting: "custom", initialViewRowsToShow: NUMBER_OF_CALENDAR_ROWS_TO_SHOW_FOR_INITIAL_VIEW, getSelectableDatesCallback: getScheduleApiResponse, - // preSelectedDate: preSelectedDate, + preSelectedDate: this.preSelectedDate, providerNumber: this.selectedProvider?.providerNumber, zipCode: this.zipCode, includeMobileTimeSlots: this.isServiceableMobile, @@ -1154,7 +1155,7 @@ export default { datePickerInitialData.initialShopTimeSlotsResponse.mobileTimeSlotsData; this.setDisplayWaitList(); - // TODO - CHECK FOR A PRESELECTED DATE!!! DON'T NEED TO DO THE BELOW IF THERE'S A PRESELECTED...? + if (this.preSelectedDate) this.selectedDate = this.preSelectedDate; if (!this.selectedDate) { // if no date is preselected on load, then select the first available @@ -1415,17 +1416,16 @@ export default { } }, setDisplayWaitList() { + const dateString = this.isMobileSelected + ? this.selectableDatesMobile?.days[0]?.date + : this.selectableDatesInshop?.days[0]?.date; if ( experimentMixin.methods.hasSettingEqualTo( experimentSettings.DISPLAY_WAITLIST, "true" ) && - this.selectableDatesMobile.days && - this.selectableDatesInshop.days + dateString ) { - const dateString = this.isMobileSelected - ? this.selectableDatesMobile?.days[0]?.date - : this.selectableDatesInshop?.days[0]?.date; const [year, month, day] = dateString.split("-").map(Number); const targetDate = new Date(year, month - 1, day); const currentDate = new Date();