using Microsoft.AspNetCore.Mvc;
using PlanTempus.Application.Features.Localization.Services;

namespace PlanTempus.Application.Features.Services.Components;

public class ServiceDetailEmployeesViewComponent : ViewComponent
{
    private readonly ILocalizationService _localization;

    public ServiceDetailEmployeesViewComponent(ILocalizationService localization)
    {
        _localization = localization;
    }

    public IViewComponentResult Invoke(string key)
    {
        var service = ServiceDetailCatalog.Get(key);

        var model = new ServiceDetailEmployeesViewModel
        {
            // Data
            Employees = service.Employees,
            Availability = service.Availability,

            // Labels
            LabelEmployeesForService = _localization.Get("services.detail.employees.employeesForService"),
            LabelSelectAll = _localization.Get("services.detail.employees.selectAll"),
            LabelAvailability = _localization.Get("services.detail.employees.availability"),
            LabelDuration = _localization.Get("services.detail.employees.duration"),
            ToggleYes = _localization.Get("common.yes"),
            ToggleNo = _localization.Get("common.no")
        };

        return View(model);
    }
}

public class ServiceDetailEmployeesViewModel
{
    // Data
    public required List<ServiceEmployee> Employees { get; init; }
    public required List<ServiceAvailability> Availability { get; init; }

    // Labels
    public required string LabelEmployeesForService { get; init; }
    public required string LabelSelectAll { get; init; }
    public required string LabelAvailability { get; init; }
    public required string LabelDuration { get; init; }

    // Toggle labels
    public required string ToggleYes { get; init; }
    public required string ToggleNo { get; init; }
}
