PlanTempusApp/PlanTempus.Application/Features/Dashboard/Components/NotificationItemViewComponent.cs
Janus C. H. Knudsen abcf8ee75e Adds dashboard booking and notification components
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
2026-01-11 13:11:55 +01:00

75 lines
2.2 KiB
C#

using Microsoft.AspNetCore.Mvc;
namespace PlanTempus.Application.Features.Dashboard.Components;
public class NotificationItemViewComponent : ViewComponent
{
public IViewComponentResult Invoke(string key)
{
var model = NotificationItemCatalog.Get(key);
return View(model);
}
}
public class NotificationItemViewModel
{
public required string Key { get; init; }
public required string Icon { get; init; }
public required string Title { get; init; }
public required string Text { get; init; }
public required string Time { get; init; }
public bool IsUnread { get; init; }
}
public static class NotificationItemCatalog
{
private static readonly Dictionary<string, NotificationItemViewModel> Notifications = new()
{
["notif-1"] = new NotificationItemViewModel
{
Key = "notif-1",
Icon = "calendar-plus",
Title = "Ny booking",
Text = "fra Emma Christensen til Balayage",
Time = "For 15 min. siden",
IsUnread = true
},
["notif-2"] = new NotificationItemViewModel
{
Key = "notif-2",
Icon = "star",
Title = "Ny anmeldelse",
Text = "5 stjerner fra Sofie Nielsen",
Time = "For 1 time siden",
IsUnread = true
},
["notif-3"] = new NotificationItemViewModel
{
Key = "notif-3",
Icon = "x",
Title = "Aflysning",
Text = "Mette Hansen aflyste kl. 15:00",
Time = "For 2 timer siden",
IsUnread = false
},
["notif-4"] = new NotificationItemViewModel
{
Key = "notif-4",
Icon = "check",
Title = "Bekræftet",
Text = "Louise Andersen bekræftede kl. 13:00",
Time = "I går kl. 18:30",
IsUnread = false
}
};
public static NotificationItemViewModel Get(string key)
{
if (Notifications.TryGetValue(key, out var notification))
return notification;
throw new KeyNotFoundException($"NotificationItem with key '{key}' not found");
}
public static IEnumerable<string> AllKeys => Notifications.Keys;
}