Correct the min date of the booking datepicker so that it accepts the current date as a selection

This commit is contained in:
Alex Tselegidis 2023-05-04 17:48:48 +02:00
parent f2c8df38b9
commit 230f052b9a

View file

@ -84,7 +84,7 @@ App.Pages.Booking = (function () {
App.Utils.UI.initializeDatepicker($selectDate, { App.Utils.UI.initializeDatepicker($selectDate, {
inline: true, inline: true,
minDate: new Date(), minDate: moment().subtract(1, 'day').set({hours: 23, minutes: 59, seconds: 59}).toDate(),
maxDate: moment().add(vars('future_booking_limit'), 'days').toDate(), maxDate: moment().add(vars('future_booking_limit'), 'days').toDate(),
onChange: (selectedDates) => { onChange: (selectedDates) => {
App.Http.Booking.getAvailableHours(moment(selectedDates[0]).format('YYYY-MM-DD')); App.Http.Booking.getAvailableHours(moment(selectedDates[0]).format('YYYY-MM-DD'));
@ -116,6 +116,8 @@ App.Pages.Booking = (function () {
}, },
}); });
$selectDate[0]._flatpickr.setDate(new Date());
const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; const browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const isTimezoneSupported = $selectTimezone.find(`option[value="${browserTimezone}"]`).length > 0; const isTimezoneSupported = $selectTimezone.find(`option[value="${browserTimezone}"]`).length > 0;
$selectTimezone.val(isTimezoneSupported ? browserTimezone : 'UTC'); $selectTimezone.val(isTimezoneSupported ? browserTimezone : 'UTC');