wip
This commit is contained in:
parent
abcf8ee75e
commit
12869e35bf
34 changed files with 1177 additions and 156 deletions
|
|
@ -0,0 +1,18 @@
|
|||
@model PlanTempus.Application.Features.Dashboard.Components.QuickStatListViewModel
|
||||
|
||||
<swp-card data-key="@Model.Key">
|
||||
<swp-card-header>
|
||||
<swp-card-title>
|
||||
<i class="ph ph-@Model.Icon"></i>
|
||||
@Model.Title
|
||||
</swp-card-title>
|
||||
</swp-card-header>
|
||||
<swp-card-content>
|
||||
<swp-quick-stats>
|
||||
@foreach (var statKey in Model.StatKeys)
|
||||
{
|
||||
@await Component.InvokeAsync("QuickStat", statKey)
|
||||
}
|
||||
</swp-quick-stats>
|
||||
</swp-card-content>
|
||||
</swp-card>
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace PlanTempus.Application.Features.Dashboard.Components;
|
||||
|
||||
public class QuickStatListViewComponent : ViewComponent
|
||||
{
|
||||
public IViewComponentResult Invoke(string key)
|
||||
{
|
||||
var model = QuickStatListCatalog.Get(key);
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
public class QuickStatListViewModel
|
||||
{
|
||||
public required string Key { get; init; }
|
||||
public required string Title { get; init; }
|
||||
public required string Icon { get; init; }
|
||||
public required IReadOnlyList<string> StatKeys { get; init; }
|
||||
}
|
||||
|
||||
public static class QuickStatListCatalog
|
||||
{
|
||||
private static readonly Dictionary<string, QuickStatListViewModel> Lists = new()
|
||||
{
|
||||
["this-week"] = new QuickStatListViewModel
|
||||
{
|
||||
Key = "this-week",
|
||||
Title = "Denne uge",
|
||||
Icon = "chart-line-up",
|
||||
StatKeys = ["bookings-week", "revenue-week", "new-customers", "avg-occupancy"]
|
||||
}
|
||||
};
|
||||
|
||||
public static QuickStatListViewModel Get(string key)
|
||||
{
|
||||
if (Lists.TryGetValue(key, out var list))
|
||||
return list;
|
||||
|
||||
throw new KeyNotFoundException($"QuickStatList with key '{key}' not found");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue