wip
This commit is contained in:
parent
abcf8ee75e
commit
12869e35bf
34 changed files with 1177 additions and 156 deletions
|
|
@ -1,90 +0,0 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace PlanTempus.Application.Features.Dashboard.Components;
|
||||
|
||||
/// <summary>
|
||||
/// ViewComponent for rendering a stat card on the dashboard.
|
||||
/// </summary>
|
||||
public class StatCardViewComponent : ViewComponent
|
||||
{
|
||||
public IViewComponentResult Invoke(string key)
|
||||
{
|
||||
var model = StatCardCatalog.Get(key);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ViewModel for the StatCard component.
|
||||
/// </summary>
|
||||
public class StatCardViewModel
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string Value { get; init; }
|
||||
public required string Label { get; init; }
|
||||
public string? TrendText { get; init; }
|
||||
public string? TrendIcon { get; init; }
|
||||
public string? TrendDirection { get; init; }
|
||||
public string? Variant { get; init; }
|
||||
public bool HasTrend => !string.IsNullOrEmpty(TrendText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Catalog of available stat cards with their data.
|
||||
/// </summary>
|
||||
public static class StatCardCatalog
|
||||
{
|
||||
private static readonly Dictionary<string, StatCardViewModel> Cards = new()
|
||||
{
|
||||
["bookings-today"] = new StatCardViewModel
|
||||
{
|
||||
Key = "bookings-today",
|
||||
Value = "12",
|
||||
Label = "Bookinger i dag",
|
||||
TrendText = "4 gennemført, 2 i gang",
|
||||
TrendIcon = "ph-check-circle",
|
||||
TrendDirection = "up",
|
||||
Variant = "highlight"
|
||||
},
|
||||
["expected-revenue"] = new StatCardViewModel
|
||||
{
|
||||
Key = "expected-revenue",
|
||||
Value = "8.450 kr",
|
||||
Label = "Forventet omsætning",
|
||||
TrendText = "+12% vs. gennemsnit",
|
||||
TrendIcon = "ph-trend-up",
|
||||
TrendDirection = "up",
|
||||
Variant = "success"
|
||||
},
|
||||
["occupancy-rate"] = new StatCardViewModel
|
||||
{
|
||||
Key = "occupancy-rate",
|
||||
Value = "78%",
|
||||
Label = "Belægningsgrad",
|
||||
TrendText = "God kapacitet",
|
||||
TrendIcon = "ph-trend-up",
|
||||
TrendDirection = "up",
|
||||
Variant = null
|
||||
},
|
||||
["needs-attention"] = new StatCardViewModel
|
||||
{
|
||||
Key = "needs-attention",
|
||||
Value = "4",
|
||||
Label = "Kræver opmærksomhed",
|
||||
TrendText = null,
|
||||
TrendIcon = null,
|
||||
TrendDirection = null,
|
||||
Variant = "warning"
|
||||
}
|
||||
};
|
||||
|
||||
public static StatCardViewModel Get(string key)
|
||||
{
|
||||
if (Cards.TryGetValue(key, out var card))
|
||||
return card;
|
||||
|
||||
throw new KeyNotFoundException($"StatCard with key '{key}' not found");
|
||||
}
|
||||
|
||||
public static IEnumerable<string> AllKeys => Cards.Keys;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue