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

namespace PlanTempus.Application.Features.Employees.Components;

public class EmployeeDetailHRViewComponent : ViewComponent
{
    private readonly ILocalizationService _localization;

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

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

        var model = new EmployeeDetailHRViewModel
        {
            // Contract data
            ContractType = employee.ContractType,
            TerminationNotice = employee.TerminationNotice,
            ContractExpiry = employee.ContractExpiry,

            // Vacation data
            VacationEarned = employee.VacationEarned,
            VacationUsed = employee.VacationUsed,
            VacationRemaining = employee.VacationRemaining,

            // Absence data
            SickDays2025 = employee.SickDays2025,
            SickDays2024 = employee.SickDays2024,
            ChildSickDays2025 = employee.ChildSickDays2025,
            MaternityLeave = employee.MaternityLeave,

            // Labels - Contract & Documents
            LabelContractDocuments = _localization.Get("employees.detail.hr.contractdocuments"),
            LabelContractType = _localization.Get("employees.detail.hr.contracttype"),
            LabelTerminationNotice = _localization.Get("employees.detail.hr.terminationnotice"),
            LabelContractExpiry = _localization.Get("employees.detail.hr.contractexpiry"),
            LabelUploadDocument = _localization.Get("employees.detail.hr.uploaddocument"),

            // Labels - Certifications
            LabelCertifications = _localization.Get("employees.detail.hr.certifications"),
            LabelAddCertification = _localization.Get("employees.detail.hr.addcertification"),

            // Labels - Courses
            LabelCourses = _localization.Get("employees.detail.hr.courses"),
            LabelCompletedCourses = _localization.Get("employees.detail.hr.completedcourses"),
            LabelPlannedCourses = _localization.Get("employees.detail.hr.plannedcourses"),
            LabelAddCourse = _localization.Get("employees.detail.hr.addcourse"),

            // Labels - Vacation
            LabelVacationBalance = _localization.Get("employees.detail.hr.vacationbalance"),
            LabelVacationEarned = _localization.Get("employees.detail.hr.vacationearned"),
            LabelVacationUsed = _localization.Get("employees.detail.hr.vacationused"),
            LabelVacationRemaining = _localization.Get("employees.detail.hr.vacationremaining"),

            // Labels - Absence
            LabelAbsenceSickness = _localization.Get("employees.detail.hr.absencesickness"),
            LabelSickDays2025 = _localization.Get("employees.detail.hr.sickdays2025"),
            LabelSickDays2024 = _localization.Get("employees.detail.hr.sickdays2024"),
            LabelChildSickDays2025 = _localization.Get("employees.detail.hr.childsickdays2025"),
            LabelMaternityLeave = _localization.Get("employees.detail.hr.maternityleave"),

            // Labels - Planned absence
            LabelPlannedAbsence = _localization.Get("employees.detail.hr.plannedabsence"),
            LabelAddAbsence = _localization.Get("employees.detail.hr.addabsence"),

            // Contract type options
            ContractTypeOptions = new List<string> { "Fastansættelse", "Tidsbegrænset", "Freelance", "Elev/Lærling" },
            TerminationNoticeOptions = new List<string> { "14 dage", "1 måned", "3 måneder" },

            // Mock data - Documents
            Documents = new List<DocumentRecord>
            {
                new("Ansættelseskontrakt.pdf", "Uploadet 1. aug 2019"),
                new("Tillæg - Lønforhøjelse 2023.pdf", "Uploadet 15. jan 2023")
            },

            // Mock data - Certifications
            Certifications = new List<CertificationRecord>
            {
                new("Balayage Specialist", "Udløber: 15. juni 2026", "Gyldig", "valid"),
                new("Farvecertificering (Wella)", "Udløber: 1. marts 2025", "Udløber snart", "expiring")
            },

            // Mock data - Courses
            CompletedCourses = new List<CourseRecord>
            {
                new("Avanceret balayage teknikker", "Wella Academy", "Marts 2024"),
                new("Kundeservice & mersalg", "SalonUp", "November 2023")
            },
            PlannedCourses = new List<CourseRecord>
            {
                new("Olaplex certificering", "Olaplex DK", "15. februar 2026", "Tilmeldt")
            },

            // Mock data - Planned absence
            PlannedAbsences = new List<PlannedAbsenceRecord>
            {
                new("23. dec – 2. jan 2026", "Ferie", "ferie"),
                new("14. feb 2025", "Fri", "fri")
            }
        };

        return View(model);
    }
}

public class EmployeeDetailHRViewModel
{
    // Contract data
    public required string ContractType { get; init; }
    public required string TerminationNotice { get; init; }
    public required string ContractExpiry { get; init; }

    // Vacation data
    public required string VacationEarned { get; init; }
    public required string VacationUsed { get; init; }
    public required string VacationRemaining { get; init; }

    // Absence data
    public required string SickDays2025 { get; init; }
    public required string SickDays2024 { get; init; }
    public required string ChildSickDays2025 { get; init; }
    public required string MaternityLeave { get; init; }

    // Labels - Contract & Documents
    public required string LabelContractDocuments { get; init; }
    public required string LabelContractType { get; init; }
    public required string LabelTerminationNotice { get; init; }
    public required string LabelContractExpiry { get; init; }
    public required string LabelUploadDocument { get; init; }

    // Labels - Certifications
    public required string LabelCertifications { get; init; }
    public required string LabelAddCertification { get; init; }

    // Labels - Courses
    public required string LabelCourses { get; init; }
    public required string LabelCompletedCourses { get; init; }
    public required string LabelPlannedCourses { get; init; }
    public required string LabelAddCourse { get; init; }

    // Labels - Vacation
    public required string LabelVacationBalance { get; init; }
    public required string LabelVacationEarned { get; init; }
    public required string LabelVacationUsed { get; init; }
    public required string LabelVacationRemaining { get; init; }

    // Labels - Absence
    public required string LabelAbsenceSickness { get; init; }
    public required string LabelSickDays2025 { get; init; }
    public required string LabelSickDays2024 { get; init; }
    public required string LabelChildSickDays2025 { get; init; }
    public required string LabelMaternityLeave { get; init; }

    // Labels - Planned absence
    public required string LabelPlannedAbsence { get; init; }
    public required string LabelAddAbsence { get; init; }

    // Contract type options
    public List<string> ContractTypeOptions { get; init; } = new();
    public List<string> TerminationNoticeOptions { get; init; } = new();

    // Data collections
    public List<DocumentRecord> Documents { get; init; } = new();
    public List<CertificationRecord> Certifications { get; init; } = new();
    public List<CourseRecord> CompletedCourses { get; init; } = new();
    public List<CourseRecord> PlannedCourses { get; init; } = new();
    public List<PlannedAbsenceRecord> PlannedAbsences { get; init; } = new();
}
