2026-01-11 18:18:36 +01:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2026-01-12 15:42:18 +01:00
|
|
|
using PlanTempus.Application.Features.Localization.Services;
|
2026-01-11 18:18:36 +01:00
|
|
|
|
|
|
|
|
namespace PlanTempus.Application.Features.Dashboard.Components;
|
|
|
|
|
|
|
|
|
|
public class AttentionListViewComponent : ViewComponent
|
|
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
private readonly ILocalizationService _localization;
|
|
|
|
|
|
|
|
|
|
public AttentionListViewComponent(ILocalizationService localization)
|
|
|
|
|
{
|
|
|
|
|
_localization = localization;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-11 18:18:36 +01:00
|
|
|
public IViewComponentResult Invoke(string key)
|
|
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
var model = AttentionListCatalog.Get(key, _localization);
|
2026-01-11 18:18:36 +01:00
|
|
|
return View(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AttentionListViewModel
|
|
|
|
|
{
|
|
|
|
|
public required string Key { get; init; }
|
|
|
|
|
public required string Title { get; init; }
|
|
|
|
|
public required IReadOnlyList<string> AttentionKeys { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-12 15:42:18 +01:00
|
|
|
internal class AttentionListData
|
|
|
|
|
{
|
|
|
|
|
public required string Key { get; init; }
|
|
|
|
|
public required string TitleKey { get; init; }
|
|
|
|
|
public required IReadOnlyList<string> AttentionKeys { get; init; }
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-11 18:18:36 +01:00
|
|
|
public static class AttentionListCatalog
|
|
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
private static readonly Dictionary<string, AttentionListData> Lists = new()
|
2026-01-11 18:18:36 +01:00
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
["current-attentions"] = new AttentionListData
|
2026-01-11 18:18:36 +01:00
|
|
|
{
|
|
|
|
|
Key = "current-attentions",
|
2026-01-12 15:42:18 +01:00
|
|
|
TitleKey = "dashboard.attentions.title",
|
2026-01-11 18:18:36 +01:00
|
|
|
AttentionKeys = ["attention-1", "attention-2", "attention-3"]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-12 15:42:18 +01:00
|
|
|
public static AttentionListViewModel Get(string key, ILocalizationService localization)
|
2026-01-11 18:18:36 +01:00
|
|
|
{
|
2026-01-12 15:42:18 +01:00
|
|
|
if (!Lists.TryGetValue(key, out var list))
|
|
|
|
|
throw new KeyNotFoundException($"AttentionList with key '{key}' not found");
|
2026-01-11 18:18:36 +01:00
|
|
|
|
2026-01-12 15:42:18 +01:00
|
|
|
return new AttentionListViewModel
|
|
|
|
|
{
|
|
|
|
|
Key = list.Key,
|
|
|
|
|
Title = localization.Get(list.TitleKey),
|
|
|
|
|
AttentionKeys = list.AttentionKeys
|
|
|
|
|
};
|
2026-01-11 18:18:36 +01:00
|
|
|
}
|
|
|
|
|
}
|