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(); } }