Import the window moment object

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

View file

@ -22,6 +22,9 @@ App.Http.Booking = (function () {
const $availableHours = $('#available-hours'); const $availableHours = $('#available-hours');
const $captchaHint = $('#captcha-hint'); const $captchaHint = $('#captcha-hint');
const $captchaTitle = $('.captcha-title'); const $captchaTitle = $('.captcha-title');
const moment = window.moment;
let unavailableDatesBackup; let unavailableDatesBackup;
let selectedDateStringBackup; let selectedDateStringBackup;
let processingUnavailableDates = false; let processingUnavailableDates = false;
@ -280,8 +283,9 @@ App.Http.Booking = (function () {
if (setDate && !vars('manage_mode')) { if (setDate && !vars('manage_mode')) {
for (let i = 1; i <= numberOfDays; i++) { for (let i = 1; i <= numberOfDays; i++) {
const currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i); const currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) { if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
$('#select-date')[0]._flatpickr.setDate( currentDate); $('#select-date')[0]._flatpickr.setDate(currentDate);
getAvailableHours(moment(currentDate).format('YYYY-MM-DD')); getAvailableHours(moment(currentDate).format('YYYY-MM-DD'));
break; break;
} }