diff --git a/NotamManagement.UI/Pages/Dialogs/DeleteConfirmationDialog.razor b/NotamManagement.UI/Pages/Dialogs/DeleteConfirmationDialog.razor new file mode 100644 index 0000000..8785114 --- /dev/null +++ b/NotamManagement.UI/Pages/Dialogs/DeleteConfirmationDialog.razor @@ -0,0 +1,19 @@ + + + @ContentText + + + Cancel + Delete + + + +@code { + [CascadingParameter] private MudDialogInstance MudDialog { get; set; } + + [Parameter] [EditorRequired] public string ContentText { get; set; } + + private void Submit() => MudDialog.Close(DialogResult.Ok(true)); + + private void Cancel() => MudDialog.Cancel(); +} \ No newline at end of file diff --git a/NotamManagement.UI/Pages/HandledNotams.razor b/NotamManagement.UI/Pages/HandledNotams.razor index 055436f..3764771 100644 --- a/NotamManagement.UI/Pages/HandledNotams.razor +++ b/NotamManagement.UI/Pages/HandledNotams.razor @@ -28,6 +28,7 @@ [Inject] public Blazored.LocalStorage.ILocalStorageService LocalStorage { get; set; } = null!; [Inject] public ApiAuthenticationStateProvider ApiAuthenticationStateProvider { get; set; } = null!; [Inject] public NavigationManager NavigationManager { get; set; } = null!; + [Inject] public IDialogService DialogService { get; set; } = null!; private List NotamActions = []; @@ -48,11 +49,25 @@ } } - private void RemoveItemCallback(NotamAction notamAction) + private async Task RemoveItemCallback(NotamAction notamAction) { - NotamActions.Remove(notamAction); + var parameters = new DialogParameters + { + { x => x.ContentText, "Are you sure you want to delete this handled notam?" } + }; + + var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; + + var dialog = await DialogService.ShowAsync("Delete", parameters, options); + + var result = await dialog.Result; - Snackbar.Add("Notam Action Deleted!", Severity.Success); + if (!result.Canceled) + { + NotamActions.Remove(notamAction); + + Snackbar.Add("Notam Action Deleted!", Severity.Success); + } } private void UpdateItemCallback(NotamAction notamAction) diff --git a/NotamManagement.UI/_Imports.razor b/NotamManagement.UI/_Imports.razor index acc9c19..b31f30d 100644 --- a/NotamManagement.UI/_Imports.razor +++ b/NotamManagement.UI/_Imports.razor @@ -12,6 +12,7 @@ @using NotamManagement.UI.Pages.Components @using NotamManagement.UI.Layout @using NotamManagement.Core.Models +@using NotamManagement.UI.Pages.Dialogs @using NotamManagement.Core.Services @using MudBlazor @using System.Net.Http.Headers \ No newline at end of file