PlanTempusApp/PlanTempus.Application/Features/Dashboard/Components/AttentionItem/AttentionItemViewComponent.cs
Janus C. H. Knudsen 12869e35bf wip
2026-01-11 18:18:36 +01:00

66 lines
2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Mvc;
namespace PlanTempus.Application.Features.Dashboard.Components;
public class AttentionItemViewComponent : ViewComponent
{
public IViewComponentResult Invoke(string key)
{
var model = AttentionItemCatalog.Get(key);
return View(model);
}
}
public class AttentionItemViewModel
{
public required string Key { get; init; }
public required string Icon { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public required string ActionText { get; init; }
public required string Severity { get; init; }
}
public static class AttentionItemCatalog
{
private static readonly Dictionary<string, AttentionItemViewModel> Attentions = new()
{
["attention-1"] = new AttentionItemViewModel
{
Key = "attention-1",
Icon = "x-circle",
Title = "Aflyst booking",
Description = "Mette Hansen aflyste kl. 15:00 tid nu ledig",
ActionText = "Fyld tid",
Severity = "urgent"
},
["attention-2"] = new AttentionItemViewModel
{
Key = "attention-2",
Icon = "clock",
Title = "Ubekræftet booking",
Description = "Ida Rasmussen har ikke bekræftet kl. 11:30",
ActionText = "Send påmindelse",
Severity = "warning"
},
["attention-3"] = new AttentionItemViewModel
{
Key = "attention-3",
Icon = "gift",
Title = "Gavekort udløber snart",
Description = "GC-D2R4-6TY9 udløber om 3 uger (200 DKK)",
ActionText = "Se gavekort",
Severity = "info"
}
};
public static AttentionItemViewModel Get(string key)
{
if (Attentions.TryGetValue(key, out var attention))
return attention;
throw new KeyNotFoundException($"AttentionItem with key '{key}' not found");
}
public static IEnumerable<string> AllKeys => Attentions.Keys;
}