using Microsoft.AspNetCore.Mvc;

namespace PlanTempus.Application.Features.Dashboard.Components;

/// <summary>
/// ViewComponent for rendering the waitlist mini card on the dashboard.
/// Displays a count badge and triggers the waitlist drawer when clicked.
/// </summary>
public class WaitlistCardViewComponent : ViewComponent
{
    public IViewComponentResult Invoke(string key)
    {
        var model = WaitlistCardCatalog.Get(key);
        return View(model);
    }
}

/// <summary>
/// ViewModel for the WaitlistCard component.
/// </summary>
public class WaitlistCardViewModel
{
    public required string Key { get; init; }
    public required string Label { get; init; }
    public required string Icon { get; init; }
    public required int Count { get; init; }
    public required string DrawerTarget { get; init; }
}

/// <summary>
/// Catalog of waitlist cards with their data.
/// </summary>
public static class WaitlistCardCatalog
{
    private static readonly Dictionary<string, WaitlistCardViewModel> Cards = new()
    {
        ["waitlist"] = new WaitlistCardViewModel
        {
            Key = "waitlist",
            Label = "På venteliste",
            Icon = "users-three",
            Count = 4,
            DrawerTarget = "waitlist-drawer"
        }
    };

    public static WaitlistCardViewModel Get(string key)
    {
        if (Cards.TryGetValue(key, out var card))
            return card;

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