Do not save the unavailability if no provider was selected

This commit is contained in:
Alex Tselegidis 2023-10-09 16:50:23 +02:00
parent b88952497c
commit 482b0077cd

View file

@ -65,6 +65,11 @@ App.Components.UnavailabilitiesModal = (function () {
$unavailabilitiesModal.find('.modal-message').addClass('d-none'); $unavailabilitiesModal.find('.modal-message').addClass('d-none');
$unavailabilitiesModal.find('.is-invalid').removeClass('is-invalid'); $unavailabilitiesModal.find('.is-invalid').removeClass('is-invalid');
if (!$selectProvider.val()) {
$selectProvider.addClass('is-invalid');
return;
}
const startMoment = moment($startDatetime[0]._flatpickr.selectedDates[0]); const startMoment = moment($startDatetime[0]._flatpickr.selectedDates[0]);
if (!startMoment.isValid()) { if (!startMoment.isValid()) {
@ -100,7 +105,7 @@ App.Components.UnavailabilitiesModal = (function () {
start_datetime: startMoment.format('YYYY-MM-DD HH:mm:ss'), start_datetime: startMoment.format('YYYY-MM-DD HH:mm:ss'),
end_datetime: endMoment.format('YYYY-MM-DD HH:mm:ss'), end_datetime: endMoment.format('YYYY-MM-DD HH:mm:ss'),
notes: $unavailabilitiesModal.find('#unavailability-notes').val(), notes: $unavailabilitiesModal.find('#unavailability-notes').val(),
id_users_provider: $('#unavailability-provider').val() id_users_provider: $selectProvider.val()
}; };
if ($id.val() !== '') { if ($id.val() !== '') {