diff --git a/salesbook.Maui/Core/RestClient/IntegryApi/IntegryNotificationRestClient.cs b/salesbook.Maui/Core/RestClient/IntegryApi/IntegryRegisterNotificationRestClient.cs similarity index 87% rename from salesbook.Maui/Core/RestClient/IntegryApi/IntegryNotificationRestClient.cs rename to salesbook.Maui/Core/RestClient/IntegryApi/IntegryRegisterNotificationRestClient.cs index 021fc6c..39fc676 100644 --- a/salesbook.Maui/Core/RestClient/IntegryApi/IntegryNotificationRestClient.cs +++ b/salesbook.Maui/Core/RestClient/IntegryApi/IntegryRegisterNotificationRestClient.cs @@ -6,11 +6,11 @@ using salesbook.Shared.Core.Interface.IntegryApi; namespace salesbook.Maui.Core.RestClient.IntegryApi; -public class IntegryNotificationRestClient( - ILogger logger, +public class IntegryRegisterNotificationRestClient( + ILogger logger, IUserSession userSession, IIntegryApiRestClient integryApiRestClient -) : IIntegryNotificationRestClient +) : IIntegryRegisterNotificationRestClient { public async Task Register(string fcmToken, ILogger? logger1 = null) { diff --git a/salesbook.Maui/Core/Services/ManageDataService.cs b/salesbook.Maui/Core/Services/ManageDataService.cs index 9031c83..b9196a1 100644 --- a/salesbook.Maui/Core/Services/ManageDataService.cs +++ b/salesbook.Maui/Core/Services/ManageDataService.cs @@ -1,14 +1,15 @@ using AutoMapper; +using MudBlazor.Extensions; using salesbook.Shared.Core.Dto; using salesbook.Shared.Core.Dto.Activity; using salesbook.Shared.Core.Dto.Contact; using salesbook.Shared.Core.Entity; using salesbook.Shared.Core.Helpers.Enum; using salesbook.Shared.Core.Interface; -using Sentry.Protocol; -using System.Linq.Expressions; using salesbook.Shared.Core.Interface.IntegryApi; using salesbook.Shared.Core.Interface.System.Network; +using Sentry.Protocol; +using System.Linq.Expressions; namespace salesbook.Maui.Core.Services; @@ -211,6 +212,15 @@ public class ManageDataService( { var dto = mapper.Map(activity); + if (activity is { AlarmTime: not null, EstimatedTime: not null }) + { + var minuteBefore = activity.EstimatedTime.Value - activity.AlarmTime.Value; + dto.MinuteBefore = (int)Math.Abs(minuteBefore.TotalMinutes); + + dto.NotificationDate = dto.MinuteBefore == 0 ? + activity.EstimatedTime : activity.AlarmTime; + } + if (activity.CodJcom != null) { dto.Category = ActivityCategoryEnum.Commessa; diff --git a/salesbook.Maui/Core/System/Notification/FirebaseNotificationService.cs b/salesbook.Maui/Core/System/Notification/FirebaseNotificationService.cs index 2f766eb..8d0fd36 100644 --- a/salesbook.Maui/Core/System/Notification/FirebaseNotificationService.cs +++ b/salesbook.Maui/Core/System/Notification/FirebaseNotificationService.cs @@ -8,7 +8,7 @@ namespace salesbook.Maui.Core.System.Notification; public class FirebaseNotificationService( IPushManager pushManager, - IIntegryNotificationRestClient integryNotificationRestClient, + IIntegryRegisterNotificationRestClient integryRegisterNotificationRestClient, INotificationManager notificationManager ) : IFirebaseNotificationService { @@ -19,7 +19,7 @@ public class FirebaseNotificationService( var (accessState, token) = await pushManager.RequestAccess(); if (accessState == AccessState.Denied || token is null) return; - await integryNotificationRestClient.Register(token); + await integryRegisterNotificationRestClient.Register(token); } private void CreateNotificationChannel() diff --git a/salesbook.Maui/Core/System/Notification/Push/PushNotificationDelegate.cs b/salesbook.Maui/Core/System/Notification/Push/PushNotificationDelegate.cs index 8e69c40..5f0bdc7 100644 --- a/salesbook.Maui/Core/System/Notification/Push/PushNotificationDelegate.cs +++ b/salesbook.Maui/Core/System/Notification/Push/PushNotificationDelegate.cs @@ -1,5 +1,5 @@ using CommunityToolkit.Mvvm.Messaging; -using salesbook.Shared.Core.Dto.Notification; +using salesbook.Shared.Core.Entity; using salesbook.Shared.Core.Interface.IntegryApi; using salesbook.Shared.Core.Messages.Notification; using Shiny.Push; @@ -7,7 +7,7 @@ using Shiny.Push; namespace salesbook.Maui.Core.System.Notification.Push; public class PushNotificationDelegate( - IIntegryNotificationRestClient integryNotificationRestClient, + IIntegryRegisterNotificationRestClient integryRegisterNotificationRestClient, IMessenger messenger ) : IPushDelegate { @@ -20,10 +20,10 @@ public class PushNotificationDelegate( public Task OnReceived(PushNotification notification) { if (notification.Notification is null) return Task.CompletedTask; - var pushNotification = new PushNotificationDTO + var pushNotification = new WtbNotification { Title = notification.Notification.Title, - Message = notification.Notification.Message + Body = notification.Notification.Message }; messenger.Send(new NewPushNotificationMessage(pushNotification)); @@ -33,7 +33,7 @@ public class PushNotificationDelegate( public Task OnNewToken(string token) { - integryNotificationRestClient.Register(token); + integryRegisterNotificationRestClient.Register(token); return Task.CompletedTask; } diff --git a/salesbook.Maui/MauiProgram.cs b/salesbook.Maui/MauiProgram.cs index c9c7290..4abc81f 100644 --- a/salesbook.Maui/MauiProgram.cs +++ b/salesbook.Maui/MauiProgram.cs @@ -86,6 +86,7 @@ namespace salesbook.Maui //Notification builder.Services.AddNotifications(); builder.Services.AddPush(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/salesbook.Maui/salesbook.Maui.csproj b/salesbook.Maui/salesbook.Maui.csproj index fb9eb60..9b32639 100644 --- a/salesbook.Maui/salesbook.Maui.csproj +++ b/salesbook.Maui/salesbook.Maui.csproj @@ -133,7 +133,7 @@ - + diff --git a/salesbook.Shared/Components/Layout/NavMenu.razor b/salesbook.Shared/Components/Layout/NavMenu.razor index 6880a7d..f5c158d 100644 --- a/salesbook.Shared/Components/Layout/NavMenu.razor +++ b/salesbook.Shared/Components/Layout/NavMenu.razor @@ -1,7 +1,6 @@ @using CommunityToolkit.Mvvm.Messaging @using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto.Activity -@using salesbook.Shared.Core.Dto.Notification @using salesbook.Shared.Core.Dto.PageState @using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Messages.Activity.Copy @@ -35,7 +34,7 @@