From 366156f5730c21e602e7513926f57262bad43009 Mon Sep 17 00:00:00 2001 From: Marieke Date: Mon, 13 May 2024 15:09:36 +0200 Subject: [PATCH] adminbutton fix --- frontend/src/composables/useNavigations.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/frontend/src/composables/useNavigations.ts b/frontend/src/composables/useNavigations.ts index 2fe01f71..fdb7a68d 100644 --- a/frontend/src/composables/useNavigations.ts +++ b/frontend/src/composables/useNavigations.ts @@ -1,4 +1,4 @@ -import { computed } from "vue"; +import { ref, watch } from "vue"; import useIsAdmin from "@/composables/useIsAdmin"; import { useAuthStore } from "@/stores/auth-store"; import { storeToRefs } from "pinia"; @@ -28,15 +28,19 @@ const admin_navigations: NavigationData[] = [ export default function useNavigations() { const { isLoggedIn } = storeToRefs(useAuthStore()); const { isAdmin } = useIsAdmin(); - const navigations = computed(() => { + const navigations = ref([]); + + const updateNavigations = async () => { if (!isLoggedIn.value) { - return noLoginNavigations; - } - const navs = main_navigations; - if (isAdmin.value) { - navs.push(...admin_navigations); + navigations.value = noLoginNavigations; + } else { + const navs = [...main_navigations]; + if (isAdmin.value) { + navs.push(...admin_navigations); + } + navigations.value = navs; } - return navs; - }); + }; + watch([isLoggedIn, isAdmin], updateNavigations, { immediate: true }); return { navigations }; }