Skip to content

Commit

Permalink
fix(ZMS-3436): attempt fix for multi click appointment slot
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Fink authored and Tom Fink committed Nov 25, 2024
1 parent ac66a9a commit 1d9cdf0
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions frontend/src/components/TheCalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@
<h4 class="time-hour" tabindex="0">
{{ times[0].format('H') }}:00-{{ times[0].format('H') }}:59
</h4>
<div class="select-appointment" tabindex="0" v-for="timeSlot in times" :key="timeSlot.unix()"
<div class="select-appointment" :class="{ 'disabled': isLoading }" tabindex="0" v-for="timeSlot in times" :key="timeSlot.unix()"
v-on:keyup.enter="handleTimeSlotSelection(timeSlot)"
v-on:keyup.space="handleTimeSlotSelection(timeSlot)" @click="handleTimeSlotSelection(timeSlot)">
{{ timeSlot.format('H:mm') }}
<v-progress-circular
v-if="isLoading && selectedTimeSlot && selectedTimeSlot.unix() === timeSlot.unix()"
indeterminate
size="16"
width="2"
color="primary"
class="ms-2"
></v-progress-circular>
</div>
</div>
<v-col
Expand Down Expand Up @@ -138,7 +146,8 @@ export default {
selectedTimeSlot: null,
captchaKey: 0,
captchaSolution: null,
appointmentCounts: []
appointmentCounts: [],
isLoading: false
}),
computed: {
captchaDetails() {
Expand Down Expand Up @@ -248,12 +257,17 @@ export default {
})
},
handleTimeSlotSelection: function (timeSlot) {
if (this.isLoading) {
console.log("nope");
return;
}
this.selectedTimeSlot = timeSlot;
this.showCaptcha = this.captchaDetails.captchaEnabled && (this.provider.scope) && (this.provider.scope.captchaActivatedRequired) && (this.provider.scope.captchaActivatedRequired === '1');
if (this.showCaptcha) {
this.captchaKey += 1;
this.captchaSolution = null;
} else {
this.isLoading = true;
this.chooseAppointment(timeSlot);
}
},
Expand Down Expand Up @@ -289,9 +303,13 @@ export default {
this.$store.commit('data/setAppointment', appointment)
this.$emit('next')
window.scrollTo(0, 0)
}, () => {
this.timeSlotError = this.$t('noAppointmentsAvailable')
})
.catch(() => {
this.timeSlotError = this.$t('noAppointmentsAvailable')
})
.finally(() => {
this.isLoading = false
});
if (!this.timeSlotError && oldAppointment && !this.$store.state.isRebooking) {
this.$store.dispatch('API/cancelAppointment', oldAppointment)
Expand Down Expand Up @@ -346,6 +364,7 @@ export default {
},
handleCaptchaError(error) {
console.error("Captcha error:", error);
this.isLoading = false;
// Handle the error, possibly show a message to the user
}
},
Expand Down Expand Up @@ -425,6 +444,12 @@ export default {
float: left;
}
.select-appointment.disabled {
opacity: 0.5;
cursor: not-allowed;
pointer-events: none;
}
.v-picker {
margin-top: 0 !important;
}
Expand Down

0 comments on commit 1d9cdf0

Please sign in to comment.