Introduces comprehensive services management module with: - Dynamic service and category tables - Localization support for services section - Mock data for services and categories - Responsive UI components for services listing - Menu navigation and styling updates Enhances application's service management capabilities
80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using PlanTempus.Application.Features.Localization.Services;
|
|
|
|
namespace PlanTempus.Application.Features.Services.Components;
|
|
|
|
public class ServiceStatCardViewComponent : ViewComponent
|
|
{
|
|
private readonly ILocalizationService _localization;
|
|
|
|
public ServiceStatCardViewComponent(ILocalizationService localization)
|
|
{
|
|
_localization = localization;
|
|
}
|
|
|
|
public IViewComponentResult Invoke(string key)
|
|
{
|
|
var model = ServiceStatCardCatalog.Get(key, _localization);
|
|
return View(model);
|
|
}
|
|
}
|
|
|
|
public class ServiceStatCardViewModel
|
|
{
|
|
public required string Key { get; init; }
|
|
public required string Value { get; init; }
|
|
public required string Label { get; init; }
|
|
public string? Variant { get; init; }
|
|
}
|
|
|
|
internal class ServiceStatCardData
|
|
{
|
|
public required string Key { get; init; }
|
|
public required string Value { get; init; }
|
|
public required string LabelKey { get; init; }
|
|
public string? Variant { get; init; }
|
|
}
|
|
|
|
public static class ServiceStatCardCatalog
|
|
{
|
|
private static readonly Dictionary<string, ServiceStatCardData> Cards = new()
|
|
{
|
|
["total-services"] = new ServiceStatCardData
|
|
{
|
|
Key = "total-services",
|
|
Value = "78",
|
|
LabelKey = "services.stats.totalServices",
|
|
Variant = "teal"
|
|
},
|
|
["active-categories"] = new ServiceStatCardData
|
|
{
|
|
Key = "active-categories",
|
|
Value = "14",
|
|
LabelKey = "services.stats.activeCategories",
|
|
Variant = "purple"
|
|
},
|
|
["average-price"] = new ServiceStatCardData
|
|
{
|
|
Key = "average-price",
|
|
Value = "856 kr",
|
|
LabelKey = "services.stats.averagePrice",
|
|
Variant = "amber"
|
|
}
|
|
};
|
|
|
|
public static ServiceStatCardViewModel Get(string key, ILocalizationService localization)
|
|
{
|
|
if (!Cards.TryGetValue(key, out var card))
|
|
throw new KeyNotFoundException($"ServiceStatCard with key '{key}' not found");
|
|
|
|
return new ServiceStatCardViewModel
|
|
{
|
|
Key = card.Key,
|
|
Value = card.Value,
|
|
Label = localization.Get(card.LabelKey),
|
|
Variant = card.Variant
|
|
};
|
|
}
|
|
|
|
public static IEnumerable<string> AllKeys => Cards.Keys;
|
|
}
|