This commit is contained in:
Janus C. H. Knudsen 2026-01-11 18:18:36 +01:00
parent abcf8ee75e
commit 12869e35bf
34 changed files with 1177 additions and 156 deletions

View file

@ -0,0 +1,6 @@
@model PlanTempus.Application.Features.Dashboard.Components.QuickStatViewModel
<swp-quick-stat data-key="@Model.Key">
<swp-stat-value>@Model.Value</swp-stat-value>
<swp-stat-label>@Model.Label</swp-stat-label>
</swp-quick-stat>

View file

@ -0,0 +1,69 @@
using Microsoft.AspNetCore.Mvc;
namespace PlanTempus.Application.Features.Dashboard.Components;
/// <summary>
/// ViewComponent for rendering a quick stat item in the sidebar.
/// </summary>
public class QuickStatViewComponent : ViewComponent
{
public IViewComponentResult Invoke(string key)
{
var model = QuickStatCatalog.Get(key);
return View(model);
}
}
/// <summary>
/// ViewModel for the QuickStat component.
/// </summary>
public class QuickStatViewModel
{
public required string Key { get; init; }
public required string Value { get; init; }
public required string Label { get; init; }
}
/// <summary>
/// Catalog of available quick stats with their data.
/// </summary>
public static class QuickStatCatalog
{
private static readonly Dictionary<string, QuickStatViewModel> 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<string> AllKeys => Stats.Keys;
}