@page "/notifications" @using LibraryManagement.Shared.Models @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Components.Authorization @using BlazorFrontend.Services @inject LibraryApiClient ApiClient @inject IJSRuntime JSRuntime Notifications Notifications Stay updated with your library account activity. @if (_notifications != null && _notifications.Any(n => !n.IsRead)) { Mark all as read } @if (_isLoading) { } else if (_notifications == null || !_notifications.Any()) { No notifications yet When you get updates about your books or subscription, they'll show up here. } else { @foreach (var notif in _notifications) { @if (!notif.IsRead) { } @if (notif.Type == "Warning") { } else if (notif.Type == "Info") { } else { } @notif.Title @notif.Message @notif.CreatedAt.ToString("MMM dd, HH:mm") @if (!string.IsNullOrEmpty(notif.ActionLink)) { @notif.ActionText } } } Please sign in to view notifications Sign In @code { private List _notifications = new(); private bool _isLoading = true; protected override async Task OnInitializedAsync() { await LoadNotifications(); } private async Task LoadNotifications() { try { _isLoading = true; StateHasChanged(); var results = await ApiClient.GetNotificationsAsync(); _notifications = results.ToList(); } catch (Exception ex) { Console.WriteLine($"Error loading notifications: {ex.Message}"); _notifications = new List(); } finally { _isLoading = false; StateHasChanged(); } } private async Task MarkAllAsRead() { try { var success = await ApiClient.MarkNotificationsReadAsync(); if (success) { await LoadNotifications(); } } catch (Exception ex) { Console.WriteLine($"Error marking notifications as read: {ex.Message}"); } } }
Stay updated with your library account activity.
When you get updates about your books or subscription, they'll show up here.
@notif.Message