From 76755a286d0cfab5a7b646d5ea455ad9df3658ea Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 31 Aug 2020 17:35:27 +0300 Subject: [PATCH] Properly set the selected date when editing an existing appointment in the booking page. --- assets/js/frontend_book.js | 2 +- assets/js/frontend_book_api.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/js/frontend_book.js b/assets/js/frontend_book.js index b2a2f913..c48c203e 100644 --- a/assets/js/frontend_book.js +++ b/assets/js/frontend_book.js @@ -690,7 +690,7 @@ window.FrontendBook = window.FrontendBook || {}; // Set Appointment Date $('#select-date').datepicker('setDate', Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss')); - FrontendBookApi.getAvailableHours($('#select-date').val()); + FrontendBookApi.getAvailableHours(moment(appointment.start_datetime).format('YYYY-MM-DD')); // Apply Customer's Data $('#last-name').val(customer.last_name); diff --git a/assets/js/frontend_book_api.js b/assets/js/frontend_book_api.js index dc2ef92c..df7f8e20 100755 --- a/assets/js/frontend_book_api.js +++ b/assets/js/frontend_book_api.js @@ -32,9 +32,9 @@ window.FrontendBookApi = window.FrontendBookApi || {}; * This function makes an AJAX call and returns the available hours for the selected service, * provider and date. * - * @param {String} selDate The selected date of which the available hours we need to receive. + * @param {String} selectedDate The selected date of the available hours we need. */ - exports.getAvailableHours = function (selDate) { + exports.getAvailableHours = function (selectedDate) { $('#available-hours').empty(); // Find the selected service duration (it is going to be send within the "data" object). @@ -61,7 +61,7 @@ window.FrontendBookApi = window.FrontendBookApi || {}; csrfToken: GlobalVariables.csrfToken, service_id: $('#select-service').val(), provider_id: $('#select-provider').val(), - selected_date: selDate, + selected_date: selectedDate, service_duration: serviceDuration, manage_mode: FrontendBook.manageMode, appointment_id: appointmentId @@ -117,7 +117,7 @@ window.FrontendBookApi = window.FrontendBookApi || {}; } var availableHourMoment = moment - .tz(selDate + ' ' + availableHour + ':00', providerTimezone) + .tz(selectedDate + ' ' + availableHour + ':00', providerTimezone) .tz(selectedTimezone); $('#available-hours div:eq(' + (currentColumn - 1) + ')').append(