From 230f052b9a9183959d01c32efbd6608312747883 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Thu, 4 May 2023 17:48:48 +0200 Subject: [PATCH] Correct the min date of the booking datepicker so that it accepts the current date as a selection --- assets/js/pages/booking.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/js/pages/booking.js b/assets/js/pages/booking.js index fa366dc8..f7c55f0b 100644 --- a/assets/js/pages/booking.js +++ b/assets/js/pages/booking.js @@ -84,7 +84,7 @@ App.Pages.Booking = (function () { App.Utils.UI.initializeDatepicker($selectDate, { 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(), onChange: (selectedDates) => { 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 isTimezoneSupported = $selectTimezone.find(`option[value="${browserTimezone}"]`).length > 0; $selectTimezone.val(isTimezoneSupported ? browserTimezone : 'UTC'); @@ -231,7 +233,7 @@ App.Pages.Booking = (function () { $(controlEl).parent().insertAfter($firstColControls.last().parent()); }); } - + // Hide columns that do not have any controls displayed. const $fieldCols = $(document).find('#wizard-frame-3 .field-col');