Add services feature with mock data and components
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
This commit is contained in:
parent
408e590922
commit
4cf30e1f27
20 changed files with 951 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
@model PlanTempus.Application.Features.Services.Components.ServiceStatCardViewModel
|
||||
|
||||
<swp-stat-card data-key="@Model.Key" class="@Model.Variant">
|
||||
<swp-stat-value>@Model.Value</swp-stat-value>
|
||||
<swp-stat-label>@Model.Label</swp-stat-label>
|
||||
</swp-stat-card>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue