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;
|
||||
const todaysDate = getTodayDate();
|
||||
let firstMobileAMAppt = await this.getFirstAvailableApptByTOD("AM", "mobile");
|
||||
let firstMobilePMAppt = await this.getFirstAvailableApptByTOD("PM", "mobile");
|
||||
let firstMobileAMAppt = await this.getFirstAvailableMobileApptByTOD("AM");
|
||||
let firstMobilePMAppt = await this.getFirstAvailableMobileApptByTOD("PM");
|
||||
if (!firstMobileAMAppt && !firstMobilePMAppt) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -2091,10 +2091,10 @@ export default {
|
|||
// Fetch all appointments
|
||||
const [firstMobileAMAppt, firstMobilePMAppt, firstInshopAMAppt, firstInshopPMAppt] =
|
||||
await Promise.all([
|
||||
this.getFirstAvailableApptByTOD("AM", "mobile"),
|
||||
this.getFirstAvailableApptByTOD("PM", "mobile"),
|
||||
this.getFirstAvailableApptByTOD("AM", "inshop"),
|
||||
this.getFirstAvailableApptByTOD("PM", "inshop"),
|
||||
this.getFirstAvailableMobileApptByTOD("AM"),
|
||||
this.getFirstAvailableMobileApptByTOD("PM"),
|
||||
this.getFirstAvailableInshopApptByTOD("AM"),
|
||||
this.getFirstAvailableInshopApptByTOD("PM"),
|
||||
]);
|
||||
|
||||
// Extract dates
|
||||
|
|
@ -2210,15 +2210,35 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
async getFirstAvailableApptByTOD(timeOfDay, appointmentType) {
|
||||
let selectableDays;
|
||||
if (appointmentType?.toLowerCase() == "mobile") {
|
||||
selectableDays = this.selectableDatesMobile?.days;
|
||||
} else if (appointmentType?.toLowerCase() == "inshop") {
|
||||
selectableDays = this.selectableDatesInshop?.days;
|
||||
async getFirstAvailableMobileApptByTOD(timeOfDay) {
|
||||
const selectableDays = this.selectableDatesMobile?.days;
|
||||
if (!selectableDays?.length) {
|
||||
return null;
|
||||
} 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) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
@ -2239,7 +2259,6 @@ export default {
|
|||
(matchingTimeSlot.date = dateObj.date)
|
||||
);
|
||||
if (
|
||||
appointmentType?.toLowerCase() == "inshop" &&
|
||||
this.selectedShopAnswer?.address1 &&
|
||||
this.selectedShopAnswer?.address2
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue