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

namespace PlanTempus.Application.Features.Services.Components;

public class ServiceDetailDurationViewComponent : ViewComponent
{
    private readonly ILocalizationService _localization;

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

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

        var model = new ServiceDetailDurationViewModel
        {
            // Data
            DurationVariants = service.DurationVariants,
            BufferBefore = service.BufferBefore,
            BufferAfter = service.BufferAfter,
            CleanupTime = service.CleanupTime,

            // Labels
            LabelDurationVariants = _localization.Get("services.detail.duration.durationVariants"),
            LabelAddVariant = _localization.Get("services.detail.duration.addVariant"),
            LabelBufferTimes = _localization.Get("services.detail.duration.bufferTimes"),
            LabelBufferBefore = _localization.Get("services.detail.duration.bufferBefore"),
            LabelBufferAfter = _localization.Get("services.detail.duration.bufferAfter"),
            LabelCleanupTime = _localization.Get("services.detail.duration.cleanupTime"),
            LabelMinutes = _localization.Get("services.detail.duration.minutes")
        };

        return View(model);
    }
}

public class ServiceDetailDurationViewModel
{
    // Data
    public required List<DurationVariant> DurationVariants { get; init; }
    public required string BufferBefore { get; init; }
    public required string BufferAfter { get; init; }
    public required string CleanupTime { get; init; }

    // Labels
    public required string LabelDurationVariants { get; init; }
    public required string LabelAddVariant { get; init; }
    public required string LabelBufferTimes { get; init; }
    public required string LabelBufferBefore { get; init; }
    public required string LabelBufferAfter { get; init; }
    public required string LabelCleanupTime { get; init; }
    public required string LabelMinutes { get; init; }
}
