Merge branch '46-double-requests-in-room-occupancy' into 'main'

Resolve "double requests in  room occupancy"

Closes #46

See merge request ekresse/htwkalender!32
This commit is contained in:
ekresse
2024-03-26 23:03:59 +00:00

View File

@@ -28,9 +28,6 @@ type CalenderEvent = {
const date: Ref<Date> = ref(new Date()); const date: Ref<Date> = ref(new Date());
// Watch for changes in URL parameter
router.afterEach(setDateFromQuery);
// Set the selected date from the URL // Set the selected date from the URL
function setDateFromQuery() { function setDateFromQuery() {
const queryDate = router.currentRoute.value.query.date; const queryDate = router.currentRoute.value.query.date;
@@ -81,9 +78,9 @@ async function getOccupation() {
showFree: event.free, showFree: event.free,
}; };
}); });
})
const calendar = fullCalendar.value?.getApi(); .finally(() => {
calendar?.refetchEvents(); fullCalendar.value?.getApi().refetchEvents();
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
@@ -157,7 +154,7 @@ const calendarOptions: ComputedRef<CalendarOptions> = computed(() => ({
router.replace({ router.replace({
query: { query: {
...router.currentRoute.value.query, ...router.currentRoute.value.query,
date: formatYearMonthDay(startDate), date: formatYearMonthDay(endDate),
}, },
}); });
getOccupation(); getOccupation();