From 01ada94adbdba1d318c6c020e26ad28658a774fc Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Tue, 15 Apr 2025 12:18:31 +0200 Subject: [PATCH] Reload data on submit --- .../Pages/Games/Components/GameCreationForm.razor.cs | 2 ++ .../Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor | 2 +- .../GameIdeas.BlazorApp/Pages/Games/GameBase.razor.cs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs index 1e773d9..358d442 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/Components/GameCreationForm.razor.cs @@ -16,6 +16,7 @@ public partial class GameCreationForm [Inject] private IGameGateway GameGateway { get; set; } = default!; [CascadingParameter] private Popup? Popup { get; set; } [Parameter] public CategoriesDto? Categories { get; set; } + [Parameter] public EventCallback OnSubmit { get; set; } private GameDto GameDto = new(); private EditContext? EditContext; @@ -57,6 +58,7 @@ public partial class GameCreationForm if (gameId != 0) { Popup?.Close(); + await OnSubmit.InvokeAsync(); } } catch (Exception) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor index 404ea88..f06eaeb 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor @@ -25,5 +25,5 @@ - + diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor.cs index f00fdd0..e356f4a 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Pages/Games/GameBase.razor.cs @@ -17,7 +17,7 @@ public partial class GameBase () protected override async Task OnInitializedAsync() { - Categories = await GameGateway.FetchCategories(); + await HandleFetchCategories(); await base.OnInitializedAsync(); } private void HandleAddClicked(AddType addType) @@ -37,4 +37,8 @@ public partial class GameBase () { ManualAddPopup?.Close(); } + private async Task HandleFetchCategories() + { + Categories = await GameGateway.FetchCategories(); + } } \ No newline at end of file