diff --git a/components/Navigation.vue b/components/Navigation.vue index 7d77631..094a5ed 100644 --- a/components/Navigation.vue +++ b/components/Navigation.vue @@ -851,17 +851,35 @@ import { useRoute } from 'vue-router' import { Menu, X, ChevronDown } from 'lucide-vue-next' const route = useRoute() -const authStore = useAuthStore() const isMobileMenuOpen = ref(false) const mobileSubmenu = ref(null) const mannschaften = ref([]) const hasGalleryImages = ref(false) const showCmsDropdown = ref(false) -// Reactive auth state from store -const isLoggedIn = computed(() => authStore.isLoggedIn) -const isAdmin = computed(() => authStore.isAdmin) -const canAccessNewsletter = computed(() => authStore.hasAnyRole('admin', 'vorstand', 'newsletter')) +// Lazy store access to avoid Pinia initialization issues +const getAuthStore = () => { + try { + return useAuthStore() + } catch (e) { + // Fallback if Pinia is not yet initialized + return null + } +} + +// Reactive auth state from store (lazy) +const isLoggedIn = computed(() => { + const store = getAuthStore() + return store?.isLoggedIn ?? false +}) +const isAdmin = computed(() => { + const store = getAuthStore() + return store?.isAdmin ?? false +}) +const canAccessNewsletter = computed(() => { + const store = getAuthStore() + return store?.hasAnyRole('admin', 'vorstand', 'newsletter') ?? false +}) // Automatisches Setzen des Submenus basierend auf der Route const currentSubmenu = computed(() => { @@ -954,7 +972,10 @@ const handleDocumentClick = (e) => { onMounted(() => { loadMannschaften() checkGalleryImages() - authStore.checkAuth() + const store = getAuthStore() + if (store) { + store.checkAuth() + } // Close CMS dropdown when clicking outside document.addEventListener('click', handleDocumentClick) diff --git a/pages/registrieren.vue b/pages/registrieren.vue index c3c8ecc..a4abb72 100644 --- a/pages/registrieren.vue +++ b/pages/registrieren.vue @@ -87,18 +87,18 @@ -
Bitte prüfen Sie die Registrierung im CMS.
`