Fixed loading error with calendar store

This commit is contained in:
Alexis
2024-05-18 15:45:17 +02:00
parent 059edd6fc1
commit 471df5e559
5 changed files with 53 additions and 56 deletions

View File

@@ -17,33 +17,12 @@ watch(user, (n, _o) => {
})
const sidebarMenu: MenuItem[] = []
const route = useRoute()
const worldId = route.params.id
const { setMonths } = useCalendar()
const { months } = storeToRefs(useCalendar())
const { data: calendar, pending, refresh } = await useLazyFetch(`/api/calendars/query?world_id=${worldId}`)
if (calendar.value?.data?.months) {
if (!calendar.value) {
await refresh()
} else {
setMonths(calendar.value?.data?.months)
}
}
</script>
<template>
<div class="h-full grid grid-cols-[auto_1fr]">
<Sidebar :menu-items="sidebarMenu" />
<template v-if="pending">
Loading
</template>
<template v-else>
<Calendar />
</template>
<Calendar />
</div>
</template>