From 9491ff26d803d2a0663c7a9e7348878ab271f375 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Sun, 21 Dec 2025 23:01:56 +0100 Subject: [PATCH] mod layout --- .../Components/Layout/MainLayout.razor | 42 ++++++++++++++++++- .../Components/Layout/NavMenu.razor | 36 ++++++++++++++++ src/Koogle.Web/Store/AuthState/AuthActions.cs | 5 +++ .../Store/AuthState/AuthReducers.cs | 10 +++++ src/Koogle.Web/Store/AuthState/AuthState.cs | 4 ++ src/KoogleApp/KoogleApp.csproj | 2 +- 6 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 src/Koogle.Web/Components/Layout/NavMenu.razor diff --git a/src/Koogle.Web/Components/Layout/MainLayout.razor b/src/Koogle.Web/Components/Layout/MainLayout.razor index 7577643..00eb08f 100644 --- a/src/Koogle.Web/Components/Layout/MainLayout.razor +++ b/src/Koogle.Web/Components/Layout/MainLayout.razor @@ -1,5 +1,8 @@ @inherits FluxorLayout +@inject IState AuthState +@inject IDispatcher Dispatcher + @* Required *@ @@ -12,7 +15,35 @@ @* Needed for snackbars *@ -@Body + + + + + + + + + + + + @if (AuthState.Value.Error is not null) + { + + @AuthState.Value.Error + + } + @Body + + + +
An unhandled error has occurred. @@ -23,6 +54,8 @@ @code { + private bool _drawerOpen = true; + private bool _isDarkMode = false; private readonly MudTheme _theme = new() @@ -63,7 +96,12 @@ // } }; - // private void ToggleDrawer() => _drawerOpen = !_drawerOpen; + private void ClearAuthError() + { + Dispatcher.Dispatch(new ClearAuthErrorAction()); + } + + private void ToggleDrawer() => _drawerOpen = !_drawerOpen; private void ToggleDarkMode() => _isDarkMode = !_isDarkMode; diff --git a/src/Koogle.Web/Components/Layout/NavMenu.razor b/src/Koogle.Web/Components/Layout/NavMenu.razor new file mode 100644 index 0000000..7248906 --- /dev/null +++ b/src/Koogle.Web/Components/Layout/NavMenu.razor @@ -0,0 +1,36 @@ +@inherits FluxorComponent + +@inject IState AuthState +@inject NavigationManager NavigationManager + + + @if (AuthState.Value.IsClubEditor || AuthState.Value.IsSuperAdmin) + { + @* // Tage und Auswertungen des ausgewählten Vereins *@ + + + + + + + @* // Stammdaten des ausgewählten Vereins *@ + + @* // mandantenübergreifende Verwaltung *@ + @if (AuthState.Value.IsSuperAdmin) + { + + Vereine verwalten + + } + + + } + + +@code { + +} diff --git a/src/Koogle.Web/Store/AuthState/AuthActions.cs b/src/Koogle.Web/Store/AuthState/AuthActions.cs index 9276709..c040df4 100644 --- a/src/Koogle.Web/Store/AuthState/AuthActions.cs +++ b/src/Koogle.Web/Store/AuthState/AuthActions.cs @@ -22,4 +22,9 @@ namespace Koogle.Web.Store.AuthState /// Action to initialize authentication state (load current user and permissions). /// public record InitializeAuthAction; + + /// + /// Action to clear the current error message. + /// + public record ClearAuthErrorAction; } diff --git a/src/Koogle.Web/Store/AuthState/AuthReducers.cs b/src/Koogle.Web/Store/AuthState/AuthReducers.cs index 44712e3..14e8997 100644 --- a/src/Koogle.Web/Store/AuthState/AuthReducers.cs +++ b/src/Koogle.Web/Store/AuthState/AuthReducers.cs @@ -66,4 +66,14 @@ public static class AuthReducers IsLoading = false, IsAuthenticated = false }; + + /// + /// Handles the ClearAuthErrorAction. + /// + [ReducerMethod(typeof(ClearAuthErrorAction))] + public static AuthState OnClearError(AuthState state) + => state with + { + Error = null + }; } diff --git a/src/Koogle.Web/Store/AuthState/AuthState.cs b/src/Koogle.Web/Store/AuthState/AuthState.cs index 64b7713..2ea7b5a 100644 --- a/src/Koogle.Web/Store/AuthState/AuthState.cs +++ b/src/Koogle.Web/Store/AuthState/AuthState.cs @@ -15,6 +15,10 @@ public record AuthState /// public bool IsAuthenticated { get; init; } + /// + /// Error message if authentication failed. + /// + public string? Error { get; init; } /// /// The current user's data. diff --git a/src/KoogleApp/KoogleApp.csproj b/src/KoogleApp/KoogleApp.csproj index 7571963..eedef92 100644 --- a/src/KoogleApp/KoogleApp.csproj +++ b/src/KoogleApp/KoogleApp.csproj @@ -31,7 +31,7 @@ - +