Skip to content

Commit

Permalink
Merge pull request #5410 from nextcloud/fix/booking-loading
Browse files Browse the repository at this point in the history
Fix appointment booking loading
  • Loading branch information
hamza221 authored Aug 22, 2023
2 parents 79a24df + c4e760c commit 9f43c60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/components/Appointments/AppointmentDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>
<div class="buttons">
<NcLoadingIcon v-if="isLoading" :size="32" class="loading-icon" />
<NcButton type="primary" @click="save" :disabled="isLoading">
<NcButton type="primary" :disabled="isLoading" @click="save">
{{ $t('calendar', 'Book the appointment') }}
</NcButton>
</div>
Expand Down Expand Up @@ -114,14 +114,17 @@ export default {
required: true,
type: Boolean,
},
isLoading: {
required: true,
type: Boolean,
},
},
data() {
return {
description: '',
email: this.visitorInfo.email,
displayName: this.visitorInfo.displayName,
timeZone: this.timeZoneId,
isLoading: false,
}
},
computed: {
Expand All @@ -133,21 +136,15 @@ export default {
},
},
methods: {
async save() {
this.canClose = false
this.isLoading = true
try {
await this.$emit('save', {
slot: this.timeSlot,
description: this.description,
email: this.email,
displayName: this.displayName,
timeZone: this.timeZone,
})
} finally {
this.canClose = true
this.isLoading = false
}
save() {
this.$emit('save', {
slot: this.timeSlot,
description: this.description,
email: this.email,
displayName: this.displayName,
timeZone: this.timeZone,
})
},
},
}
Expand Down
6 changes: 6 additions & 0 deletions src/views/Appointments/Booking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
:visitor-info="visitorInfo"
:time-zone-id="timeZone"
:show-error="bookingError"
:is-loading="bookingLoading"
@save="onSave"
@close="selectedSlot = undefined" />
</div>
Expand Down Expand Up @@ -153,6 +154,7 @@ export default {
selectedSlot: undefined,
bookingConfirmed: false,
bookingError: false,
bookingLoading: false,
}
},
watch: {
Expand Down Expand Up @@ -204,6 +206,7 @@ export default {
}
},
async onSave({ slot, displayName, email, description, timeZone }) {
this.bookingLoading = true
console.info('slot will be booked', {
slot,
description,
Expand All @@ -223,7 +226,10 @@ export default {
} catch (e) {
console.error('could not book appointment', e)
this.bookingError = true
} finally {
this.bookingLoading = false
}
},
onSlotClicked(slot) {
this.selectedSlot = slot
Expand Down

0 comments on commit 9f43c60

Please sign in to comment.