Gestita pagina notifiche
This commit is contained in:
@@ -1,15 +1,86 @@
|
||||
@using salesbook.Shared.Core.Dto.Notification
|
||||
@using salesbook.Shared.Core.Entity
|
||||
|
||||
<div class="row">
|
||||
<div class="behind"><button class="trash-btn"><MudIcon Icon="@Icons.Material.Filled.Delete" /></button></div>
|
||||
<div class="row" id="@Notification.Id">
|
||||
<div class="behind-left">
|
||||
<button class="read-btn">
|
||||
<MudIcon Icon="@Icons.Material.Rounded.Check" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="behind-right">
|
||||
<button class="trash-btn">
|
||||
<MudIcon Icon="@Icons.Material.Rounded.Delete" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="notification-card">
|
||||
<div>
|
||||
<div class="title">@Notification.Title</div>
|
||||
<div class="subtitle">@Notification.Message</div>
|
||||
@if (Notification.NotificationData is { Type: not null })
|
||||
{
|
||||
@switch (Notification.NotificationData.Type)
|
||||
{
|
||||
case "memo":
|
||||
<div class="avatar"><MudIcon Icon="@Icons.Material.Rounded.ContentPaste" /></div>
|
||||
break;
|
||||
case "newPlanned":
|
||||
<div class="avatar"><MudIcon Icon="@Icons.Material.Rounded.CalendarMonth" /></div>
|
||||
break;
|
||||
}
|
||||
}
|
||||
<div class="notification-body">
|
||||
<div class="title-row">
|
||||
<div class="title">@Notification.Title</div>
|
||||
|
||||
<div class="section-time">
|
||||
<div class="notification-time">@GetTimeAgo(Notification.StartDate)</div>
|
||||
@if (Unread)
|
||||
{
|
||||
<span class="unread-dot"></span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (
|
||||
Notification.StartDate < DateTime.Today && Notification.Body != null && Notification.Body.Contains("Oggi")
|
||||
)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="subtitle">@Notification.Body.Replace("Oggi", $"{Notification.StartDate:d}")</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="subtitle">@Notification.Body</MudText>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public PushNotificationDTO Notification { get; set; } = new();
|
||||
[Parameter] public bool Unread { get; set; }
|
||||
[Parameter] public WtbNotification Notification { get; set; } = new();
|
||||
|
||||
private static string GetTimeAgo(DateTime? timestamp)
|
||||
{
|
||||
if (timestamp is null) return "";
|
||||
|
||||
var difference = DateTime.Now - timestamp.Value;
|
||||
|
||||
switch (difference.TotalMinutes)
|
||||
{
|
||||
case < 1:
|
||||
return "Adesso";
|
||||
case < 60:
|
||||
return $"{(int)difference.TotalMinutes} minuti fa";
|
||||
default:
|
||||
{
|
||||
switch (difference.TotalHours)
|
||||
{
|
||||
case < 2:
|
||||
return $"{(int)difference.TotalHours} ora fa";
|
||||
case < 24:
|
||||
return $"{timestamp.Value:t}";
|
||||
default:
|
||||
{
|
||||
return difference.TotalDays < 7 ? $"{(int)difference.TotalDays}g fa" : timestamp.Value.ToString("dd/MM/yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user