@@ -5,6 +5,7 @@ let nonWorkingDays = [];
5
5
let selectedDate = rescheduledDate || null ;
6
6
let staffId = $ ( '#staff_id' ) . val ( ) || null ;
7
7
let previouslySelectedCell = null ;
8
+ let isRequestInProgress = false ;
8
9
9
10
const calendar = new FullCalendar . Calendar ( calendarEl , {
10
11
initialView : 'dayGridMonth' ,
@@ -203,6 +204,11 @@ function formatTime(date) {
203
204
}
204
205
205
206
function getAvailableSlots ( selectedDate , staffId = null ) {
207
+ if ( isRequestInProgress ) {
208
+ return ; // Exit the function if a request is already in progress
209
+ }
210
+ isRequestInProgress = true ;
211
+
206
212
// Update the slot list with the available slots for the selected date
207
213
const slotList = $ ( '#slot-list' ) ;
208
214
const slotContainer = $ ( '.slot-container' ) ;
@@ -305,6 +311,10 @@ function getAvailableSlots(selectedDate, staffId = null) {
305
311
// Update the date chosen
306
312
$ ( '.djangoAppt_date_chosen' ) . text ( data . date_chosen ) ;
307
313
$ ( '#service-datetime-chosen' ) . text ( data . date_chosen ) ;
314
+ isRequestInProgress = false ;
315
+ } ,
316
+ error : function ( ) {
317
+ isRequestInProgress = false ; // Ensure the flag is reset even if the request fails
308
318
}
309
319
} ) ;
310
320
}
0 commit comments