Files
TaskHybrid/salesbook.Shared/Components/Pages/Notifications.razor
2025-09-09 16:30:51 +02:00

46 lines
1.3 KiB
Plaintext

@page "/Notifications"
@attribute [Authorize]
@using salesbook.Shared.Components.Layout
@using salesbook.Shared.Components.SingleElements
@using salesbook.Shared.Core.Dto.Notification
@using salesbook.Shared.Core.Dto.PageState
@using salesbook.Shared.Core.Messages.Notification
@inject NotificationState Notification
@inject NewPushNotificationService NewPushNotificationService
@inject IJSRuntime JS
<HeaderLayout Title="Notifiche" />
<div class="container">
@if (Notification.UnreadNotifications.IsNullOrEmpty())
{
<NoDataAvailable Text="Nessuna notifica meno recente" />
}
else
{
<div class="list" id="list">
@foreach(var notification in Notification.UnreadNotifications)
{
<NotificationCard Notification="notification" />
}
</div>
}
</div>
@code {
protected override Task OnInitializedAsync()
{
NewPushNotificationService.OnNotificationReceived += NewNotificationReceived;
return Task.CompletedTask;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JS.InvokeVoidAsync("initNotifications");
}
private void NewNotificationReceived(PushNotificationDTO notification)
{
InvokeAsync(StateHasChanged);
}
}