CASH-2378 - split back out mobile and inshop instances of getFirstAvailableApptByTOD
This commit is contained in:
parent
f532b7087e
commit
bbfaf75c87
1 changed files with 33 additions and 14 deletions
|
|
@ -1927,8 +1927,8 @@ export default {
|
||||||
|
|
||||||
let promotedMobileAppointment = null;
|
let promotedMobileAppointment = null;
|
||||||
const todaysDate = getTodayDate();
|
const todaysDate = getTodayDate();
|
||||||
let firstMobileAMAppt = await this.getFirstAvailableApptByTOD("AM", "mobile");
|
let firstMobileAMAppt = await this.getFirstAvailableMobileApptByTOD("AM");
|
||||||
let firstMobilePMAppt = await this.getFirstAvailableApptByTOD("PM", "mobile");
|
let firstMobilePMAppt = await this.getFirstAvailableMobileApptByTOD("PM");
|
||||||
if (!firstMobileAMAppt && !firstMobilePMAppt) {
|
if (!firstMobileAMAppt && !firstMobilePMAppt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2091,10 +2091,10 @@ export default {
|
||||||
// Fetch all appointments
|
// Fetch all appointments
|
||||||
const [firstMobileAMAppt, firstMobilePMAppt, firstInshopAMAppt, firstInshopPMAppt] =
|
const [firstMobileAMAppt, firstMobilePMAppt, firstInshopAMAppt, firstInshopPMAppt] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.getFirstAvailableApptByTOD("AM", "mobile"),
|
this.getFirstAvailableMobileApptByTOD("AM"),
|
||||||
this.getFirstAvailableApptByTOD("PM", "mobile"),
|
this.getFirstAvailableMobileApptByTOD("PM"),
|
||||||
this.getFirstAvailableApptByTOD("AM", "inshop"),
|
this.getFirstAvailableInshopApptByTOD("AM"),
|
||||||
this.getFirstAvailableApptByTOD("PM", "inshop"),
|
this.getFirstAvailableInshopApptByTOD("PM"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Extract dates
|
// Extract dates
|
||||||
|
|
@ -2210,15 +2210,35 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getFirstAvailableApptByTOD(timeOfDay, appointmentType) {
|
async getFirstAvailableMobileApptByTOD(timeOfDay) {
|
||||||
let selectableDays;
|
const selectableDays = this.selectableDatesMobile?.days;
|
||||||
if (appointmentType?.toLowerCase() == "mobile") {
|
if (!selectableDays?.length) {
|
||||||
selectableDays = this.selectableDatesMobile?.days;
|
return null;
|
||||||
} else if (appointmentType?.toLowerCase() == "inshop") {
|
|
||||||
selectableDays = this.selectableDatesInshop?.days;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
for (const dateObj of selectableDays) {
|
||||||
|
let matchingTimeSlot = {
|
||||||
|
estimatedServiceMinutes: {
|
||||||
|
minimum: this.estimatedServiceMinutesMinimum,
|
||||||
|
maximum: this.estimatedServiceMinutesMaximum,
|
||||||
|
},
|
||||||
|
timeSlot: null,
|
||||||
|
date: null,
|
||||||
|
};
|
||||||
|
const isMatchingApptDay = dateObj.timeSlots.some(
|
||||||
|
(slot) =>
|
||||||
|
slot.id.includes(timeOfDay) &&
|
||||||
|
(matchingTimeSlot.timeSlot = slot) &&
|
||||||
|
(matchingTimeSlot.date = dateObj.date)
|
||||||
|
);
|
||||||
|
if (isMatchingApptDay && matchingTimeSlot) {
|
||||||
|
return matchingTimeSlot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
async getFirstAvailableInshopApptByTOD(timeOfDay) {
|
||||||
|
const selectableDays = this.selectableDatesInshop?.days;
|
||||||
if (!selectableDays?.length) {
|
if (!selectableDays?.length) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2239,7 +2259,6 @@ export default {
|
||||||
(matchingTimeSlot.date = dateObj.date)
|
(matchingTimeSlot.date = dateObj.date)
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
appointmentType?.toLowerCase() == "inshop" &&
|
|
||||||
this.selectedShopAnswer?.address1 &&
|
this.selectedShopAnswer?.address1 &&
|
||||||
this.selectedShopAnswer?.address2
|
this.selectedShopAnswer?.address2
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue