diff --git a/FoodsharingSiegen.Contracts/StorageKeys.cs b/FoodsharingSiegen.Contracts/StorageKeys.cs
index dc09f46..c3334ad 100644
--- a/FoodsharingSiegen.Contracts/StorageKeys.cs
+++ b/FoodsharingSiegen.Contracts/StorageKeys.cs
@@ -5,9 +5,18 @@ namespace FoodsharingSiegen.Contracts
///
public static class StorageKeys
{
+ #region Constants
+
///
- /// The token key
+ /// Represents the storage key used for prospect filtering preferences.
+ ///
+ public const string ProspectFilter = "ProspectFilter";
+
+ ///
+ /// The token key
///
public const string TokenKey = "_token";
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs
index f7120ad..458357a 100644
--- a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs
+++ b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs
@@ -3,6 +3,7 @@ using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Auth;
using FoodsharingSiegen.Server.Data.Service;
+using FoodsharingSiegen.Server.Service;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
@@ -31,6 +32,12 @@ namespace FoodsharingSiegen.Server.BaseClasses
[Inject]
protected AuthService AuthService { get; set; } = null!;
+ ///
+ /// Gets or sets the service that interacts with the browser's local storage.
+ ///
+ [Inject]
+ protected LocalStorageService LocalStorageService { get; set; } = null!;
+
///
/// Gets or sets the modal service for handling modals within the application
///
diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor
index 78b736d..1e4370a 100644
--- a/FoodsharingSiegen.Server/Pages/Prospects.razor
+++ b/FoodsharingSiegen.Server/Pages/Prospects.razor
@@ -26,7 +26,7 @@
}
-
+
- /// Gets or sets the value of the prospect service (ab)
- ///
[Inject]
- public ProspectService ProspectService { get; set; } = null!;
+ private ProspectService ProspectService { get; set; } = null!;
///
/// Gets or sets the value of the user service (ab)
///
[Inject]
- public UserService UserService { get; set; } = null!;
+ private UserService UserService { get; set; } = null!;
#endregion
@@ -44,6 +43,9 @@ namespace FoodsharingSiegen.Server.Pages
///
protected override async Task InitializeDataAsync()
{
+ var filter = await LocalStorageService.GetItem(StorageKeys.ProspectFilter);
+ if (filter != null) Filter = filter;
+
// Load prospects
await LoadProspects();
}
@@ -63,6 +65,21 @@ namespace FoodsharingSiegen.Server.Pages
#endregion
+ #region Private Method FilterChangedAsync
+
+ ///
+ /// Updates the current filter with the specified ProspectFilter object.
+ ///
+ /// The ProspectFilter object containing the updated filter criteria.
+ /// A task that represents the asynchronous operation.
+ private async Task FilterChangedAsync(ProspectFilter arg)
+ {
+ Filter = arg;
+ await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
+ }
+
+ #endregion
+
#region Private Method LoadProspects
///
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsAll.razor b/FoodsharingSiegen.Server/Pages/ProspectsAll.razor
index 6051744..83f6222 100644
--- a/FoodsharingSiegen.Server/Pages/ProspectsAll.razor
+++ b/FoodsharingSiegen.Server/Pages/ProspectsAll.razor
@@ -17,7 +17,7 @@
}
-
+
(StorageKeys.ProspectFilter);
+ if (filter != null) Filter = filter;
+
// Load prospects
await LoadProspects();
}
#endregion
+ #region Private Method FilterChangedAsync
+
+ ///
+ /// Updates the current filter with the specified ProspectFilter object.
+ ///
+ /// The ProspectFilter object containing the updated filter criteria.
+ /// A task that represents the asynchronous operation.
+ private async Task FilterChangedAsync(ProspectFilter arg)
+ {
+ Filter = arg;
+ await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
+ }
+
+ #endregion
+
#region Private Method LoadProspects
///
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor
index 0a5fbbf..e52c6db 100644
--- a/FoodsharingSiegen.Server/Pages/ProspectsDone.razor
+++ b/FoodsharingSiegen.Server/Pages/ProspectsDone.razor
@@ -17,7 +17,7 @@
}
-
+
protected override async Task InitializeDataAsync()
{
+ // Load Filter
+ var filter = await LocalStorageService.GetItem(StorageKeys.ProspectFilter);
+ if (filter != null) Filter = filter;
+
await LoadProspects();
}
#endregion
+ #region Private Method FilterChangedAsync
+
+ ///
+ /// Updates the current filter with the specified ProspectFilter object.
+ ///
+ /// The ProspectFilter object containing the updated filter criteria.
+ /// A task that represents the asynchronous operation.
+ private async Task FilterChangedAsync(ProspectFilter arg)
+ {
+ Filter = arg;
+ await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
+ }
+
+ #endregion
+
#region Private Method LoadProspects
///
diff --git a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor
index 829f783..2c6e686 100644
--- a/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor
+++ b/FoodsharingSiegen.Server/Pages/ProspectsVerify.razor
@@ -17,7 +17,7 @@
}
-
+
protected override async Task InitializeDataAsync()
{
+ // Load Filter
+ var filter = await LocalStorageService.GetItem(StorageKeys.ProspectFilter);
+ if (filter != null) Filter = filter;
+
// Load prospects
await LoadProspects();
}
#endregion
+ #region Private Method FilterChangedAsync
+
+ ///
+ /// Updates the current filter with the specified ProspectFilter object.
+ ///
+ /// The ProspectFilter object containing the updated filter criteria.
+ /// A task that represents the asynchronous operation.
+ private async Task FilterChangedAsync(ProspectFilter arg)
+ {
+ Filter = arg;
+ await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
+ }
+
+ #endregion
+
#region Private Method LoadProspects
///