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

namespace PlanTempus.Application.Features.Services.Components;

public class ServiceDetailGeneralViewComponent : ViewComponent
{
    private readonly ILocalizationService _localization;

    // Category display -> value mapping
    private static readonly Dictionary<string, string> CategoryValues = new()
    {
        ["Kombi-behandlinger"] = "kombi",
        ["Klip"] = "klip",
        ["Farve"] = "farve",
        ["Behandlinger"] = "behandlinger",
        ["Styling"] = "styling"
    };

    // Color value -> display label mapping
    private static readonly Dictionary<string, string> ColorLabels = new()
    {
        ["red"] = "Rød",
        ["pink"] = "Pink",
        ["purple"] = "Lilla",
        ["deep-purple"] = "Mørk lilla",
        ["indigo"] = "Indigo",
        ["blue"] = "Blå",
        ["light-blue"] = "Lyseblå",
        ["cyan"] = "Cyan",
        ["teal"] = "Teal",
        ["green"] = "Grøn",
        ["light-green"] = "Lysegrøn",
        ["lime"] = "Lime",
        ["yellow"] = "Gul",
        ["amber"] = "Amber",
        ["orange"] = "Orange",
        ["deep-orange"] = "Mørk orange"
    };

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

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

        var model = new ServiceDetailGeneralViewModel
        {
            // Data
            Name = service.Name,
            Category = service.Category,
            CategoryValue = CategoryValues.GetValueOrDefault(service.Category, "kombi"),
            CalendarColor = service.CalendarColor,
            CalendarColorLabel = ColorLabels.GetValueOrDefault(service.CalendarColor, service.CalendarColor),
            IsActive = service.IsActive,
            InternalNotes = service.InternalNotes,
            CanBookAsMain = service.CanBookAsMain,
            CanBookAsAddon = service.CanBookAsAddon,
            ShowInOnlineBooking = service.ShowInOnlineBooking,
            IsFeatured = service.IsFeatured,
            Description = service.Description,

            // Labels
            LabelBasic = _localization.Get("services.detail.general.basic"),
            LabelServiceName = _localization.Get("services.detail.general.serviceName"),
            LabelCategory = _localization.Get("services.detail.general.category"),
            LabelCalendarColor = _localization.Get("services.detail.general.calendarColor"),
            LabelIsActive = _localization.Get("services.detail.general.isActive"),
            LabelInternalNotes = _localization.Get("services.detail.general.internalNotes"),
            LabelBookingType = _localization.Get("services.detail.general.bookingType"),
            LabelCanBookAsMain = _localization.Get("services.detail.general.canBookAsMain"),
            LabelCanBookAsMainDesc = _localization.Get("services.detail.general.canBookAsMainDesc"),
            LabelCanBookAsAddon = _localization.Get("services.detail.general.canBookAsAddon"),
            LabelCanBookAsAddonDesc = _localization.Get("services.detail.general.canBookAsAddonDesc"),
            LabelOnlineBooking = _localization.Get("services.detail.general.onlineBooking"),
            LabelShowInOnlineBooking = _localization.Get("services.detail.general.showInOnlineBooking"),
            LabelShowInOnlineBookingDesc = _localization.Get("services.detail.general.showInOnlineBookingDesc"),
            LabelIsFeatured = _localization.Get("services.detail.general.isFeatured"),
            LabelIsFeaturedDesc = _localization.Get("services.detail.general.isFeaturedDesc"),
            LabelDescription = _localization.Get("services.detail.general.description"),
            LabelImage = _localization.Get("services.detail.general.image"),
            LabelUploadImage = _localization.Get("services.detail.general.uploadImage"),
            ToggleYes = _localization.Get("common.yes"),
            ToggleNo = _localization.Get("common.no")
        };

        return View(model);
    }
}

public class ServiceDetailGeneralViewModel
{
    // Data
    public required string Name { get; init; }
    public required string Category { get; init; }
    public required string CategoryValue { get; init; }
    public required string CalendarColor { get; init; }
    public required string CalendarColorLabel { get; init; }
    public required bool IsActive { get; init; }
    public required string InternalNotes { get; init; }
    public required bool CanBookAsMain { get; init; }
    public required bool CanBookAsAddon { get; init; }
    public required bool ShowInOnlineBooking { get; init; }
    public required bool IsFeatured { get; init; }
    public required string Description { get; init; }

    // Labels - Basic
    public required string LabelBasic { get; init; }
    public required string LabelServiceName { get; init; }
    public required string LabelCategory { get; init; }
    public required string LabelCalendarColor { get; init; }
    public required string LabelIsActive { get; init; }

    // Labels - Internal Notes
    public required string LabelInternalNotes { get; init; }

    // Labels - Booking Type
    public required string LabelBookingType { get; init; }
    public required string LabelCanBookAsMain { get; init; }
    public required string LabelCanBookAsMainDesc { get; init; }
    public required string LabelCanBookAsAddon { get; init; }
    public required string LabelCanBookAsAddonDesc { get; init; }

    // Labels - Online Booking
    public required string LabelOnlineBooking { get; init; }
    public required string LabelShowInOnlineBooking { get; init; }
    public required string LabelShowInOnlineBookingDesc { get; init; }
    public required string LabelIsFeatured { get; init; }
    public required string LabelIsFeaturedDesc { get; init; }

    // Labels - Description & Image
    public required string LabelDescription { get; init; }
    public required string LabelImage { get; init; }
    public required string LabelUploadImage { get; init; }

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