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

namespace PlanTempus.Application.Features.Employees.Components;

public class EmployeeDetailStatsViewComponent : ViewComponent
{
    private readonly ILocalizationService _localization;

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

    public IViewComponentResult Invoke(string key)
    {
        var employee = EmployeeDetailCatalog.Get(key);

        var model = new EmployeeDetailStatsViewModel
        {
            BookingsThisYear = employee.BookingsThisYear,
            RevenueThisYear = employee.RevenueThisYear,
            Rating = employee.Rating,
            LabelPerformance = _localization.Get("employees.detail.stats.performance"),
            LabelBookingsThisYear = _localization.Get("employees.detail.stats.bookingsyear"),
            LabelRevenueThisYear = _localization.Get("employees.detail.stats.revenueyear"),
            LabelAvgRating = _localization.Get("employees.detail.stats.avgrating"),
            LabelOccupancy = _localization.Get("employees.detail.stats.occupancy"),
            LabelCompletedBookings = _localization.Get("employees.detail.stats.completedbookings"),
            LabelDate = _localization.Get("employees.detail.stats.date"),
            LabelTime = _localization.Get("employees.detail.stats.time"),
            LabelCustomer = _localization.Get("employees.detail.stats.customer"),
            LabelServices = _localization.Get("employees.detail.stats.services"),
            LabelDuration = _localization.Get("employees.detail.stats.duration"),
            LabelAmount = _localization.Get("employees.detail.stats.amount"),
            LabelStatus = _localization.Get("employees.detail.stats.status"),
            CompletedBookings = GetMockBookings()
        };

        return View(model);
    }

    private List<CompletedBookingItem> GetMockBookings()
    {
        return new List<CompletedBookingItem>
        {
            new() { Date = "23. dec 2024", Time = "10:00", Customer = "Maria Hansen", Services = "Dameklip, Bundfarve", Duration = "2t 30m", Amount = "1.510 kr", Status = "Betalt", StatusClass = "paid" },
            new() { Date = "23. dec 2024", Time = "14:30", Customer = "Sofie Nielsen", Services = "Herreklip", Duration = "30m", Amount = "350 kr", Status = "Betalt", StatusClass = "paid" },
            new() { Date = "22. dec 2024", Time = "09:00", Customer = "Emma Pedersen", Services = "Dameklip, Highlights", Duration = "3t 15m", Amount = "2.150 kr", Status = "Afventer", StatusClass = "pending" },
            new() { Date = "22. dec 2024", Time = "13:00", Customer = "Anne Larsen", Services = "Dameklip", Duration = "45m", Amount = "450 kr", Status = "Betalt", StatusClass = "paid" },
            new() { Date = "21. dec 2024", Time = "11:00", Customer = "Katrine Jensen", Services = "Balayage, Olaplex", Duration = "4t", Amount = "3.200 kr", Status = "Betalt", StatusClass = "paid" }
        };
    }
}

public class EmployeeDetailStatsViewModel
{
    public required string BookingsThisYear { get; init; }
    public required string RevenueThisYear { get; init; }
    public required string Rating { get; init; }
    public required string LabelPerformance { get; init; }
    public required string LabelBookingsThisYear { get; init; }
    public required string LabelRevenueThisYear { get; init; }
    public required string LabelAvgRating { get; init; }
    public required string LabelOccupancy { get; init; }
    public required string LabelCompletedBookings { get; init; }
    public required string LabelDate { get; init; }
    public required string LabelTime { get; init; }
    public required string LabelCustomer { get; init; }
    public required string LabelServices { get; init; }
    public required string LabelDuration { get; init; }
    public required string LabelAmount { get; init; }
    public required string LabelStatus { get; init; }
    public required List<CompletedBookingItem> CompletedBookings { get; init; }
}

public class CompletedBookingItem
{
    public required string Date { get; init; }
    public required string Time { get; init; }
    public required string Customer { get; init; }
    public required string Services { get; init; }
    public required string Duration { get; init; }
    public required string Amount { get; init; }
    public required string Status { get; init; }
    public required string StatusClass { get; init; }
}
