From 23261aab51cf121effd63dd85b3c875ea10b95da Mon Sep 17 00:00:00 2001 From: Till JS Date: Wed, 25 Mar 2026 09:25:47 +0100 Subject: [PATCH] fix(manacore): address critical production readiness issues 1. Admin role gate: Nav link only shows for admin role users, admin layout redirects non-admins to /home with access denied message 2. Profile update: Replace stubbed setTimeout with real API call to profileService.updateProfile(), add empty name validation 3. Error boundaries: Wrap each dashboard widget in svelte:boundary with error UI showing widget name, error message, retry button 4. Payment page: Replace alert() with toast notification for unfinished payment integration (no more browser alerts) 5. Form validation: Add name validation in profile update Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/dashboard/DashboardGrid.svelte | 24 ++++- .../apps/web/src/routes/(app)/+layout.svelte | 14 ++- .../web/src/routes/(app)/admin/+layout.svelte | 102 ++++++++++-------- .../web/src/routes/(app)/mana/+page.svelte | 19 +++- .../src/routes/(app)/settings/+page.svelte | 10 +- 5 files changed, 112 insertions(+), 57 deletions(-) diff --git a/apps/manacore/apps/web/src/lib/components/dashboard/DashboardGrid.svelte b/apps/manacore/apps/web/src/lib/components/dashboard/DashboardGrid.svelte index 497862079..846b67d5d 100644 --- a/apps/manacore/apps/web/src/lib/components/dashboard/DashboardGrid.svelte +++ b/apps/manacore/apps/web/src/lib/components/dashboard/DashboardGrid.svelte @@ -46,7 +46,29 @@ > {#each items as widget (widget.id)}
- + + + {#snippet failed(error, reset)} +
+
⚠️
+

+ {widget.id} fehlgeschlagen +

+

+ {error?.message || 'Unbekannter Fehler'} +

+ +
+ {/snippet} +
{/each} diff --git a/apps/manacore/apps/web/src/routes/(app)/+layout.svelte b/apps/manacore/apps/web/src/routes/(app)/+layout.svelte index a43743fc0..23fb3b07a 100644 --- a/apps/manacore/apps/web/src/routes/(app)/+layout.svelte +++ b/apps/manacore/apps/web/src/routes/(app)/+layout.svelte @@ -80,8 +80,7 @@ let userEmail = $derived(authStore.user?.email); // Navigation items for ManaCore - // Admin link is conditionally added based on user role - let baseNavItems: PillNavItem[] = [ + const baseNavItems: PillNavItem[] = [ { href: '/home', label: 'Home', icon: 'home' }, { href: '/dashboard', label: 'Dashboard', icon: 'grid' }, { href: '/observatory', label: 'Observatory', icon: 'eye' }, @@ -92,12 +91,11 @@ { href: '/settings', label: 'Settings', icon: 'settings' }, ]; - // TODO: Check user role from authStore and add admin link if admin - // For now, always show admin link for testing - const navItems: PillNavItem[] = [ - ...baseNavItems, - { href: '/admin', label: 'Admin', icon: 'shield' }, - ]; + // Only show admin link if user has admin role + let isAdmin = $derived(authStore.user?.role === 'admin'); + let navItems = $derived( + isAdmin ? [...baseNavItems, { href: '/admin', label: 'Admin', icon: 'shield' }] : baseNavItems + ); // Navigation shortcuts (Ctrl+1-5) const navRoutes = navItems.map((item) => item.href); diff --git a/apps/manacore/apps/web/src/routes/(app)/admin/+layout.svelte b/apps/manacore/apps/web/src/routes/(app)/admin/+layout.svelte index cd70b93cb..71b63cf33 100644 --- a/apps/manacore/apps/web/src/routes/(app)/admin/+layout.svelte +++ b/apps/manacore/apps/web/src/routes/(app)/admin/+layout.svelte @@ -1,9 +1,19 @@ -
-
-
-

Admin Dashboard

-

System monitoring and management

-
-
- - - - Admin -
+{#if !isAdmin} +
+
🔒
+

Zugriff verweigert

+

Du hast keine Admin-Berechtigung.

- - + Admin +
+
-
- {@render children()} + + +
+ {@render children()} +
- +{/if} diff --git a/apps/manacore/apps/web/src/routes/(app)/mana/+page.svelte b/apps/manacore/apps/web/src/routes/(app)/mana/+page.svelte index dc73c0c2b..41f763cb7 100644 --- a/apps/manacore/apps/web/src/routes/(app)/mana/+page.svelte +++ b/apps/manacore/apps/web/src/routes/(app)/mana/+page.svelte @@ -1,14 +1,16 @@ @@ -16,6 +18,15 @@ Mana - ManaCore + +{#if toastMessage} +
+ {toastMessage} +
+{/if} +
setTimeout(resolve, 500)); + await profileService.updateProfile({ name }); profileSuccess = true; ManaCoreEvents.profileUpdated(); } catch (e) {