From 3f201b90e3a00401cf90f18abcdd8a5aa4f2df3f Mon Sep 17 00:00:00 2001
From: Alexis <35.alexis.pele@gmail.com>
Date: Sun, 25 Aug 2024 18:24:59 +0200
Subject: [PATCH] Refactored user menu and titles
---
components/global/user/CTA.vue | 120 +++++++++++++++++++++++++--------
pages/index.vue | 3 +-
pages/my/calendars/[id].vue | 11 +--
pages/my/index.vue | 9 +--
pages/my/worlds/[id].vue | 2 +-
5 files changed, 105 insertions(+), 40 deletions(-)
diff --git a/components/global/user/CTA.vue b/components/global/user/CTA.vue
index 726f696..ef8e109 100644
--- a/components/global/user/CTA.vue
+++ b/components/global/user/CTA.vue
@@ -1,9 +1,10 @@
diff --git a/pages/my/calendars/[id].vue b/pages/my/calendars/[id].vue
index 4883481..b8a9f11 100644
--- a/pages/my/calendars/[id].vue
+++ b/pages/my/calendars/[id].vue
@@ -3,9 +3,6 @@ import { PhCircleNotch } from "@phosphor-icons/vue";
import type { Calendar } from "~/models/CalendarConfig";
import type { Category } from "~/models/Category";
-useHead({
- title: "Calendrier"
-})
definePageMeta({
middleware: ["auth-guard"]
})
@@ -21,11 +18,15 @@ watch(user, (n) => {
const route = useRoute()
const id = route.params.id
-const { data: calendarData, pending: calPending } = useLazyFetch("/api/calendars/query", { key: `calendar-${id}`, query: { id, full: true } })
-const { data: catData, pending: catPending } = useLazyFetch("/api/calendars/categories/query", { key: `categories-${id}` })
+const { data: calendarData, pending: calPending } = await useLazyFetch("/api/calendars/query", { key: `calendar-${id}`, query: { id, full: true } })
+const { data: catData, pending: catPending } = await useLazyFetch("/api/calendars/categories/query", { key: `categories-${id}` })
const cal = computed(() => calendarData?.value?.data as Calendar)
const categories = computed(() => catData?.value?.data as Category[])
+
+useHead({
+ title: cal.value.name
+})
diff --git a/pages/my/index.vue b/pages/my/index.vue
index fffc952..79db25e 100644
--- a/pages/my/index.vue
+++ b/pages/my/index.vue
@@ -2,15 +2,16 @@
import type { RealtimeChannel } from "@supabase/supabase-js"
import type { World } from "~/models/World";
+useHead({
+ title: "Mondes"
+})
+
const supabase = useSupabaseClient()
const { data: res } = await useFetch("/api/worlds/query")
const worlds = ref(res.value?.data as World[])
-useHead({
- title: "Profil"
-})
definePageMeta({
middleware: ["auth-guard"]
})
@@ -18,7 +19,7 @@ definePageMeta({
const user = useSupabaseUser()
// Redirect user back home when they log out on the page
-watch(user, (n, _o) => {
+watch(user, (n) => {
if (!n) {
navigateTo("/")
}
diff --git a/pages/my/worlds/[id].vue b/pages/my/worlds/[id].vue
index 01ef662..8121317 100644
--- a/pages/my/worlds/[id].vue
+++ b/pages/my/worlds/[id].vue
@@ -13,7 +13,7 @@ const { data: res, pending } = await useFetch("/api/worlds/query", { query: { id
const world = ref(res.value?.data as World)
useHead({
- title: "Profil"
+ title: world.value.name
})
definePageMeta({
middleware: ["auth-guard"]