using Microsoft.AspNetCore.Mvc; using PlanTempus.Application.Features.Localization.Services; namespace PlanTempus.Application.Features.Employees.Components; public class EmployeeDetailHeaderViewComponent : ViewComponent { private readonly ILocalizationService _localization; public EmployeeDetailHeaderViewComponent(ILocalizationService localization) { _localization = localization; } public IViewComponentResult Invoke(string key) { var employee = EmployeeDetailCatalog.Get(key); var model = new EmployeeDetailHeaderViewModel { Initials = employee.Initials, Name = employee.Name, AvatarColor = employee.AvatarColor, Role = employee.Role, RoleText = _localization.Get(employee.RoleKey), Status = employee.Status, StatusText = _localization.Get(employee.StatusKey), BookingsThisYear = employee.BookingsThisYear, RevenueThisYear = employee.RevenueThisYear, Rating = employee.Rating, EmployedSince = employee.EmployedSince, LabelBookings = _localization.Get("employees.detail.bookings"), LabelRevenue = _localization.Get("employees.detail.revenue"), LabelRating = _localization.Get("employees.detail.rating"), LabelEmployedSince = _localization.Get("employees.detail.employedsince"), Tags = employee.Tags.Select(t => new EmployeeTagViewModel { Text = t.Text, CssClass = t.CssClass }).ToList() }; return View(model); } } public class EmployeeDetailHeaderViewModel { public required string Initials { get; init; } public required string Name { get; init; } public string? AvatarColor { get; init; } public required string Role { get; init; } public required string RoleText { get; init; } public required string Status { get; init; } public required string StatusText { get; init; } public bool IsActive => Status == "active"; public required string BookingsThisYear { get; init; } public required string RevenueThisYear { get; init; } public required string Rating { get; init; } public required string EmployedSince { get; init; } public required string LabelBookings { get; init; } public required string LabelRevenue { get; init; } public required string LabelRating { get; init; } public required string LabelEmployedSince { get; init; } public List Tags { get; init; } = new(); } public class EmployeeTagViewModel { public required string Text { get; init; } public required string CssClass { get; init; } }