Merge pull request #2992 from Safelite/feature/CASH-1790-refactor-2

Reapply PR for CASH-1790 refactoring, 2 and 3 combined of 4
This commit is contained in:
AdamCaouetteSafelite 2026-01-06 10:53:52 -05:00 committed by GitHub
commit 34b9e8e9bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 39 additions and 83 deletions

View file

@ -281,7 +281,7 @@ export default {
if (event.screenX === 0 && event.screenY === 0) { if (event.screenX === 0 && event.screenY === 0) {
return; return;
} }
this.$emit("date-clicked", date); this.$emit("date-selected", date);
}, },
getWeekStartDate(dateString) { getWeekStartDate(dateString) {
const date = convertDateStringToDate(dateString); const date = convertDateStringToDate(dateString);
@ -846,12 +846,6 @@ export default {
}, },
}, },
watch: { watch: {
isLoading(newValue) {
// if done loading dates, then set to first available date
if (newValue === false && this.firstAvailableSelectableDate) {
this.selectedDate = this.firstAvailableSelectableDate;
}
},
modelValue(newValue) { modelValue(newValue) {
this.resetField({ this.resetField({
value: newValue, value: newValue,

View file

@ -133,8 +133,6 @@
:isOvernightDropoff="isOvernightDropoff" /> :isOvernightDropoff="isOvernightDropoff" />
</div> </div>
<datePicker <datePicker
:currentZip="zipCode"
:currentProviderNumber="selectedProvider?.providerNumber"
v-show="appointmentType" v-show="appointmentType"
customComponentId="dateQuestion" customComponentId="dateQuestion"
selectableDatesSetting="custom" selectableDatesSetting="custom"
@ -144,7 +142,7 @@
class="text-link-small" class="text-link-small"
:getMoreDatesCallback="getMoreScheduleData" :getMoreDatesCallback="getMoreScheduleData"
validationRules="date-required" validationRules="date-required"
@date-clicked="handleDateClicked" @date-selected="handleDateSelected"
:pricingByDayBasePrice="pricingByDayBasePrice" :pricingByDayBasePrice="pricingByDayBasePrice"
:pricingByDayUpcharge="pricingByDayUpcharge" :pricingByDayUpcharge="pricingByDayUpcharge"
:showPricingByDay="showPricingByDay" :showPricingByDay="showPricingByDay"
@ -167,7 +165,6 @@
:timeSlotsForSelectedDate="timeSlotsForSelectedDate" :timeSlotsForSelectedDate="timeSlotsForSelectedDate"
:isSameDay="isSameDay" :isSameDay="isSameDay"
:selectedRouteCodeData="selectedRouteCodeData" :selectedRouteCodeData="selectedRouteCodeData"
:isDatePickerDoneInitializing="isDatePickerDoneInitializing"
@waitListRequested="handleWaitListRequested" /> @waitListRequested="handleWaitListRequested" />
<navbar <navbar
cmsWidgetName="FunnelFooterWidget" cmsWidgetName="FunnelFooterWidget"
@ -475,7 +472,6 @@ export default {
experimentSettings.SHOW_MOBILE_FIRST_APPT, experimentSettings.SHOW_MOBILE_FIRST_APPT,
"true" "true"
), ),
isDatePickerDoneInitializing: false,
}; };
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
@ -638,12 +634,12 @@ export default {
showTimeSlotQuestion() { showTimeSlotQuestion() {
if ( if (
this.selectedDate && this.selectedDate &&
this.selectedDate.includes("mobile") && this.appointmentTypeFromAppointmentTypeQuestion &&
!this.isMobileSelected this.timeSlotsForSelectedDate
) { ) {
this.setSelectedDateToFirstAvailable(); return true;
} }
return this.selectedDate && this.appointmentTypeFromAppointmentTypeQuestion; return false;
}, },
isMobileStaticRecalibrationApplicable() { isMobileStaticRecalibrationApplicable() {
return ( return (
@ -1181,8 +1177,6 @@ export default {
async initializeDatePicker() { async initializeDatePicker() {
this.isShowMobileFirstAppt && this.showLoadingModal(); this.isShowMobileFirstAppt && this.showLoadingModal();
this.selectedDate = null;
const includeMobileTimeSlots = this.isServiceableMobile; const includeMobileTimeSlots = this.isServiceableMobile;
const includeInshopTimeSlots = this.isServiceableInshop || this.isServiceableDropoff; const includeInshopTimeSlots = this.isServiceableInshop || this.isServiceableDropoff;
const datePickerInitialData = await this.$refs.datePicker.loadInitialData({ const datePickerInitialData = await this.$refs.datePicker.loadInitialData({
@ -1220,8 +1214,6 @@ export default {
} }
this.isShowMobileFirstAppt && this.hideLoadingModal(); this.isShowMobileFirstAppt && this.hideLoadingModal();
await this.$nextTick();
this.isDatePickerDoneInitializing = true;
}, },
getScheduleApiResponse, getScheduleApiResponse,
getServiceZipCtuCodeFromStore() { getServiceZipCtuCodeFromStore() {
@ -1572,28 +1564,40 @@ export default {
handleWaitListRequested(value) { handleWaitListRequested(value) {
this.waitListRequested = value; this.waitListRequested = value;
}, },
handleDateClicked(date) { handleDateSelected(date) {
// do something to mark this as upcharge day or not... const previousDate = this.selectedDate;
if (date.isPricingByDayUpchargeDay) {
this.includePricingByDayUpcharge = true; // check if date actually changed
} else { if (previousDate !== date.dateString) {
this.includePricingByDayUpcharge = false; this.selectedTimeSlotInfo = this.getEmptyTimeSlot();
this.updateFooterButtonText(this.selectedTimeSlotInfo);
} }
// TODO: REMOVE AS PART OF CASH-1634
// // do something to mark this as upcharge day or not...
// if (date.isPricingByDayUpchargeDay) {
// this.includePricingByDayUpcharge = true;
// } else {
// this.includePricingByDayUpcharge = false;
// }
},
getEmptyTimeSlot() {
return {
timeSlot: {
date: null,
routeCode: null,
startTime: null,
endTime: null,
jobMaxMinutes: null,
jobMinMinutes: null,
},
isPremiumAppointment: null,
};
}, },
updateTimeSlot(timeSlotObj) { updateTimeSlot(timeSlotObj) {
if (!timeSlotObj?.routeCode) { if (!timeSlotObj?.routeCode) {
this.appointmentType = AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF; this.appointmentType = AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF;
this.selectedTimeSlotInfo = { this.selectedTimeSlotInfo = this.getEmptyTimeSlot();
timeSlot: {
date: null,
routeCode: null,
startTime: null,
endTime: null,
jobMaxMinutes: null,
jobMinMinutes: null,
},
isPremiumAppointment: null,
};
return; return;
} }
const timeSlot = this.timeSlotsForSelectedDate?.timeSlots?.find( const timeSlot = this.timeSlotsForSelectedDate?.timeSlots?.find(
@ -1690,6 +1694,9 @@ export default {
}, },
handleAppointmentTypeChange(newAppointmentType) { handleAppointmentTypeChange(newAppointmentType) {
this.updateFooterButtonText(); this.updateFooterButtonText();
// if time appointment type changes, clear any selected time slot
this.selectedTimeSlotInfo = this.getEmptyTimeSlot();
if (newAppointmentType === AppointmentTypeStrings.MOBILE) { if (newAppointmentType === AppointmentTypeStrings.MOBILE) {
// Remember last shop selected if previous selection was inshop/dropoff // Remember last shop selected if previous selection was inshop/dropoff
if ( if (
@ -1698,17 +1705,6 @@ export default {
AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF) && AppointmentTypeStrings.IN_SHOP_OR_DROP_OFF) &&
this.selectedProvider this.selectedProvider
) { ) {
this.selectedTimeSlotInfo = {
timeSlot: {
date: null,
routeCode: null,
startTime: null,
endTime: null,
jobMaxMinutes: null,
jobMinMinutes: null,
},
isPremiumAppointment: null,
};
this.lastSelectedInshopOrDropoffProvider = this.selectedProvider; this.lastSelectedInshopOrDropoffProvider = this.selectedProvider;
} }
this.appointmentType = AppointmentTypeStrings.MOBILE; this.appointmentType = AppointmentTypeStrings.MOBILE;
@ -1856,36 +1852,6 @@ export default {
this.handleAppointmentTypeChange(newValue); this.handleAppointmentTypeChange(newValue);
}, },
}, },
selectedDate(newValue, oldValue) {
if (!this.isDatePickerDoneInitializing) {
return;
} // needed otherwise it nulls selectedTimeSlotInfo too early and prevents a previously selected time slot from auto-selecting
// Clear time slot selection if date selected changes
const selectedDate = this.getSelectedDateFromStore();
if (oldValue && this.appointmentType === AppointmentTypeStrings.MOBILE) {
oldValue = `${oldValue}-mobile`;
}
const hasValueChanged = newValue !== oldValue;
const isDateDifferent = (newValue || oldValue) !== selectedDate;
if (hasValueChanged && isDateDifferent && !this.selectedMobileFirstAppointment) {
this.selectedTimeSlotInfo = {
timeSlot: {
date: null,
routeCode: null,
startTime: null,
endTime: null,
jobMaxMinutes: null,
jobMinMinutes: null,
},
isPremiumAppointment: null,
};
}
},
selectedTimeSlotInfo(newValue) {
this.updateFooterButtonText(newValue);
},
}, },
components: { components: {
funnelHeader, funnelHeader,
@ -1898,7 +1864,6 @@ export default {
textBlock, textBlock,
timeSlotQuestion, timeSlotQuestion,
mobileFirstModal, mobileFirstModal,
alert, alert,
serviceZipModalQuestion, serviceZipModalQuestion,
appointmentTypeQuestion, appointmentTypeQuestion,

View file

@ -137,7 +137,6 @@ export default {
isSameDay: Boolean, isSameDay: Boolean,
displayWaitList: Boolean, displayWaitList: Boolean,
selectedRouteCodeData: Object, selectedRouteCodeData: Object,
isDatePickerDoneInitializing: Boolean,
}, },
data() { data() {
return { return {
@ -191,9 +190,6 @@ export default {
this.updateDropoffAndTimeSlotAnswersFromSelectedRouteCodeData(newValue); this.updateDropoffAndTimeSlotAnswersFromSelectedRouteCodeData(newValue);
}, },
timeSlotsForSelectedDate() { timeSlotsForSelectedDate() {
if (!this.isDatePickerDoneInitializing) {
return;
} // needed otherwise it nulls these too early and prevents a previously selected time slot from auto-selecting
this.selectedAnswerForDropOffOrInshop = null; this.selectedAnswerForDropOffOrInshop = null;
this.selectedAnswerForTimeSlots = null; this.selectedAnswerForTimeSlots = null;
this.autoSelectTimeSlotIfOnlyOneIsAvailable(); this.autoSelectTimeSlotIfOnlyOneIsAvailable();

View file

@ -80,6 +80,7 @@ export default {
}, },
set: function (newValue) { set: function (newValue) {
this.$emit("update:modelValue", newValue); this.$emit("update:modelValue", newValue);
this.$emit("handle-appointment-type-change", newValue);
}, },
}, },
isMobileOnly() { isMobileOnly() {