Add user manager page (#22)

Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
2025-04-27 20:49:57 +02:00
parent 033747899b
commit a2e93c9438
63 changed files with 1249 additions and 135 deletions

View File

@@ -0,0 +1,78 @@
using GameIdeas.BlazorApp.Pages.Games.Filter;
using GameIdeas.BlazorApp.Pages.Games.Gateways;
using GameIdeas.BlazorApp.Shared.Components.Popup;
using GameIdeas.BlazorApp.Shared.Models;
using GameIdeas.Shared.Dto;
using GameIdeas.Shared.Enum;
using Microsoft.AspNetCore.Components;
namespace GameIdeas.BlazorApp.Pages.Games;
public partial class Games
{
[Inject] private IGameGateway GameGateway { get; set; } = default!;
private DisplayType DisplayType = DisplayType.List;
private GameFilterParams GameFilter = new();
private Popup? ManualAddPopup;
private bool IsLoading = false;
private CategoriesDto? Categories;
private IEnumerable<GameDto> GamesDto = [];
private int CurrentPage;
protected override async Task OnInitializedAsync()
{
CurrentPage = 1;
GameFilter.SortType = Filter.GameFilter.SortTypes
.First(st => st.SortType == SortType.Ascending);
GameFilter.SortProperty= Filter.GameFilter.GameProperties
.First(gp => gp.PropertyName == nameof(GameIdeas.Shared.Model.Game.Title));
await HandleFetchDatas();
await base.OnInitializedAsync();
}
private void HandleAddClicked(AddType addType)
{
switch (addType)
{
case AddType.Manual:
ManualAddPopup?.Open();
break;
case AddType.Auto:
break;
default:
break;
}
}
private void HandleBackdropManualAddClicked()
{
ManualAddPopup?.Close();
}
private async Task HandleFetchDatas(bool loadCategories = true, bool displayLoader = true)
{
try
{
IsLoading = displayLoader;
if (loadCategories)
Categories = await GameGateway.FetchCategories();
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
}
catch (Exception)
{
throw;
}
finally
{
IsLoading = false;
}
}
private async Task HandleFilterChanged(GameFilterParams args)
{
GameFilter = args;
await HandleFetchDatas(loadCategories: false, displayLoader: false);
}
}