diff --git a/Pages/UserListPanel.razor b/Pages/UserListPanel.razor index 3590a63..b03faff 100644 --- a/Pages/UserListPanel.razor +++ b/Pages/UserListPanel.razor @@ -1,5 +1,6 @@ @page "/users" @using AdminPanel.Models +@using System.ComponentModel.DataAnnotations User Panel @@ -9,9 +10,22 @@ - - - + + + Cancel @@ -27,18 +41,18 @@ Remove Selection - - + + CommittedItemChanges="OnAccountUpdated"> diff --git a/Pages/UserListPanel.razor.cs b/Pages/UserListPanel.razor.cs index 562262f..7d4904d 100644 --- a/Pages/UserListPanel.razor.cs +++ b/Pages/UserListPanel.razor.cs @@ -1,5 +1,4 @@ -using System.ComponentModel; -using AdminPanel.Models; +using AdminPanel.Models; using AdminPanel.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; @@ -12,6 +11,9 @@ namespace AdminPanel.Pages [Inject] public ISnackbar Snackbar { get; private init; } [Inject] public IUsersService Service { get; private init; } + private MudDataGrid Grid { get; set; } + + private HashSet SelectedItems { get; set; } = new(); private string? FormAccountName { get; set; } @@ -33,7 +35,7 @@ namespace AdminPanel.Pages } - private async void OnAccountEdited(User user) + private async void OnAccountUpdated(User user) { Console.WriteLine(user.IsAdmin); try @@ -42,7 +44,8 @@ namespace AdminPanel.Pages } catch (Exception) { - Snackbar.Add("Server responded with errors, your given input may be incorrect.\nIf you entered a new email, verify that the email is not used by another member."); + Snackbar.Add( + "Server responded with errors, your given input may be incorrect.\nIf you entered a new email, verify that the email is not used by another member."); } } @@ -55,7 +58,7 @@ namespace AdminPanel.Pages { await Service.AddUser(FormAccountName!, FormAccountEmail!, FormAccountPassword!, FormAccountIsAdmin); - StateHasChanged(); + await Grid.ReloadServerData(); } catch (Exception) { @@ -70,11 +73,17 @@ namespace AdminPanel.Pages try { await Service.RemoveUsers(items); + await Grid.ReloadServerData(); } catch (Exception) { Snackbar.Add("Server responded with errors"); } } + + private Func VerifyLength(uint min, uint max) + { + return s => (s.Length >= min && s.Length <= max) ? null : $"length is incorrect (must be between {min} and {max})"; + } } } \ No newline at end of file