Files
game-ideas/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/GameBaseComponent.cs
Egamorf 1baa2a73fe
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m16s
Fix gitea issues (#54)
Co-authored-by: Maxime Adler <madler@sqli.com>
Reviewed-on: #54
2025-05-18 16:27:56 +02:00

61 lines
1.4 KiB
C#

using GameIdeas.BlazorApp.Pages.Games.Gateways;
using GameIdeas.BlazorApp.Shared.Models;
using GameIdeas.Shared.Dto;
using Microsoft.AspNetCore.Components;
namespace GameIdeas.BlazorApp.Shared.Components;
public class GameBaseComponent : ComponentBase
{
[Inject] protected IGameGateway GameGateway { get; set; } = default!;
protected Popup.Popup? ManualAddPopup;
protected CategoriesDto? Categories;
protected bool IsLoading = false;
protected override async Task OnInitializedAsync()
{
await HandleFetchCategories();
await base.OnInitializedAsync();
}
protected async Task HandleFetchCategories()
{
try
{
IsLoading = true;
StateHasChanged();
Categories = await GameGateway.FetchCategories();
}
catch (Exception)
{
throw;
}
finally
{
IsLoading = false;
StateHasChanged();
}
}
protected void HandleAddClicked(AddType addType)
{
switch (addType)
{
case AddType.Manual:
ManualAddPopup?.Open();
break;
case AddType.Auto:
break;
default:
break;
}
}
protected void HandleBackdropManualAddClicked()
{
ManualAddPopup?.Close();
}
}