using Microsoft.AspNetCore.Mvc; namespace PlanTempus.Application.Features.Dashboard.Components; /// /// ViewComponent for rendering a quick stat item in the sidebar. /// public class QuickStatViewComponent : ViewComponent { public IViewComponentResult Invoke(string key) { var model = QuickStatCatalog.Get(key); return View(model); } } /// /// ViewModel for the QuickStat component. /// public class QuickStatViewModel { public required string Key { get; init; } public required string Value { get; init; } public required string Label { get; init; } } /// /// Catalog of available quick stats with their data. /// public static class QuickStatCatalog { private static readonly Dictionary Stats = new() { ["bookings-week"] = new QuickStatViewModel { Key = "bookings-week", Value = "47", Label = "Bookinger" }, ["revenue-week"] = new QuickStatViewModel { Key = "revenue-week", Value = "38.200 kr", Label = "Omsætning" }, ["new-customers"] = new QuickStatViewModel { Key = "new-customers", Value = "8", Label = "Nye kunder" }, ["avg-occupancy"] = new QuickStatViewModel { Key = "avg-occupancy", Value = "72%", Label = "Gns. belægning" } }; public static QuickStatViewModel Get(string key) { if (Stats.TryGetValue(key, out var stat)) return stat; throw new KeyNotFoundException($"QuickStat with key '{key}' not found"); } public static IEnumerable AllKeys => Stats.Keys; }