diff --git a/MidrandBookshop/Components/Pages/Home.razor b/MidrandBookshop/Components/Pages/Home.razor
index 06a0c4c..200d1a8 100644
--- a/MidrandBookshop/Components/Pages/Home.razor
+++ b/MidrandBookshop/Components/Pages/Home.razor
@@ -217,133 +217,3 @@
-
-@code {
- public enum ViewMode { Grid, List }
- private ViewMode CurrentViewMode = ViewMode.Grid;
-
- [CascadingParameter]
- public string SharedSearchQuery { get; set; } = string.Empty;
-
- private string ActiveCategory = "All";
- private bool ShowExpandedCategories = false;
- private bool ShowFilterMenu = false;
-
- private string SelectedSortOption = "default";
- private string ActivePriceFilter = "all";
- private bool OnlyShowNew = false;
-
- private List MainCategories = new() { "All", "Graphic Design", "Product Design", "Architecture" };
- private List DynamicExtendedCategories = new();
-
- private int ItemsPerPage = 12;
- private int VisibleCount = 12;
-
- public class BookItem
- {
- public long Id { get; set; } // Refactored to hold unique record indices of type long
- public string Title { get; set; } = string.Empty;
- public string Author { get; set; } = string.Empty;
- public decimal Price { get; set; }
- public string Category { get; set; } = string.Empty;
- public bool IsNew { get; set; }
- public string Isbn { get; set; } = string.Empty;
- }
-
- private List BooksCollection = new();
-
- private IEnumerable FilteredData
- {
- get
- {
- var data = BooksCollection.AsEnumerable();
-
- if (!string.IsNullOrWhiteSpace(SharedSearchQuery))
- {
- var q = SharedSearchQuery.Trim();
- data = data.Where(b =>
- b.Title.Contains(q, StringComparison.OrdinalIgnoreCase) ||
- b.Author.Contains(q, StringComparison.OrdinalIgnoreCase) ||
- b.Isbn.Contains(q, StringComparison.OrdinalIgnoreCase)
- );
- }
-
- if (ActiveCategory != "All")
- {
- data = data.Where(b => b.Category.Equals(ActiveCategory, StringComparison.OrdinalIgnoreCase));
- }
-
- if (OnlyShowNew) { data = data.Where(b => b.IsNew); }
-
- data = ActivePriceFilter switch
- {
- "under-500" => data.Where(b => b.Price < 500),
- "500-1000" => data.Where(b => b.Price >= 500 && b.Price <= 1000),
- "over-1000" => data.Where(b => b.Price > 1000),
- _ => data
- };
-
- return data;
- }
- }
-
- private IEnumerable SortedAndFilteredBooks => SelectedSortOption switch
- {
- "price-low" => FilteredData.OrderBy(b => b.Price),
- "price-high" => FilteredData.OrderByDescending(b => b.Price),
- "title-asc" => FilteredData.OrderBy(b => b.Title),
- _ => FilteredData
- };
-
- private IEnumerable PaginatedBooks => SortedAndFilteredBooks.Take(VisibleCount);
- private int TotalFilteredCount => FilteredData.Count();
- private bool HasMoreItems => VisibleCount < TotalFilteredCount;
-
- protected override void OnInitialized()
- {
- var extraSourceCategories = new[] { "Fine Arts", "Science", "Photography", "Typography", "Interior Design", "Industrialism", "Fashion", "Curation Studies" };
- DynamicExtendedCategories.AddRange(extraSourceCategories);
-
- // Updated mock items to supply long IDs matching your screenshot items
- BooksCollection.Add(new BookItem { Id = 1L, Title = "Letters from M/M (Paris)", Author = "M/M Paris", Price = 720, Category = "Graphic Design", IsNew = true, Isbn = "9782915173" });
- BooksCollection.Add(new BookItem { Id = 2L, Title = "Daan Paans: Floating Signifiers", Author = "Daan Paans", Price = 540, Category = "Product Design", IsNew = true, Isbn = "9789492051" });
- BooksCollection.Add(new BookItem { Id = 3L, Title = "Album Architectures, Maputo", Author = "Guedes Archive", Price = 350, Category = "Architecture", IsNew = true, Isbn = "9780620751" });
-
- var designPrefixes = new[] { "Minimalist", "Monolithic", "Architectural", "Japanese", "Scandinavian" };
- var designNouns = new[] { "Structures", "Typologies", "Forms & Spaces", "Systems Matrix", "Graphic Ephemera" };
- var designers = new[] { "J. Morrison", "K. Fujita", "Studio Bouroullec", "Es Devlin", "Kenya Hara" };
-
- var entireCategoryPool = MainCategories.Concat(DynamicExtendedCategories).Where(c => c != "All").ToArray();
- var random = new Random(42);
-
- for (int i = 4; i <= 60; i++)
- {
- BooksCollection.Add(new BookItem
- {
- Id = (long)i,
- Title = $"{designPrefixes[random.Next(designPrefixes.Length)]} {designNouns[random.Next(designNouns.Length)]} (Vol. {random.Next(1, 4)})",
- Author = designers[random.Next(designers.Length)],
- Price = random.Next(25, 135) * 10,
- Category = entireCategoryPool[random.Next(entireCategoryPool.Length)],
- IsNew = random.NextDouble() > 0.7,
- Isbn = $"978000000{i}"
- });
- }
- }
-
- // Handles the explicit page transition routing
- private void NavigateToProduct(long id)
- {
- Navigation.NavigateTo($"/product/{id}");
- }
-
- private void SetViewMode(ViewMode targetMode) => CurrentViewMode = targetMode;
- private void SelectCategory(string categoryName) { ActiveCategory = categoryName; VisibleCount = ItemsPerPage; }
- private void ToggleExtraCategories() => ShowExpandedCategories = !ShowExpandedCategories;
- private void ToggleFilterMenu() => ShowFilterMenu = !ShowFilterMenu;
- private void ChangeSort(string sortOption) => SelectedSortOption = sortOption;
- private void ChangePriceFilter(string priceBracket) { ActivePriceFilter = priceBracket; VisibleCount = ItemsPerPage; }
- private void ToggleNewArrivalsOnly(ChangeEventArgs e) { OnlyShowNew = e.Value is bool b && b; VisibleCount = ItemsPerPage; }
- private void ResetFilters() { SelectedSortOption = "default"; ActivePriceFilter = "all"; OnlyShowNew = false; VisibleCount = ItemsPerPage; }
- private void LoadNextPage() { if (HasMoreItems) VisibleCount += ItemsPerPage; }
-}
\ No newline at end of file
diff --git a/MidrandBookshop/Components/Pages/Home.razor.cs b/MidrandBookshop/Components/Pages/Home.razor.cs
new file mode 100644
index 0000000..780545c
--- /dev/null
+++ b/MidrandBookshop/Components/Pages/Home.razor.cs
@@ -0,0 +1,112 @@
+using LiteCharms.Features.MidrandBooks.AuthorBooks;
+using MidrandBookshop.Models;
+
+namespace MidrandBookshop.Components.Pages;
+
+public partial class Home(BooksService booksService)
+{
+ [CascadingParameter]
+ public string SharedSearchQuery { get; set; } = string.Empty;
+
+ public enum ViewMode { Grid, List }
+
+ private ViewMode CurrentViewMode = ViewMode.Grid;
+ private string ActiveCategory = "All";
+ private bool ShowExpandedCategories = false;
+ private bool ShowFilterMenu = false;
+ private string SelectedSortOption = "default";
+ private string ActivePriceFilter = "all";
+ private bool OnlyShowNew = false;
+ private List MainCategories = ["All", "Graphic Design", "Product Design", "Architecture"];
+ private List DynamicExtendedCategories = [];
+ private int ItemsPerPage = 12;
+ private int VisibleCount = 12;
+ private List BooksCollection = [];
+ private IEnumerable FilteredData
+ {
+ get
+ {
+ var data = BooksCollection.AsEnumerable();
+
+ if (!string.IsNullOrWhiteSpace(SharedSearchQuery))
+ {
+ var q = SharedSearchQuery.Trim();
+ data = data.Where(b =>
+ b.Title.Contains(q, StringComparison.OrdinalIgnoreCase) ||
+ b.Author.Contains(q, StringComparison.OrdinalIgnoreCase) ||
+ b.Isbn.Contains(q, StringComparison.OrdinalIgnoreCase)
+ );
+ }
+
+ if (ActiveCategory != "All")
+ {
+ data = data.Where(b => b.Category.Equals(ActiveCategory, StringComparison.OrdinalIgnoreCase));
+ }
+
+ if (OnlyShowNew) { data = data.Where(b => b.IsNew); }
+
+ data = ActivePriceFilter switch
+ {
+ "under-500" => data.Where(b => b.Price < 500),
+ "500-1000" => data.Where(b => b.Price >= 500 && b.Price <= 1000),
+ "over-1000" => data.Where(b => b.Price > 1000),
+ _ => data
+ };
+
+ return data;
+ }
+ }
+ private IEnumerable SortedAndFilteredBooks => SelectedSortOption switch
+ {
+ "price-low" => FilteredData.OrderBy(b => b.Price),
+ "price-high" => FilteredData.OrderByDescending(b => b.Price),
+ "title-asc" => FilteredData.OrderBy(b => b.Title),
+ _ => FilteredData
+ };
+ private IEnumerable PaginatedBooks => SortedAndFilteredBooks.Take(VisibleCount);
+ private int TotalFilteredCount => FilteredData.Count();
+ private bool HasMoreItems => VisibleCount < TotalFilteredCount;
+
+ protected override void OnInitialized()
+ {
+ var extraSourceCategories = new[] { "Fine Arts", "Science", "Photography", "Typography", "Interior Design", "Industrialism", "Fashion", "Curation Studies" };
+ DynamicExtendedCategories.AddRange(extraSourceCategories);
+
+ // Updated mock items to supply long IDs matching your screenshot items
+ BooksCollection.Add(new BookItem { Id = 1L, Title = "Letters from M/M (Paris)", Author = "M/M Paris", Price = 720, Category = "Graphic Design", IsNew = true, Isbn = "9782915173" });
+ BooksCollection.Add(new BookItem { Id = 2L, Title = "Daan Paans: Floating Signifiers", Author = "Daan Paans", Price = 540, Category = "Product Design", IsNew = true, Isbn = "9789492051" });
+ BooksCollection.Add(new BookItem { Id = 3L, Title = "Album Architectures, Maputo", Author = "Guedes Archive", Price = 350, Category = "Architecture", IsNew = true, Isbn = "9780620751" });
+
+ var designPrefixes = new[] { "Minimalist", "Monolithic", "Architectural", "Japanese", "Scandinavian" };
+ var designNouns = new[] { "Structures", "Typologies", "Forms & Spaces", "Systems Matrix", "Graphic Ephemera" };
+ var designers = new[] { "J. Morrison", "K. Fujita", "Studio Bouroullec", "Es Devlin", "Kenya Hara" };
+
+ var entireCategoryPool = MainCategories.Concat(DynamicExtendedCategories).Where(c => c != "All").ToArray();
+ var random = new Random(42);
+
+ for (int i = 4; i <= 60; i++)
+ {
+ BooksCollection.Add(new BookItem
+ {
+ Id = (long)i,
+ Title = $"{designPrefixes[random.Next(designPrefixes.Length)]} {designNouns[random.Next(designNouns.Length)]} (Vol. {random.Next(1, 4)})",
+ Author = designers[random.Next(designers.Length)],
+ Price = random.Next(25, 135) * 10,
+ Category = entireCategoryPool[random.Next(entireCategoryPool.Length)],
+ IsNew = random.NextDouble() > 0.7,
+ Isbn = $"978000000{i}"
+ });
+ }
+ }
+
+ private void NavigateToProduct(long id) => Navigation.NavigateTo($"/product/{id}");
+ private void SetViewMode(ViewMode targetMode) => CurrentViewMode = targetMode;
+ private void SelectCategory(string categoryName) { ActiveCategory = categoryName; VisibleCount = ItemsPerPage; }
+ private void ToggleExtraCategories() => ShowExpandedCategories = !ShowExpandedCategories;
+ private void ToggleFilterMenu() => ShowFilterMenu = !ShowFilterMenu;
+ private void ChangeSort(string sortOption) => SelectedSortOption = sortOption;
+ private void ChangePriceFilter(string priceBracket) { ActivePriceFilter = priceBracket; VisibleCount = ItemsPerPage; }
+ private void ToggleNewArrivalsOnly(ChangeEventArgs e) { OnlyShowNew = e.Value is bool b && b; VisibleCount = ItemsPerPage; }
+ private void ResetFilters() { SelectedSortOption = "default"; ActivePriceFilter = "all"; OnlyShowNew = false; VisibleCount = ItemsPerPage; }
+ private void LoadNextPage() { if (HasMoreItems) VisibleCount += ItemsPerPage; }
+}
diff --git a/MidrandBookshop/MidrandBookshop.csproj b/MidrandBookshop/MidrandBookshop.csproj
index 23c37e0..8e86827 100644
--- a/MidrandBookshop/MidrandBookshop.csproj
+++ b/MidrandBookshop/MidrandBookshop.csproj
@@ -51,6 +51,7 @@
+
diff --git a/MidrandBookshop/Models/BookItem.cs b/MidrandBookshop/Models/BookItem.cs
new file mode 100644
index 0000000..c2f93da
--- /dev/null
+++ b/MidrandBookshop/Models/BookItem.cs
@@ -0,0 +1,12 @@
+namespace MidrandBookshop.Models;
+
+public class BookItem
+{
+ public long Id { get; set; } // Refactored to hold unique record indices of type long
+ public string Title { get; set; } = string.Empty;
+ public string Author { get; set; } = string.Empty;
+ public decimal Price { get; set; }
+ public string Category { get; set; } = string.Empty;
+ public bool IsNew { get; set; }
+ public string Isbn { get; set; } = string.Empty;
+}