@page "/" @inject DashboardService Dash MeterVault — @S.Nav_Overview @S.Nav_Overview @if (_summary is null) { } else { @S.Dashboard_ThisMonth @Format.Euro(_summary.Month.Current) @S.Common_ThisYear @Format.Euro(_summary.Year.Current) @S.Dashboard_LatestMonthWithData @Format.Euro(_summary.LatestMonthCost) @S.Dashboard_WhatCostsMost @if (_breakdown is { Count: > 0 }) { @foreach (var slice in _breakdown) { @slice.Name @Format.Euro(slice.Cost) } } else { @S.Dashboard_NoCostData } @S.Dashboard_WhatChanged @S.Dashboard_ColCategory@S.Dashboard_ColCurrent@S.Dashboard_ColPreviousΔ @foreach (var row in _difference) { @row.Name @Format.Euro(row.Current) @Format.Euro(row.Previous) @Format.DirectionIcon(Math.Sign(row.Delta)) @Format.Euro(Math.Abs(row.Delta)) } } @code { private DashboardSummary? _summary; private IReadOnlyList _breakdown = []; private IReadOnlyList _difference = []; protected override async Task OnInitializedAsync() { var asOf = DateOnly.FromDateTime(DateTime.UtcNow); _summary = await Dash.GetSummaryAsync(asOf); var yearStart = new DateOnly(asOf.Year, 1, 1); _breakdown = await Dash.GetCategoryBreakdownAsync(yearStart, asOf.AddMonths(1)); _difference = await Dash.GetCategoryDifferenceAsync(yearStart, yearStart.AddYears(-1), asOf.AddMonths(1)); } }