Automatically select the next available date in the booking page or display a message if this month is unavailable (#1075) (#1204)
This commit is contained in:
parent
07ff42c1a4
commit
ebe087553e
2 changed files with 24 additions and 0 deletions
|
@ -709,6 +709,15 @@ class Booking extends EA_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
if (count($unavailable_dates) === $number_of_days_in_month)
|
||||
{
|
||||
json_response([
|
||||
'is_month_unavailable' => TRUE,
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_response($unavailable_dates);
|
||||
}
|
||||
catch (Throwable $e)
|
||||
|
|
|
@ -28,6 +28,7 @@ App.Http.Booking = (function () {
|
|||
let unavailableDatesBackup;
|
||||
let selectedDateStringBackup;
|
||||
let processingUnavailableDates = false;
|
||||
let searchedMonthCounter = 0;
|
||||
|
||||
/**
|
||||
* Get Available Hours
|
||||
|
@ -260,6 +261,20 @@ App.Http.Booking = (function () {
|
|||
data: data,
|
||||
dataType: 'json'
|
||||
}).done((response) => {
|
||||
if (response.is_month_unavailable) {
|
||||
if (searchedMonthCounter >= 3) {
|
||||
searchedMonthCounter = 0;
|
||||
return; // Stop searching
|
||||
}
|
||||
|
||||
searchedMonthCounter++;
|
||||
const selectedDateMoment = moment(selectedDateString);
|
||||
selectedDateMoment.add(1, 'month');
|
||||
const nextSelectedDate = selectedDateMoment.format('YYYY-MM-DD');
|
||||
getUnavailableDates(providerId, serviceId, nextSelectedDate);
|
||||
return;
|
||||
}
|
||||
|
||||
unavailableDatesBackup = response;
|
||||
selectedDateStringBackup = selectedDateString;
|
||||
applyUnavailableDates(response, selectedDateString, true);
|
||||
|
|
Loading…
Reference in a new issue