Migliorata gestione e visualizzazione notifiche
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@inject IManageDataService ManageDataService
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDialogService Dialog
|
||||
|
||||
<div class="row" id="@Notification.Id">
|
||||
<div class="row" id="@Notification.Id" @onclick="OpenActivity">
|
||||
<div class="behind-left">
|
||||
<button class="read-btn">
|
||||
<MudIcon Icon="@Icons.Material.Rounded.Check" />
|
||||
@@ -51,10 +57,35 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<OverlayLayout Visible="VisibleOverlay" />
|
||||
|
||||
@code {
|
||||
[Parameter] public bool Unread { get; set; }
|
||||
[Parameter] public WtbNotification Notification { get; set; } = new();
|
||||
|
||||
private bool VisibleOverlay { get; set; }
|
||||
|
||||
private async Task OpenActivity()
|
||||
{
|
||||
if(Notification.NotificationData?.ActivityId == null) return;
|
||||
var activityId = Notification.NotificationData.ActivityId;
|
||||
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
Snackbar.Clear();
|
||||
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
var activity = (await ManageDataService.GetActivityTryLocalDb(new WhereCondActivity { ActivityId = activityId })).LastOrDefault();
|
||||
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
|
||||
if (activity == null) Snackbar.Add("Impossibile aprire l'attivit<69>", Severity.Error);
|
||||
|
||||
_ = ModalHelpers.OpenActivityForm(Dialog, activity, null);
|
||||
}
|
||||
|
||||
private static string GetTimeAgo(DateTime? timestamp)
|
||||
{
|
||||
if (timestamp is null) return "";
|
||||
@@ -77,7 +108,7 @@
|
||||
return $"{timestamp.Value:t}";
|
||||
default:
|
||||
{
|
||||
return difference.TotalDays < 7 ? $"{(int)difference.TotalDays}g fa" : timestamp.Value.ToString("dd/MM/yyyy");
|
||||
return timestamp.Value.ToString("dd/MM/yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user