From fc9dfcaca0ae161d348bb3364c323ffa8839f6ce Mon Sep 17 00:00:00 2001 From: beo3000 Date: Thu, 1 Jan 2026 14:34:02 +0100 Subject: [PATCH] added club-settings: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neue Datei: src/Koogle.Web/Components/Pages/Settings.razor - Route /settings mit ClubAdmin-Policy - Zeigt Name, LoginName, Kostenberechnung - "Bearbeiten" Button öffnet bestehenden ClubEditDialog - Kein Löschen, keine Neuanlage Geändert: src/Koogle.Web/Components/Layout/NavMenu.razor - Neuer Link "Vereins-Einstellungen" in "Stammdaten"-Gruppe (Icon: Tune) --- .../Components/Layout/NavMenu.razor | 12 +- .../Components/Pages/Settings.razor | 137 ++++++++++++++++++ 2 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 src/Koogle.Web/Components/Pages/Settings.razor diff --git a/src/Koogle.Web/Components/Layout/NavMenu.razor b/src/Koogle.Web/Components/Layout/NavMenu.razor index 1cce34c..c044e55 100644 --- a/src/Koogle.Web/Components/Layout/NavMenu.razor +++ b/src/Koogle.Web/Components/Layout/NavMenu.razor @@ -44,7 +44,7 @@ - Auslöser + Ausl�ser Gifs - + + + Vereins-Einstellungen + + } } @@ -79,7 +85,7 @@ - Auslöser + Ausl�ser } diff --git a/src/Koogle.Web/Components/Pages/Settings.razor b/src/Koogle.Web/Components/Pages/Settings.razor new file mode 100644 index 0000000..d085ea4 --- /dev/null +++ b/src/Koogle.Web/Components/Pages/Settings.razor @@ -0,0 +1,137 @@ +@page "/settings" +@attribute [Authorize(Policy = "ClubAdmin")] + +@inherits Fluxor.Blazor.Web.Components.FluxorComponent + +@using Fluxor +@using Koogle.Application.DTOs +@using Koogle.Application.Interfaces +@using Koogle.Domain.Enums +@using Koogle.Web.Store.ClubState +@using Koogle.Web.Components.Pages.Admin +@using Microsoft.AspNetCore.Authorization + +@inject IClubService ClubService +@inject ICurrentClubContext CurrentClubContext +@inject IState ClubState +@inject IDispatcher Dispatcher +@inject ISnackbar Snackbar +@inject IDialogService DialogService + +Vereins-Einstellungen + +Vereins-Einstellungen + +@if (ClubState.Value.Error is not null) +{ + + @ClubState.Value.Error + +} + +@if (_isLoading) +{ + +} +else if (_club is null) +{ + Kein Club ausgewählt +} +else +{ + + + + + Name + @_club.Name + + + Login-Name + @_club.LoginName + + + Kostenberechnung + + @GetCalculationLabel(_club.ExpenseCalculation) + + + + + + + Bearbeiten + + + +} + +@code { + private ClubDto? _club; + private bool _isLoading = true; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + await LoadClubAsync(); + } + + private async Task LoadClubAsync() + { + _isLoading = true; + try + { + var clubId = CurrentClubContext.ClubId; + if (clubId != Guid.Empty) + { + _club = await ClubService.GetByIdAsync(clubId); + } + } + finally + { + _isLoading = false; + } + } + + private void ClearError() + { + Dispatcher.Dispatch(new ClearClubErrorAction()); + } + + private static string GetCalculationLabel(ExpenseCalculation calculation) => calculation switch + { + ExpenseCalculation.None => "Keine", + ExpenseCalculation.Average => "Durchschnitt", + ExpenseCalculation.Maximum => "Maximum", + _ => calculation.ToString() + }; + + private static Color GetCalculationColor(ExpenseCalculation calculation) => calculation switch + { + ExpenseCalculation.None => Color.Default, + ExpenseCalculation.Average => Color.Info, + ExpenseCalculation.Maximum => Color.Warning, + _ => Color.Default + }; + + private async Task OpenEditDialog() + { + if (_club is null) return; + + var parameters = new DialogParameters + { + { "Club", _club } + }; + + var dialog = await DialogService.ShowAsync("Vereins-Einstellungen bearbeiten", parameters); + var result = await dialog.Result; + + if (result != null && !result.Canceled && result.Data is UpdateClubDto dto) + { + Dispatcher.Dispatch(new UpdateClubAction(dto)); + Snackbar.Add("Einstellungen werden gespeichert...", Severity.Info); + await LoadClubAsync(); + } + } +}