Select first service and provider if only one option exists

This commit is contained in:
Alex Tselegidis 2024-07-07 11:38:26 +02:00
parent 4c7696e877
commit 8dab03f38a

View file

@ -175,6 +175,7 @@ App.Pages.Booking = (function () {
// If the manage mode is true, the appointment data should be loaded by default.
if (manageMode) {
applyAppointmentData(vars('appointment_data'), vars('provider_data'), vars('customer_data'));
$('#wizard-frame-1')
.css({
'visibility': 'visible',
@ -213,6 +214,14 @@ App.Pages.Booking = (function () {
(selectedServiceId && selectedProviderId) ||
(vars('available_services').length === 1 && vars('available_providers').length === 1)
) {
if (!selectedServiceId) {
$selectService.val(vars('available_services')[0].id).trigger('change');
}
if (!selectedProviderId) {
$selectProvider.val(vars('available_providers')[0].id).trigger('change');
}
$('.active-step').removeClass('active-step');
$('#step-2').addClass('active-step');
$('#wizard-frame-1').hide();