All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m16s
Co-authored-by: Maxime Adler <madler@sqli.com> Reviewed-on: #54
61 lines
1.4 KiB
C#
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();
|
|
}
|
|
}
|