using Microsoft.AspNetCore.Mvc;

namespace PlanTempus.Application.Features.Dashboard.Components;

public class AttentionListViewComponent : ViewComponent
{
    public IViewComponentResult Invoke(string key)
    {
        var model = AttentionListCatalog.Get(key);
        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; }
}

public static class AttentionListCatalog
{
    private static readonly Dictionary<string, AttentionListViewModel> Lists = new()
    {
        ["current-attentions"] = new AttentionListViewModel
        {
            Key = "current-attentions",
            Title = "Opmærksomheder",
            AttentionKeys = ["attention-1", "attention-2", "attention-3"]
        }
    };

    public static AttentionListViewModel Get(string key)
    {
        if (Lists.TryGetValue(key, out var list))
            return list;

        throw new KeyNotFoundException($"AttentionList with key '{key}' not found");
    }
}
