66using Microsoft . Extensions . Localization ;
77using Microsoft . FluentUI . AspNetCore . Components ;
88using Microsoft . FluentUI . AspNetCore . Components . Extensions ;
9+ using System . Collections . Frozen ;
910
1011namespace CodeBreaker . Blazor . Client . Pages ;
1112
@@ -14,6 +15,11 @@ public partial class ReportsPage
1415 private GameInfo [ ] ? _games ;
1516 private bool _isLoadingGames = false ;
1617 private DateTime ? _selectedDate = DateTime . Now ;
18+ private string ? _selectedGameTypeKey = null ;
19+ private string ? _enteredPlayerName = null ;
20+ private IDictionary < string , GameType ? > _gameTypes = null ! ;
21+
22+ private GameType ? SelectedGameType => string . IsNullOrEmpty ( _selectedGameTypeKey ) ? null : _gameTypes [ _selectedGameTypeKey ] ;
1723
1824 [ Inject ] private IDialogService DialogService { get ; set ; } = default ! ;
1925
@@ -25,6 +31,17 @@ public partial class ReportsPage
2531
2632 private string [ ] Headers => [ .. Loc . GetString ( "ReportsPage_Table_Headers" ) . Value . Split ( "," ) ] ;
2733
34+ protected override void OnInitialized ( )
35+ {
36+ _gameTypes = new Dictionary < string , GameType ? > ( ) {
37+ { Loc [ "ReportsPage_GameType_All" ] , null } ,
38+ { "6x4" , GameType . Game6x4 } ,
39+ { "6x4 Mini" , GameType . Game6x4Mini } ,
40+ { "8x5" , GameType . Game8x5 } ,
41+ { "5x5x4" , GameType . Game5x5x4 } ,
42+ } . ToFrozenDictionary ( ) ;
43+ }
44+
2845 public async Task GetGamesAsync ( )
2946 {
3047 var date = _selectedDate . ToDateOnly ( ) ;
@@ -33,7 +50,7 @@ public async Task GetGamesAsync()
3350 _isLoadingGames = true ;
3451 try
3552 {
36- var query = new GamesQuery ( Date : date , Ended : true ) ;
53+ var query = new GamesQuery ( Date : date , Ended : true , GameType : SelectedGameType , PlayerName : _enteredPlayerName ) ;
3754 var response = await GameClient . GetGamesAsync ( query ) ;
3855 Logger ? . LogDebug ( "Got response: {response}" , response ) ;
3956 _games = [ ..response ?? [ ] ] ;
0 commit comments