Skip to content

Commit 7115222

Browse files
authored
Merge pull request #142 from adamspd/139-duplicate-slots
Fix duplicate slots when concurring request are sent
2 parents e08a95e + 6c6f166 commit 7115222

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

appointment/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
__package_name__ = "django-appointment"
66
__url__ = "https://github.com/adamspd/django-appointment"
77
__package_website__ = "https://django-appt.adamspierredavid.com/"
8-
__version__ = "3.3.5"
8+
__version__ = "3.3.6"
99
__test_version__ = False

appointment/static/js/appointments.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let nonWorkingDays = [];
55
let selectedDate = rescheduledDate || null;
66
let staffId = $('#staff_id').val() || null;
77
let previouslySelectedCell = null;
8+
let isRequestInProgress = false;
89

910
const calendar = new FullCalendar.Calendar(calendarEl, {
1011
initialView: 'dayGridMonth',
@@ -203,6 +204,11 @@ function formatTime(date) {
203204
}
204205

205206
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+
206212
// Update the slot list with the available slots for the selected date
207213
const slotList = $('#slot-list');
208214
const slotContainer = $('.slot-container');
@@ -305,6 +311,10 @@ function getAvailableSlots(selectedDate, staffId = null) {
305311
// Update the date chosen
306312
$('.djangoAppt_date_chosen').text(data.date_chosen);
307313
$('#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
308318
}
309319
});
310320
}

0 commit comments

Comments
 (0)