Introduces reusable view components for bookings and notifications Implements dynamic rendering of booking items and lists Adds corresponding CSS styles for new dashboard components Enhances dashboard user interface with interactive elements
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace PlanTempus.Application.Features.Dashboard.Components;
|
|
|
|
public class NotificationListViewComponent : ViewComponent
|
|
{
|
|
public IViewComponentResult Invoke(string key)
|
|
{
|
|
var model = NotificationListCatalog.Get(key);
|
|
return View(model);
|
|
}
|
|
}
|
|
|
|
public class NotificationListViewModel
|
|
{
|
|
public required string Key { get; init; }
|
|
public required string Title { get; init; }
|
|
public required string ActionText { get; init; }
|
|
public required IReadOnlyList<string> NotificationKeys { get; init; }
|
|
}
|
|
|
|
public static class NotificationListCatalog
|
|
{
|
|
private static readonly Dictionary<string, NotificationListViewModel> Lists = new()
|
|
{
|
|
["recent-notifications"] = new NotificationListViewModel
|
|
{
|
|
Key = "recent-notifications",
|
|
Title = "Notifikationer",
|
|
ActionText = "Marker alle som læst",
|
|
NotificationKeys = ["notif-1", "notif-2", "notif-3", "notif-4"]
|
|
}
|
|
};
|
|
|
|
public static NotificationListViewModel Get(string key)
|
|
{
|
|
if (Lists.TryGetValue(key, out var list))
|
|
return list;
|
|
|
|
throw new KeyNotFoundException($"NotificationList with key '{key}' not found");
|
|
}
|
|
}
|