@page "/notifications" @using LibraryManagement.Shared.Models @using BlazorWebAssembly.Services @inject LibraryApiClient ApiClient @inject NotificationStateService NotifService @inject IJSRuntime JS Notifications | LibraryLuxe User Updates Notifications @if (_notifications.Any(n => !n.IsRead)) { Mark All As Read } @if (_isLoading) { @for (int i = 0; i < 4; i++) { } } else if (!_notifications.Any()) { Clean Slate You're all caught up. New updates will appear here. } else { @foreach (var notif in _notifications) { MarkAsRead(notif)" class="group bg-card rounded-2xl p-6 border border-border hover:border-primary/30 transition-all duration-300 shadow-sm relative overflow-hidden cursor-pointer @(!notif.IsRead ? "bg-primary/[0.02]" : "")"> @if (!notif.IsRead) { } @if (notif.Type == "Warning") { } else if (notif.Type == "Info") { } else { } @notif.Title @notif.CreatedAt.ToString("MMM dd, HH:mm") @notif.Message @if (!string.IsNullOrEmpty(notif.ActionLink)) { @notif.ActionText } } } Identity Required Please sign in to your LibraryLuxe account to access your personal updates and notifications. Sign In Now @code { private List _notifications = new(); private bool _isLoading = true; protected override async Task OnInitializedAsync() { await LoadNotifications(); } private async Task LoadNotifications() { try { _isLoading = true; _notifications = (await ApiClient.GetNotificationsAsync()).ToList(); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } finally { _isLoading = false; } } private async Task MarkAllAsRead() { try { var success = await ApiClient.MarkNotificationsReadAsync(); if (success) { NotifService.SetUnreadCount(0); await LoadNotifications(); } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } private async Task MarkAsRead(NotificationDto notif) { if (notif.IsRead) return; try { var success = await ApiClient.MarkAsReadAsync(notif.Id); if (success) { notif.IsRead = true; NotifService.DecrementCount(); StateHasChanged(); } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } private string GetIconClass(string type) => type switch { "Warning" => "bg-orange-500/10 text-orange-500", "Info" => "bg-blue-500/10 text-blue-500", _ => "bg-primary/10 text-primary" }; }
You're all caught up. New updates will appear here.
@notif.Message
Please sign in to your LibraryLuxe account to access your personal updates and notifications.