From 83257d1d2a707979b2e8b22f5a2818d1b2d2e5c6 Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Fri, 28 Mar 2025 20:50:15 +0100 Subject: [PATCH] Add "All" prospects view and refine filtering logic Introduced a new "All" prospects page for admins to view and manage all prospects. Removed unused "Users" list and related logic from code. Updated filters to support the new "All" state and adjusted navigation to include the new page. --- FoodsharingSiegen.Contracts/Entity/Enums.cs | 2 + .../Controls/ProspectFilterControl.razor | 6 +- .../Pages/Prospects.razor.cs | 10 -- .../Pages/ProspectsAll.razor | 21 ++++ .../Pages/ProspectsAll.razor.cs | 108 ++++++++++++++++++ .../Pages/ProspectsVerify.razor.cs | 10 -- FoodsharingSiegen.Server/Shared/NavMenu.razor | 2 +- 7 files changed, 135 insertions(+), 24 deletions(-) create mode 100644 FoodsharingSiegen.Server/Pages/ProspectsAll.razor create mode 100644 FoodsharingSiegen.Server/Pages/ProspectsAll.razor.cs diff --git a/FoodsharingSiegen.Contracts/Entity/Enums.cs b/FoodsharingSiegen.Contracts/Entity/Enums.cs index 2f9a17f..9fac34e 100644 --- a/FoodsharingSiegen.Contracts/Entity/Enums.cs +++ b/FoodsharingSiegen.Contracts/Entity/Enums.cs @@ -92,6 +92,8 @@ namespace FoodsharingSiegen.Contracts.Entity public enum ProspectStateFilter { + All = 0, + OnBoarding = 10, Verification = 20, diff --git a/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor b/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor index 7d7e47d..5e53a5b 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor @@ -40,19 +40,19 @@ Suchfilter
- @if (StateFilter == ProspectStateFilter.OnBoarding) + @if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.All) {
Ohne @AppSettings.Terms.StepInName
} - @if (StateFilter == ProspectStateFilter.Verification) + @if (StateFilter is ProspectStateFilter.Verification or ProspectStateFilter.All) {
Perso noch nicht geprüft
} - @if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.Verification) + @if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.Verification or ProspectStateFilter.All) {
Lange keine Aktivität (6 Monate) diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs index bdb6f87..529b243 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs @@ -36,11 +36,6 @@ namespace FoodsharingSiegen.Server.Pages /// private List? ProspectList { get; set; } - /// - /// Gets or sets the value of the users (ab) - /// - private List? Users { get; set; } - #endregion #region Override InitializeDataAsync @@ -50,11 +45,6 @@ namespace FoodsharingSiegen.Server.Pages { // Load prospects await LoadProspects(); - - // Load users - var getUsersR = await UserService.GetUsersAsync(); - if (getUsersR.Success) - Users = getUsersR.Data; } #endregion diff --git a/FoodsharingSiegen.Server/Pages/ProspectsAll.razor b/FoodsharingSiegen.Server/Pages/ProspectsAll.razor new file mode 100644 index 0000000..bb3b6b0 --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/ProspectsAll.razor @@ -0,0 +1,21 @@ +@page "/all" + +@using FoodsharingSiegen.Shared.Helper +@inherits FsBase + +Freischalten - @AppSettings.Terms.Title + +

Freischalten

+ +@{ + var filterList = ProspectList.ApplyFilter(Filter); +} + +
+ +
+ + \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/ProspectsAll.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsAll.razor.cs new file mode 100644 index 0000000..52e1df6 --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/ProspectsAll.razor.cs @@ -0,0 +1,108 @@ +using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Contracts.Model; +using FoodsharingSiegen.Server.Data.Service; +using FoodsharingSiegen.Server.Dialogs; +using Microsoft.AspNetCore.Components; + +namespace FoodsharingSiegen.Server.Pages +{ + /// + /// The prospects done class (a. beging, 07.02.2023) + /// + public partial class ProspectsAll + { + #region Dependencies + + /// + /// Gets or sets the value of the prospect service (ab) + /// + [Inject] + public ProspectService ProspectService { get; set; } = null!; + + /// + /// Gets or sets the value of the user service (ab) + /// + [Inject] + public UserService UserService { get; set; } = null!; + + #endregion + + #region Private Properties + + private ProspectFilter Filter { get; set; } = new(); + + /// + /// Gets or sets the value of the prospect list (ab) + /// + private List? ProspectList { get; set; } + + #endregion + + #region Override InitializeDataAsync + + /// + protected override async Task InitializeDataAsync() + { + // Load prospects + await LoadProspects(); + } + + #endregion + + #region Private Method LoadProspects + + /// + /// Loads the prospects (a. beging, 11.04.2022) + /// + private async Task LoadProspects() + { + var parameter = new GetProspectsParameter(); + var prospectsR = await ProspectService.GetProspectsAsync(parameter); + if (prospectsR.Success) ProspectList = prospectsR.Data; + + await InvokeAsync(StateHasChanged); + } + + #endregion + + #region Private Method OnUpdateProspect + + /// + /// Ons the update prospect using the specified prospect (a. beging, 11.04.2022) + /// + /// The prospect + private async Task OnUpdateProspect(Prospect prospect) + { + var updateProspectR = await ProspectService.UpdateAsync(prospect); + if (updateProspectR.Success) await LoadProspects(); + } + + #endregion + + #region Private Method RemoveInteraction + + /// + /// Removes the interaction using the specified arg (a. beging, 11.04.2022) + /// + /// The arg + private async Task RemoveInteraction(Guid arg) + { + var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => + { + o.ConfirmButtonText = "Ja, wirklich!"; + o.CancelButtonText = "Abbrechen"; + o.ShowMessageIcon = false; + }); + + if (confirm) + { + await ProspectService.RemoveInteraction(arg); + await LoadProspects(); + } + + await InvokeAsync(StateHasChanged); + } + + #endregion + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs index c2772ed..338f07f 100644 --- a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs +++ b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor.cs @@ -35,11 +35,6 @@ namespace FoodsharingSiegen.Server.Pages /// Gets or sets the value of the prospect list (ab) /// private List? ProspectList { get; set; } - - /// - /// Gets or sets the value of the users (ab) - /// - private List? Users { get; set; } #endregion @@ -50,11 +45,6 @@ namespace FoodsharingSiegen.Server.Pages { // Load prospects await LoadProspects(); - - // Load users - var getUsersR = await UserService.GetUsersAsync(); - if (getUsersR.Success) - Users = getUsersR.Data; } #endregion diff --git a/FoodsharingSiegen.Server/Shared/NavMenu.razor b/FoodsharingSiegen.Server/Shared/NavMenu.razor index 8b3ce28..0c95e89 100644 --- a/FoodsharingSiegen.Server/Shared/NavMenu.razor +++ b/FoodsharingSiegen.Server/Shared/NavMenu.razor @@ -37,7 +37,7 @@