diff --git a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor index 8443d96..b91bc5e 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ActivityForm.razor @@ -1,7 +1,6 @@ @using System.Globalization @using System.Text.RegularExpressions @using CommunityToolkit.Mvvm.Messaging -@using Java.Util.Jar @using salesbook.Shared.Core.Dto @using salesbook.Shared.Components.Layout @using salesbook.Shared.Core.Entity @@ -126,13 +125,13 @@ { @if (item.p.Type == AttachedDTO.TypeAttached.Position) { - + @item.p.Description } else { - + @item.p.Name } @@ -518,7 +517,7 @@ if (resultNamePosition is true) attached.Description = NamePosition; - attached.Name = NamePosition!; + attached.Name = NamePosition!; } AttachedList ??= []; @@ -542,4 +541,37 @@ StateHasChanged(); } + private async Task OpenAttached(AttachedDTO attached) + { + if (attached is { FileContent: not null, MimeType: not null }) + { + var fileViewerUrl = $"data:{attached.MimeType};base64,{Convert.ToBase64String(attached.FileContent)}"; + await ModalHelpers.OpenViewAttach(Dialog, fileViewerUrl); + } + else + { + Snackbar.Clear(); + Snackbar.Add("Impossibile aprire il file", Severity.Error); + } + } + + private void OpenPosition(AttachedDTO attached) + { + if (attached is { Lat: not null, Lng: not null }) + { + const string baseUrl = "https://www.google.it/maps/place/"; + NavigationManager.NavigateTo( + $"{baseUrl}{AdjustCoordinate(attached.Lat.Value)},{AdjustCoordinate(attached.Lng.Value)}" + ); + } + else + { + Snackbar.Clear(); + Snackbar.Add("Impossibile aprire la posizione", Severity.Error); + } + } + + private static string AdjustCoordinate(double coordinate) => + coordinate.ToString(CultureInfo.InvariantCulture).Replace(",", "."); + } \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor b/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor index 7985f88..f070e1f 100644 --- a/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor +++ b/salesbook.Shared/Components/SingleElements/Modal/ContactForm.razor @@ -559,6 +559,9 @@ private async Task ConvertProspectToContact() { - + await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO + { + CodPpro = ContactModel.CodContact + }); } } \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/ViewAttached.razor b/salesbook.Shared/Components/SingleElements/Modal/ViewAttached.razor new file mode 100644 index 0000000..0dc97c5 --- /dev/null +++ b/salesbook.Shared/Components/SingleElements/Modal/ViewAttached.razor @@ -0,0 +1,14 @@ + + + @if (!string.IsNullOrEmpty(FileViewerUrl)) + { + + } + + + +@code { + [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } + + [Parameter] public string? FileViewerUrl { get; set; } +} \ No newline at end of file diff --git a/salesbook.Shared/Components/SingleElements/Modal/ViewAttached.razor.css b/salesbook.Shared/Components/SingleElements/Modal/ViewAttached.razor.css new file mode 100644 index 0000000..6eeaddd --- /dev/null +++ b/salesbook.Shared/Components/SingleElements/Modal/ViewAttached.razor.css @@ -0,0 +1,7 @@ +.content.attached { + display: flex; + flex-direction: column; + gap: 2rem; + padding: 1rem; + height: unset; +} diff --git a/salesbook.Shared/Core/Helpers/ModalHelpers.cs b/salesbook.Shared/Core/Helpers/ModalHelpers.cs index fa199f6..574a8ba 100644 --- a/salesbook.Shared/Core/Helpers/ModalHelpers.cs +++ b/salesbook.Shared/Core/Helpers/ModalHelpers.cs @@ -85,4 +85,23 @@ public class ModalHelpers return await modal.Result; } + + public static async Task OpenViewAttach(IDialogService dialog, string? fileViewUrl) + { + var modal = await dialog.ShowAsync( + "View attached", + new DialogParameters + { + { x => x.FileViewerUrl, fileViewUrl } + }, + new DialogOptions + { + FullScreen = true, + CloseButton = true, + NoHeader = true + } + ); + + return await modal.Result; + } } \ No newline at end of file