Preselect the date with a query parameter (#1376)

This commit is contained in:
Alex Tselegidis 2023-07-03 10:05:20 +02:00
parent 66dfd36d6d
commit 4d58075ef7

View file

@ -300,6 +300,16 @@ App.Http.Booking = (function () {
// Grey out unavailable dates. // Grey out unavailable dates.
$('#select-date')[0]._flatpickr.set('disable', unavailableDates.map(unavailableDate => new Date(unavailableDate))); $('#select-date')[0]._flatpickr.set('disable', unavailableDates.map(unavailableDate => new Date(unavailableDate)));
const dateQueryParam = App.Utils.Url.queryParam('date');
if (dateQueryParam) {
const dateQueryParamMoment = moment(dateQueryParam);
if (dateQueryParamMoment.isValid() && !unavailableDates.includes(dateQueryParam) && dateQueryParamMoment.format('YYYY-MM') === selectedDateMoment.format('YYYY-MM')) {
$('#select-date')[0]._flatpickr.setDate(dateQueryParamMoment.toDate());
}
}
processingUnavailableDates = false; processingUnavailableDates = false;
} }