From d6d173d08767beba9897d56a12cd796c9cbb291b Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Fri, 28 Feb 2025 13:42:09 +0100 Subject: [PATCH 1/6] Fixed loading syntax for calendar --- pages/calendars/[id].vue | 33 +++++++++++++++++++++++++++------ pages/my/calendars/[id].vue | 33 +++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/pages/calendars/[id].vue b/pages/calendars/[id].vue index 95d527a..29f0786 100644 --- a/pages/calendars/[id].vue +++ b/pages/calendars/[id].vue @@ -8,8 +8,29 @@ const shortId = route.params.id const user = useSupabaseUser() -const { data: calendarData, pending: calPending, refresh: calRefresh } = await useLazyFetch<{ data: Calendar }>("/api/calendars/query", { query: { shortId, full: true } }) -const { data: catData, pending: catPending, refresh: catRefresh } = await useLazyFetch<{ data: Category[] }>("/api/calendars/categories/query") +const { + data: calendar, + status: calendarStatus, + refresh: calRefresh +} = await useLazyFetch<{ data: Calendar }>("/api/calendars/query", + { + key: `calendar-${shortId}`, + query: { + shortId, + full: true + } + } +) + +const { + data: categories, + status: categoriesStatus, + refresh: catRefresh +} = await useLazyFetch<{ data: Category[] }>("/api/calendars/categories/query", + { key: `categories-${shortId}` } +) + +const isLoading = computed(() => calendarStatus.value === "pending" || categoriesStatus.value === "pending") watch(user, () => { calRefresh() @@ -18,7 +39,7 @@ watch(user, () => { diff --git a/pages/my/worlds/[id].vue b/pages/my/worlds/[id].vue index 39e84e6..992f05d 100644 --- a/pages/my/worlds/[id].vue +++ b/pages/my/worlds/[id].vue @@ -2,7 +2,7 @@ import type { RealtimeChannel } from "@supabase/supabase-js" import type { World } from "~/models/World"; import type { Calendar } from "~/models/CalendarConfig"; -import { PhPlus, PhTrash } from "@phosphor-icons/vue"; +import { PhArrowBendDoubleUpLeft, PhGlobeHemisphereWest, PhPlus, PhTrash } from "@phosphor-icons/vue"; const supabase = useSupabaseClient() const route = useRoute() @@ -112,7 +112,7 @@ function hideDeleteModal() { {{ $t('entity.isLoading') }} - From 04940aacc3b9ed1cfa5a9b7791b86b0f9f46031a Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Fri, 28 Feb 2025 17:25:03 +0100 Subject: [PATCH 5/6] Formatted data calls and removed svg bg --- pages/my/index.vue | 48 +++++++++++----------------------------- pages/my/worlds/[id].vue | 26 ---------------------- public/images/galaxy.svg | 28 ----------------------- public/images/planet.svg | 1 - 4 files changed, 13 insertions(+), 90 deletions(-) delete mode 100644 public/images/galaxy.svg delete mode 100644 public/images/planet.svg diff --git a/pages/my/index.vue b/pages/my/index.vue index 7ed7f45..1471b8a 100644 --- a/pages/my/index.vue +++ b/pages/my/index.vue @@ -5,9 +5,7 @@ import type { World } from "~/models/World"; const supabase = useSupabaseClient() -const { data: res } = await useFetch("/api/worlds/query") - -const worlds = ref(res.value?.data as World[]) +const { data: worlds } = await useLazyFetch<{ data: World[] }>("/api/worlds/query") definePageMeta({ middleware: ["auth-guard"] @@ -36,8 +34,10 @@ let worldChannel: RealtimeChannel /** Handles world insertion realtime events */ function handleInsertedWorld(newWorld: World) { + if (!worlds.value?.data) return + try { - worlds.value.push(newWorld) + worlds.value?.data.push(newWorld) } catch (err) { console.log(err) } @@ -45,8 +45,10 @@ function handleInsertedWorld(newWorld: World) { /** Handles world deletion realtime events */ function handleDeletedWorld(id: number) { + if (!worlds.value?.data) return + try { - worlds.value.splice(worlds.value.findIndex(w => w.id === id)) + worlds.value.data.splice(worlds.value.data.findIndex(w => w.id === id)) } catch (err) { console.log(err) } @@ -68,7 +70,9 @@ onMounted(() => { break case "UPDATE": - worlds.value = (await $fetch("/api/worlds/query")).data as World[] + if (!worlds.value?.data) return + + worlds.value.data = (await $fetch("/api/worlds/query")).data as World[] break default: @@ -101,7 +105,7 @@ function hideDeleteModal() { - - diff --git a/pages/my/worlds/[id].vue b/pages/my/worlds/[id].vue index 992f05d..a19dd3b 100644 --- a/pages/my/worlds/[id].vue +++ b/pages/my/worlds/[id].vue @@ -208,29 +208,3 @@ function hideDeleteModal() { - - diff --git a/public/images/galaxy.svg b/public/images/galaxy.svg deleted file mode 100644 index 9f7e863..0000000 --- a/public/images/galaxy.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - diff --git a/public/images/planet.svg b/public/images/planet.svg deleted file mode 100644 index f632d3d..0000000 --- a/public/images/planet.svg +++ /dev/null @@ -1 +0,0 @@ - From fe035da7c343151486cfd84c366399750c023784 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Fri, 28 Feb 2025 19:24:53 +0100 Subject: [PATCH 6/6] Added edit world functions --- components/world/dialog/Edit.vue | 53 +++++++++++++++ components/world/form/Edit.vue | 113 +++++++++++++++++++++++++++++++ i18n.config.ts | 14 ++++ models/World.ts | 4 ++ pages/my/index.vue | 30 ++++++-- server/api/worlds/[id].patch.ts | 77 +++++++++++++++++++++ 6 files changed, 285 insertions(+), 6 deletions(-) create mode 100644 components/world/dialog/Edit.vue create mode 100644 components/world/form/Edit.vue create mode 100644 server/api/worlds/[id].patch.ts diff --git a/components/world/dialog/Edit.vue b/components/world/dialog/Edit.vue new file mode 100644 index 0000000..1487278 --- /dev/null +++ b/components/world/dialog/Edit.vue @@ -0,0 +1,53 @@ + + + diff --git a/components/world/form/Edit.vue b/components/world/form/Edit.vue new file mode 100644 index 0000000..fe8d1ba --- /dev/null +++ b/components/world/form/Edit.vue @@ -0,0 +1,113 @@ + + +