@using Koogle.Application.DTOs @using Koogle.Application.Interfaces @inject IPlayerStatisticsService StatisticsService @inject ISnackbar Snackbar Kegelstatistik @DateTime.Now.Year @if (_isLoading) { } else if (_stats != null) { @if (_stats.TotalThrowsThisYear == 0) { Noch keine Statistiken vorhanden. Spiele ein paar Runden! } else {
@_stats.TotalGamesThisYear Spiele
@_stats.TotalThrowsThisYear Wuerfe
@_stats.TotalPinsThisYear Kegel
@_stats.ClubAverageThisYear.ToString("F2") Durchschnitt
@if (_stats.TopPerformers.Count > 0) { Top Kegler @{ var rank = 1; } @foreach (var performer in _stats.TopPerformers.Take(5)) {
@rank
@performer.PersonName @performer.TotalThrows Wuerfe, @performer.TotalPins Kegel
@performer.Average.ToString("F2")
rank++; }
} @if (_stats.MonthlyTrend.Count > 0) { Monatstrend Monat Spiele Wuerfe Durchschnitt @foreach (var month in _stats.MonthlyTrend.TakeLast(6)) { @GetMonthName(month.Month) @month.Games @month.Throws @month.Average.ToString("F2") } } } }
@code { private StatisticsWidgetDto? _stats; private bool _isLoading = true; protected override async Task OnInitializedAsync() { try { _stats = await StatisticsService.GetDashboardStatisticsAsync(); } catch (Exception ex) { Snackbar.Add($"Fehler beim Laden der Statistiken: {ex.Message}", Severity.Error); } finally { _isLoading = false; } } private static Color GetRankColor(int rank) => rank switch { 1 => Color.Warning, // Gold 2 => Color.Default, // Silver 3 => Color.Tertiary, // Bronze _ => Color.Default }; private static Color GetAverageColor(double average) => average switch { >= 7 => Color.Success, >= 5 => Color.Warning, _ => Color.Error }; private static string GetMonthName(int month) => month switch { 1 => "Jan", 2 => "Feb", 3 => "Mär", 4 => "Apr", 5 => "Mai", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Okt", 11 => "Nov", 12 => "Dez", _ => month.ToString() }; }