Watched for user change in the page instead

This commit is contained in:
Alexis
2024-12-20 11:41:17 +01:00
parent 3db1654682
commit 91048d1b8e

View File

@@ -6,11 +6,18 @@ import type { Category } from "~/models/Category";
const route = useRoute()
const shortId = route.params.id
const { data: calendarData, pending: calPending } = await useLazyFetch("/api/calendars/query", { key: `calendar-${shortId}`, query: { shortId, full: true } })
const { data: catData, pending: catPending } = await useLazyFetch("/api/calendars/categories/query", { key: `categories-${shortId}` })
const user = useSupabaseUser()
const { data: calendarData, pending: calPending, refresh: calRefresh } = await useLazyFetch("/api/calendars/query", { key: `calendar-${shortId}`, query: { shortId, full: true } })
const { data: catData, pending: catPending, refresh: catRefresh } = await useLazyFetch("/api/calendars/categories/query", { key: `categories-${shortId}` })
const cal = computed<Calendar>(() => calendarData?.value?.data as Calendar)
const categories = computed<Category[]>(() => catData?.value?.data as Category[])
watch(user, () => {
calRefresh()
catRefresh()
})
</script>
<template>