be-components 4.5.5 → 4.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/lib/commonjs/Bracket/api/index.js +15 -5
  2. package/lib/commonjs/Bracket/api/index.js.map +1 -1
  3. package/lib/commonjs/Bracket/components/BracketCompetitionActions.js +17 -12
  4. package/lib/commonjs/Bracket/components/BracketCompetitionActions.js.map +1 -1
  5. package/lib/commonjs/Bracket/components/BracketCompetitionCard.js +1 -0
  6. package/lib/commonjs/Bracket/components/BracketCompetitionCard.js.map +1 -1
  7. package/lib/commonjs/Bracket/components/BracketPlay/BracketRound.js +2 -0
  8. package/lib/commonjs/Bracket/components/BracketPlay/BracketRound.js.map +1 -1
  9. package/lib/commonjs/Bracket/components/BracketPlay/index.js +0 -8
  10. package/lib/commonjs/Bracket/components/BracketPlay/index.js.map +1 -1
  11. package/lib/commonjs/Bracket/components/EditPlayerBracket.js +32 -3
  12. package/lib/commonjs/Bracket/components/EditPlayerBracket.js.map +1 -1
  13. package/lib/commonjs/Bracket/components/EnteredCompetitionsModal.js +197 -0
  14. package/lib/commonjs/Bracket/components/EnteredCompetitionsModal.js.map +1 -0
  15. package/lib/commonjs/Bracket/components/JoinCompetitionCard.js +78 -3
  16. package/lib/commonjs/Bracket/components/JoinCompetitionCard.js.map +1 -1
  17. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js +3 -3
  18. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  19. package/lib/commonjs/Bracket/components/PlayerBracketCard.js +21 -4
  20. package/lib/commonjs/Bracket/components/PlayerBracketCard.js.map +1 -1
  21. package/lib/commonjs/Bracket/components/PlayerBrackets.js +27 -4
  22. package/lib/commonjs/Bracket/components/PlayerBrackets.js.map +1 -1
  23. package/lib/commonjs/Bracket/components/RoomHome.js +436 -117
  24. package/lib/commonjs/Bracket/components/RoomHome.js.map +1 -1
  25. package/lib/commonjs/Bracket/index.js +254 -420
  26. package/lib/commonjs/Bracket/index.js.map +1 -1
  27. package/lib/commonjs/Competition/components/EnterCompetitionPrompt.js.map +1 -1
  28. package/lib/commonjs/Engage/index.js.map +1 -1
  29. package/lib/module/Bracket/api/index.js +15 -5
  30. package/lib/module/Bracket/api/index.js.map +1 -1
  31. package/lib/module/Bracket/components/BracketCompetitionActions.js +18 -13
  32. package/lib/module/Bracket/components/BracketCompetitionActions.js.map +1 -1
  33. package/lib/module/Bracket/components/BracketCompetitionCard.js +1 -0
  34. package/lib/module/Bracket/components/BracketCompetitionCard.js.map +1 -1
  35. package/lib/module/Bracket/components/BracketPlay/BracketRound.js +2 -0
  36. package/lib/module/Bracket/components/BracketPlay/BracketRound.js.map +1 -1
  37. package/lib/module/Bracket/components/BracketPlay/index.js +0 -8
  38. package/lib/module/Bracket/components/BracketPlay/index.js.map +1 -1
  39. package/lib/module/Bracket/components/EditPlayerBracket.js +33 -4
  40. package/lib/module/Bracket/components/EditPlayerBracket.js.map +1 -1
  41. package/lib/module/Bracket/components/EnteredCompetitionsModal.js +190 -0
  42. package/lib/module/Bracket/components/EnteredCompetitionsModal.js.map +1 -0
  43. package/lib/module/Bracket/components/JoinCompetitionCard.js +78 -3
  44. package/lib/module/Bracket/components/JoinCompetitionCard.js.map +1 -1
  45. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js +3 -3
  46. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  47. package/lib/module/Bracket/components/PlayerBracketCard.js +21 -4
  48. package/lib/module/Bracket/components/PlayerBracketCard.js.map +1 -1
  49. package/lib/module/Bracket/components/PlayerBrackets.js +28 -5
  50. package/lib/module/Bracket/components/PlayerBrackets.js.map +1 -1
  51. package/lib/module/Bracket/components/RoomHome.js +438 -119
  52. package/lib/module/Bracket/components/RoomHome.js.map +1 -1
  53. package/lib/module/Bracket/index.js +255 -421
  54. package/lib/module/Bracket/index.js.map +1 -1
  55. package/lib/module/Competition/components/EnterCompetitionPrompt.js.map +1 -1
  56. package/lib/module/Engage/index.js.map +1 -1
  57. package/lib/typescript/lib/commonjs/Bracket/api/index.d.ts +6 -1
  58. package/lib/typescript/lib/commonjs/Bracket/api/index.d.ts.map +1 -1
  59. package/lib/typescript/lib/commonjs/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  60. package/lib/typescript/lib/commonjs/Bracket/components/BracketCompetitionCard.d.ts.map +1 -1
  61. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/BracketRound.d.ts.map +1 -1
  62. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts +1 -2
  63. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  64. package/lib/typescript/lib/commonjs/Bracket/components/EditPlayerBracket.d.ts +3 -1
  65. package/lib/typescript/lib/commonjs/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  66. package/lib/typescript/lib/commonjs/Bracket/components/EnteredCompetitionsModal.d.ts +14 -0
  67. package/lib/typescript/lib/commonjs/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  68. package/lib/typescript/lib/commonjs/Bracket/components/JoinCompetitionCard.d.ts +2 -1
  69. package/lib/typescript/lib/commonjs/Bracket/components/JoinCompetitionCard.d.ts.map +1 -1
  70. package/lib/typescript/lib/commonjs/Bracket/components/PlayerBrackets.d.ts +4 -1
  71. package/lib/typescript/lib/commonjs/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  72. package/lib/typescript/lib/commonjs/Bracket/components/RoomHome.d.ts +4 -14
  73. package/lib/typescript/lib/commonjs/Bracket/components/RoomHome.d.ts.map +1 -1
  74. package/lib/typescript/lib/commonjs/Bracket/index.d.ts.map +1 -1
  75. package/lib/typescript/lib/module/Bracket/api/index.d.ts +6 -1
  76. package/lib/typescript/lib/module/Bracket/api/index.d.ts.map +1 -1
  77. package/lib/typescript/lib/module/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  78. package/lib/typescript/lib/module/Bracket/components/BracketCompetitionCard.d.ts.map +1 -1
  79. package/lib/typescript/lib/module/Bracket/components/BracketPlay/BracketRound.d.ts.map +1 -1
  80. package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts +1 -2
  81. package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  82. package/lib/typescript/lib/module/Bracket/components/EditPlayerBracket.d.ts +5 -2
  83. package/lib/typescript/lib/module/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  84. package/lib/typescript/lib/module/Bracket/components/EnteredCompetitionsModal.d.ts +15 -0
  85. package/lib/typescript/lib/module/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  86. package/lib/typescript/lib/module/Bracket/components/JoinCompetitionCard.d.ts +2 -1
  87. package/lib/typescript/lib/module/Bracket/components/JoinCompetitionCard.d.ts.map +1 -1
  88. package/lib/typescript/lib/module/Bracket/components/PlayerBracketCard.d.ts +3 -1
  89. package/lib/typescript/lib/module/Bracket/components/PlayerBracketCard.d.ts.map +1 -1
  90. package/lib/typescript/lib/module/Bracket/components/PlayerBrackets.d.ts +6 -2
  91. package/lib/typescript/lib/module/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  92. package/lib/typescript/lib/module/Bracket/components/RoomHome.d.ts +4 -14
  93. package/lib/typescript/lib/module/Bracket/components/RoomHome.d.ts.map +1 -1
  94. package/lib/typescript/lib/module/Bracket/index.d.ts.map +1 -1
  95. package/lib/typescript/src/Bracket/api/index.d.ts +5 -1
  96. package/lib/typescript/src/Bracket/api/index.d.ts.map +1 -1
  97. package/lib/typescript/src/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  98. package/lib/typescript/src/Bracket/components/BracketCompetitionCard.d.ts.map +1 -1
  99. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts +1 -2
  100. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  101. package/lib/typescript/src/Bracket/components/EditPlayerBracket.d.ts +8 -1
  102. package/lib/typescript/src/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  103. package/lib/typescript/src/Bracket/components/EnteredCompetitionsModal.d.ts +21 -0
  104. package/lib/typescript/src/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  105. package/lib/typescript/src/Bracket/components/JoinCompetitionCard.d.ts +2 -1
  106. package/lib/typescript/src/Bracket/components/JoinCompetitionCard.d.ts.map +1 -1
  107. package/lib/typescript/src/Bracket/components/PlayerBracketCard.d.ts +3 -2
  108. package/lib/typescript/src/Bracket/components/PlayerBracketCard.d.ts.map +1 -1
  109. package/lib/typescript/src/Bracket/components/PlayerBrackets.d.ts +9 -1
  110. package/lib/typescript/src/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  111. package/lib/typescript/src/Bracket/components/RoomHome.d.ts +11 -18
  112. package/lib/typescript/src/Bracket/components/RoomHome.d.ts.map +1 -1
  113. package/lib/typescript/src/Bracket/index.d.ts.map +1 -1
  114. package/lib/typescript/src/Engage/index.d.ts.map +1 -1
  115. package/package.json +1 -1
  116. package/src/Bracket/api/index.ts +10 -5
  117. package/src/Bracket/components/BracketCompetitionActions.tsx +14 -12
  118. package/src/Bracket/components/BracketCompetitionCard.tsx +1 -0
  119. package/src/Bracket/components/BracketPlay/BracketRound.tsx +2 -2
  120. package/src/Bracket/components/BracketPlay/index.tsx +13 -18
  121. package/src/Bracket/components/EditPlayerBracket.tsx +58 -42
  122. package/src/Bracket/components/EnteredCompetitionsModal.tsx +113 -0
  123. package/src/Bracket/components/JoinCompetitionCard.tsx +46 -3
  124. package/src/Bracket/components/ManageBracketCompetitionForm.tsx +3 -3
  125. package/src/Bracket/components/PlayerBracketCard.tsx +9 -4
  126. package/src/Bracket/components/PlayerBrackets.tsx +45 -33
  127. package/src/Bracket/components/RoomHome.tsx +356 -117
  128. package/src/Bracket/index.tsx +277 -402
  129. package/src/Competition/components/EnterCompetitionPrompt.tsx +1 -1
  130. package/src/Engage/index.tsx +1 -0
  131. package/src/types.d.ts +1 -0
@@ -1,38 +1,28 @@
1
- import React, { useCallback, useMemo, useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { Button, Text, View } from '../../Components/Themed';
3
- import type { AthleteProps, BracketCompetitionProps, BracketProps, CompetitionPlayerBracketProps, CompetitionResultTypeProps, LeagueProps, MyPlayerProps, PlayerBracketProps, TeamProps } from '../../types';
3
+ import type { AthleteProps, BracketCompetitionProps, BracketProps, CompetitionPlayerBracketProps, LeagueProps, MyPlayerProps, PlayerBracketProps, TeamProps } from '../../types';
4
4
  import { FlatList, Image } from 'react-native';
5
5
  import PlayerBracketCard from './PlayerBracketCard';
6
6
  import SearchBox from '../../Components/SearchBox';
7
7
  import { Icons, Toggle } from '../../Components';
8
8
  import { useColors } from '../../constants/useColors';
9
9
  import moment from 'moment-mini';
10
- import { BracketComeptitionApi } from '../api';
10
+ import { BracketApi, BracketComeptitionApi, BracketCompetitionHelpers } from '../api';
11
+ import EditPlayerBracket from './EditPlayerBracket';
12
+ import EnteredCompetitionsModal from './EnteredCompetitionsModal';
11
13
 
12
14
  type RoomHomeProps = {
13
15
  player?:MyPlayerProps,
14
- visible?:boolean,
15
- player_brackets:PlayerBracketProps[],
16
- bracket_competitions:BracketCompetitionProps[],
17
- competition_player_brackets:CompetitionPlayerBracketProps[],
18
- brackets:BracketProps[],
16
+ visible:boolean,
19
17
  onManageCompetition:(bracket_competition_id:string) => void,
20
- onMoreAdmin:(offset:number) => void,
21
- admin_offset:number,
22
- admin_competitions:BracketCompetitionProps[],
23
18
  onFocusPosition?:(pos:{ x:number, y:number, height:number, width:number }) => void,
24
19
  width:number,
25
- public_competitions:BracketCompetitionProps[],
26
- active_brackets:BracketProps[],
20
+ onRequestAuthenticate:() => void,
21
+ insets?: { top:number, bottom:number, right:number, left:number },
27
22
  view_mode:'mobile'|'desktop'
28
- competition_result_types:CompetitionResultTypeProps[],
29
23
  leagues:LeagueProps[],
30
24
  onCreateNewCompetition?:(bracket_id?:string) => void,
31
- athletes:AthleteProps[],
32
- onUpdatePlayerBracket:(player_bracket:PlayerBracketProps) => void,
33
- onEditPlayerBracket:(player_bracket:PlayerBracketProps) => void,
34
- onView: (bracket_id:string, player_bracket_id?:string, bracket_competition_id?:string) => void,
35
- teams:TeamProps[]
25
+ onView: (bracket_id:string, player_bracket_id?:string, bracket_competition?:BracketCompetitionProps) => void,
36
26
  }
37
27
 
38
28
  const MIN_CARD_WIDTH = 330
@@ -47,59 +37,237 @@ const calcCardWidth = (width:number, margin:number) => {
47
37
 
48
38
  const sections = [ 'toggle', 'active_brackets', 'past_brackets', 'tournaments', 'admin_competitions', 'competitions']
49
39
 
50
- const RoomHome = ({ visible, width, player, leagues, active_brackets, public_competitions, admin_competitions, onMoreAdmin, admin_offset, onManageCompetition, onCreateNewCompetition, onView, onUpdatePlayerBracket, onEditPlayerBracket, onFocusPosition, brackets, player_brackets, bracket_competitions, competition_player_brackets, athletes, teams }:RoomHomeProps) => {
40
+ const RoomHome = ({ view_mode, visible, width, onRequestAuthenticate, player, leagues, insets, onManageCompetition, onCreateNewCompetition, onView, onFocusPosition}:RoomHomeProps) => {
51
41
  const Colors = useColors();
42
+ const [ active_toggle, setActiveToggle ] = useState('my_brackets');
43
+ const [ show_comps, setShowComps ] = useState<{
44
+ player_bracket?:PlayerBracketProps,
45
+ champion_team?:TeamProps,
46
+ champion_athlete?:AthleteProps,
47
+ entered_competitions:BracketCompetitionProps[],
48
+ entered_brackets:CompetitionPlayerBracketProps[]
49
+ }>({
50
+ entered_brackets: [],
51
+ entered_competitions:[]
52
+ })
53
+ const [ editing_player_bracket, setEditingPlayerBracket ] = useState<PlayerBracketProps|undefined>(undefined);
54
+ const [ admin_data, setAdminData ] = useState<{
55
+ admin_loading:boolean,
56
+ admin_competitions:BracketCompetitionProps[],
57
+ admin_brackets:BracketProps[],
58
+ admin_offset:number
59
+ }>({
60
+ admin_loading: false,
61
+ admin_brackets: [],
62
+ admin_competitions:[],
63
+ admin_offset:0
64
+ });
65
+ const { admin_competitions, admin_offset } = admin_data;
66
+ const [ competitions_data, setCompetitionsData ] = useState<{
67
+ competitions_loaded:boolean,
68
+ competitions_loading: boolean,
69
+ public_competitions:BracketCompetitionProps[],
70
+ competition_brackets:BracketProps[]
71
+ }>({
72
+ competitions_loading: false,
73
+ competitions_loaded: false,
74
+ public_competitions:[],
75
+ competition_brackets:[]
76
+ });
77
+ const { public_competitions, competition_brackets } = competitions_data
78
+ const [ comp_search, setCompSearch ] = useState({
79
+ visible: false,
80
+ value: ''
81
+ });
82
+ let visisble_comps = [ ...public_competitions ]
83
+ if(comp_search.visible){
84
+ visisble_comps = visisble_comps.filter(c => `${c.competition_name} ${c.competition_description}`.toLowerCase().includes(comp_search.value.toLowerCase()))
85
+ }
86
+ const unique_competition_leagues = [ ...new Set(competition_brackets.filter(b => visisble_comps.map(c => c.bracket_id.toString()).includes(b.bracket_id.toString())).map(b => b.league_id)) ]
87
+
88
+ const [ tournaments_data, setTournamentsData ] = useState<{
89
+ tournaments_loading:boolean,
90
+ tournament_brackets:BracketProps[]
91
+ }>({
92
+ tournaments_loading: false,
93
+ tournament_brackets: []
94
+ });
95
+ const { tournament_brackets } = tournaments_data;
96
+ let visisble_tourney_brackets = [ ...tournament_brackets ]
97
+
98
+ const [ selected_league, setSelectedLeague ] = useState<string | undefined>(undefined);
99
+ if(selected_league){
100
+ visisble_tourney_brackets = visisble_tourney_brackets.filter(b => b.league_id == selected_league)
101
+ }
102
+ const [ tourney_search, setTourneySearch ] = useState({
103
+ visible:false, value:''
104
+ });
105
+ if(tourney_search.visible){
106
+ visisble_tourney_brackets = visisble_tourney_brackets.filter(b => `${b.bracket_name}`.toLowerCase().includes(tourney_search.value.toLowerCase()));
107
+ }
108
+ const unique_tournament_leagues = [ ...new Set(visisble_tourney_brackets.map(b => b.league_id)) ];
109
+
110
+ const [ my_brackets_data, setMyBrackets ] = useState<{
111
+ my_brackets_loading: boolean,
112
+ my_brackets_loaded:boolean,
113
+ competition_player_brackets:CompetitionPlayerBracketProps[],
114
+ my_competitions:BracketCompetitionProps[],
115
+ my_brackets:BracketProps[],
116
+ player_brackets:PlayerBracketProps[],
117
+ champion_teams:TeamProps[],
118
+ champion_athletes:AthleteProps[],
119
+ }>({
120
+ my_brackets_loading: false,
121
+ my_brackets_loaded: false,
122
+ competition_player_brackets: [],
123
+ my_brackets:[],
124
+ champion_athletes:[],
125
+ champion_teams: [],
126
+ my_competitions:[],
127
+ player_brackets:[]
128
+ });
129
+ const { my_brackets_loaded, my_brackets_loading, my_brackets, my_competitions, competition_player_brackets, player_brackets, champion_athletes, champion_teams } = my_brackets_data;
130
+ const active_brackets = player_brackets.filter(pb => pb.status == 'active');
131
+ const closed_brackets = player_brackets.filter(pb => pb.status == 'closed');
132
+
133
+ const [ past_search, setPastSearch ] = useState({
134
+ visible: false,
135
+ value:''
136
+ });
137
+ let closed_bracket_ids = [ ...new Set(closed_brackets.map(b => b.bracket_id)) ].slice(0,10)
138
+ if(past_search.visible){
139
+ let filtered_brackets = [ ...closed_brackets].filter(b => `${b.bracket_name}`.toLowerCase().includes(past_search.value.toLowerCase()))
140
+ closed_bracket_ids = [ ...new Set(filtered_brackets.map(b => b.bracket_id)) ].slice(0,10)
141
+ }
142
+
143
+ const [ active_search, setActiveSearch ] = useState({
144
+ visible:false,
145
+ value:''
146
+ });
147
+ let active_bracket_ids = [ ...new Set(active_brackets.map(b => b.bracket_id)) ]
148
+ if(active_search.visible){
149
+ let filtered_a_brackets = [ ...active_brackets].filter(b => `${b.bracket_name}`.toLowerCase().includes(active_search.value.toLowerCase()))
150
+ active_bracket_ids = [ ...new Set(filtered_a_brackets.map(b => b.bracket_id)) ].slice(0,10)
151
+ }
152
+
52
153
  const [ action_loading, setActionLoading ] = useState<string|undefined>(undefined)//This will be a bracket id
53
- const [ active_toggle, setActiveToggle ] = useState('competitions');
54
- const [ past_search, setPastSearch ] = useState('');
55
- const [ show_active_search, setShowActiveSearch ] = useState(false);
56
154
  const [ expanded_brackets, setExpandedBrackets ] = useState<string[]>([]);
57
155
  const [ expanded_leagues, setExpandedLeagues ] = useState<string[]>([]);
58
156
  const [ expanded_c_leagues, setExpandedCLeagues ] = useState<string[]>([])
59
- const [ active_search, setActiveSearch ] = useState('');
60
- const [ show_past_search, setShowPastSearch ] = useState(false);
61
- const [ show_brackets_search, setShowBracketsSearch ] = useState(false);
62
- const [ selected_league, setSelectedLeague ] = useState<string | undefined>(undefined);
63
- const [ brackets_search, setBracketsSearch ] = useState('');
64
- console.log(brackets_search)
65
- const [ competition_search, setCompetitionSearch ] = useState('');
66
- console.log(competition_search)
67
- const [ show_competition_search, setShowCompetitionSearch ] = useState(false);
68
- let visible_active_brackets = [ ...active_brackets ]
69
- const unique_leages = [ ...new Set(visible_active_brackets.map(b => b.league_id)) ];
70
- if(selected_league){ visible_active_brackets = visible_active_brackets.filter(b => b.league_id == selected_league) }
71
- //const inprogress_bracket_ids = [ ...new Set(visible_active_brackets.map(b => b.bracket_id)) ];
72
-
73
- const filterPlayerBrackets = (bs:BracketProps[], pbs:PlayerBracketProps[], status:'active'|'closed', search:string) => {
74
- let init_pbs = pbs.filter(pb => pb.status == status);
75
- if(!search || search == ''){ return init_pbs }
76
- let brackets = bs.filter(b => `${b.bracket_name.toLowerCase()}`.includes(search.toLowerCase()));
77
- return init_pbs.filter(pb => brackets.map(b => b.bracket_id.toString()).includes(pb.bracket_id.toString()));
157
+
158
+
159
+ useEffect(() => {
160
+ if(!visible){ return }
161
+ getData(active_toggle)
162
+ },[visible, active_toggle]);
163
+
164
+
165
+ const getData = async(toggle:string) => {
166
+ switch(toggle){
167
+ case 'my_brackets': getMyBrackets(); return
168
+ case 'tournaments': getTournaments(); return
169
+ case 'competitions': getCompetitions(); return
170
+ default: return
171
+ }
78
172
  }
79
173
 
80
- let visible_player_brackets = useMemo(() => {
81
- return filterPlayerBrackets(brackets, player_brackets, 'active', active_search);
82
- },[brackets.length, player_brackets.length, active_search]);
174
+ const getCompetitions = async() => {
175
+ setCompetitionsData({ ...competitions_data, competitions_loading: true });
176
+ const pub_comps = await BracketComeptitionApi.getActivePublicBrackets();
177
+ const unique_brackets = [ ...new Set(pub_comps.map(c => c.bracket_id)) ]
178
+ const comp_brackets = await BracketApi.getBracketsByIds(unique_brackets);
179
+ setCompetitionsData({
180
+ ...competitions_data,
181
+ public_competitions: pub_comps,
182
+ competitions_loaded: true,
183
+ competition_brackets: comp_brackets,
184
+ competitions_loading: false
185
+ })
186
+ getAdminComps(0);
187
+ }
83
188
 
84
- const active_bracket_ids = [ ...new Set(visible_player_brackets.map(pb => pb.bracket_id)) ]
189
+ const getAdminComps = async(offset:number) => {
190
+ if(!player){ return }
191
+ const admin_comps = await BracketComeptitionApi.getMyAdminCompetitions(offset);
192
+ setAdminData({
193
+ admin_loading: false,
194
+ admin_brackets:[],
195
+ admin_competitions:admin_comps,
196
+ admin_offset:offset
197
+ })
198
+ }
85
199
 
86
- let past_player_brackets = useMemo(() => {
87
- return filterPlayerBrackets(brackets, player_brackets, 'closed', past_search);
88
- },[brackets.length, player_brackets.length, past_search])
89
-
90
- const past_bracket_ids = [ ...new Set(past_player_brackets.map(pb => pb.bracket_id)) ]
200
+ const getTournaments = async() => {
201
+ setTournamentsData({ ...tournaments_data, tournaments_loading: true });
202
+ const tourney_brackets = await BracketApi.getActiveBrackets();
203
+ setTournamentsData({
204
+ ...tournaments_data,
205
+ tournaments_loading: false,
206
+ tournament_brackets: tourney_brackets
207
+ });
208
+ }
209
+
210
+ const getMyBrackets = async() => {
211
+ if(!player){ return }
212
+ setMyBrackets({ ...my_brackets_data, my_brackets_loading: true });
213
+ const my_response = await BracketComeptitionApi.getMyPlayerBrackets();
214
+ const bracket_ids = [ ...new Set(my_response.player_brackets.map(pb => pb.bracket_id))]
215
+ let brackets = await BracketApi.getBracketsByIds(bracket_ids);
216
+ let champ_team_ids = my_response.player_brackets.filter(pb => pb.champion_id_type == 'team').map(b => b.champion_id ?? '')
217
+ const champ_teams = await BracketApi.getTeamsByIds(champ_team_ids);
218
+ let champ_athlete_ids = my_response.player_brackets.filter(pb => pb.champion_id_type == 'athlete').map(b => b.champion_id ?? '')
219
+ const champ_athletes = await BracketApi.getAthletesByIds(champ_athlete_ids);
220
+ //Filter to active and closed
221
+ setMyBrackets({
222
+ ...my_brackets_data,
223
+ my_brackets_loading:false,
224
+ my_brackets_loaded: true,
225
+ champion_athletes: champ_athletes,
226
+ champion_teams: champ_teams,
227
+ my_brackets: brackets,
228
+ player_brackets: my_response.player_brackets,
229
+ competition_player_brackets: my_response.competition_player_brackets,
230
+ my_competitions: my_response.bracket_competitions
231
+ })
232
+ }
233
+
234
+ const handleView = async(bracket_id:string, player_bracket_id?:string, bracket_competition?:BracketCompetitionProps) => {
235
+ if(bracket_id && player_bracket_id && bracket_competition){ return onView(bracket_id, player_bracket_id, bracket_competition) }
236
+ //Ok! Now - what if we do not have a player_bracket
237
+ let init_pb_id = player_bracket_id
238
+ if(!init_pb_id){
239
+ //Lets try and find one!
240
+ init_pb_id = player_brackets.find(pb => pb.bracket_id == bracket_id && pb.status != 'deleted')?.player_bracket_id
241
+ if(!init_pb_id && !my_brackets_loaded){
242
+ //Lets try and get the plyaers brackets and see!
243
+ const my_pbs = await BracketComeptitionApi.getMyPlayerBrackets();
244
+ init_pb_id = my_pbs.player_brackets.find(pb => pb.bracket_id == bracket_id && pb.status != 'deleted')?.player_bracket_id
245
+ }
246
+ }
247
+
248
+ //Ok! Now - what if we do not have a bracket competition!
249
+ let init_bc = bracket_competition
250
+ if(!init_bc){
251
+ //First check if my competitions has any!
252
+ init_bc = my_competitions.find(c => c.bracket_id == bracket_id)
253
+ if(!init_bc){ init_bc = public_competitions.find(pc => pc.bracket_id == bracket_id) }
254
+ if(!init_bc){
255
+ //Lets try and get one from the server
256
+ const comps_bc = await BracketComeptitionApi.getBracketCompetitionsByBracketId(bracket_id);
257
+ init_bc = comps_bc.find(bc => bc.bracket_id == bracket_id && !bc.invite_only)
258
+ }
259
+ }
260
+ return onView(bracket_id, init_pb_id, init_bc)
261
+ }
91
262
 
92
- const competition_bracket_ids = [ ...new Set(public_competitions.map(bc => bc.bracket_id)) ]
93
- const competition_brackets = brackets.filter(b => competition_bracket_ids.includes(b.bracket_id));
94
- const competition_league_ids = [ ...new Set(competition_brackets.map(cb => cb.league_id)) ];
95
263
 
96
264
  const pb_width = calcCardWidth(width, 6);
97
265
 
98
266
  const renderBrackets = (data:{ item:string, index:number }) => {
99
- const bracket = brackets.find(b => b.bracket_id == data.item);
267
+ const bracket = my_brackets.find(b => b.bracket_id == data.item);
100
268
  if(!bracket){ return <></> }
101
269
  const expanded = expanded_brackets.includes(data.item) ? true : false
102
- let my_player_brackets = player_brackets.filter(pb => pb.bracket_id == data.item);
270
+ let my_player_brackets = player_brackets.filter(pb => pb.bracket_id == data.item && pb.status != 'deleted');
103
271
  let additional = my_player_brackets.length - 1
104
272
  if(!expanded){
105
273
  my_player_brackets = my_player_brackets.slice(0,1);
@@ -107,8 +275,8 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
107
275
  const league = leagues.find(l => l.league_id == bracket.league_id);
108
276
  const act_loading = action_loading == data.item ? true : false
109
277
  return (
110
- <View float style={{ margin:5, width: pb_width }}>
111
- <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
278
+ <View key={`${data.item}_${data.index}_bracket`} float style={{ margin:5, width: pb_width }}>
279
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
112
280
  {league ?
113
281
  <Image
114
282
  style={{ height:40, width:40, marginRight:5 }}
@@ -144,9 +312,12 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
144
312
  completion_status: 'inprogress',
145
313
  status: 'active'
146
314
  })
147
- onUpdatePlayerBracket(new_pb);
148
315
  setActionLoading(undefined);
149
316
  if(!expanded){ setExpandedBrackets(expanded_brackets.concat(data.item)) }
317
+ setMyBrackets({
318
+ ...my_brackets_data,
319
+ player_brackets: player_brackets.filter(pb => pb.player_bracket_id != new_pb.player_bracket_id).concat(new_pb)
320
+ })
150
321
  }}
151
322
  />
152
323
  :<></>}
@@ -173,7 +344,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
173
344
  const renderCompetitions = (data:{ item:BracketCompetitionProps, index:number }) => {
174
345
  return (
175
346
  <Button style={{ padding:10, flexDirection:'row', alignItems:'center', borderRadius:0, borderBottomWidth:1, borderColor:Colors.borders.light }}
176
- onPress={() => onView(data.item.bracket_id, player_brackets.find(pb => pb.bracket_id == data.item.bracket_id)?.player_bracket_id, data.item.bracket_competition_id)}>
347
+ onPress={() => handleView(data.item.bracket_id, undefined, data.item)}>
177
348
  <View transparent>
178
349
  <Image
179
350
  source={{ uri: data.item.image?.url }}
@@ -207,7 +378,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
207
378
  <Icons.BracketIcon size={50} color={Colors.text.h1} />
208
379
  }
209
380
  </View>
210
- <View type='footer' style={{ padding:8 }}>
381
+ <View type='footer' style={{ padding:8, borderBottomLeftRadius:8, borderBottomRightRadius:8 }}>
211
382
  <Button
212
383
  type='action'
213
384
  style={{ padding:5 }}
@@ -219,14 +390,21 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
219
390
  )
220
391
  }
221
392
 
222
- const renderPlayerBrackets = useCallback((data:{ item:PlayerBracketProps, index:number }) => {
393
+ const handleSearchPrivate = async(code:string) => {
394
+ const bc = await BracketComeptitionApi.getBracketcompetitionByCode(code);
395
+ if(!bc){ return alert('Unable to find private competition by that code')}
396
+ let pb_response = await BracketComeptitionApi.getMyPlayerBrackets(bc.bracket_id);
397
+ return handleView(bc.bracket_id, pb_response.player_brackets[0]?.player_bracket_id, bc)
398
+ }
399
+
400
+ const renderPlayerBrackets = (data:{ item:PlayerBracketProps, index:number}) => {
223
401
  const cpbs = competition_player_brackets.filter(cpb => cpb.status != 'deleted' && cpb.player_bracket_id == data.item.player_bracket_id);
224
- const comps = bracket_competitions.filter(bc => cpbs.map(cpb => cpb.bracket_competition_id.toString()).includes(bc.bracket_competition_id.toString()));
225
- const bracket = brackets.find(b => b.bracket_id == data.item.bracket_id);
402
+ const comps = my_competitions.filter(bc => cpbs.map(cpb => cpb.bracket_competition_id.toString()).includes(bc.bracket_competition_id.toString()));
403
+ const bracket = my_brackets.find(b => b.bracket_id == data.item.bracket_id);
226
404
  if(!bracket){ return <></> }
227
405
  const league = leagues.find(l => l.league_id == bracket.league_id);
228
- const champion_team = teams.find(t => data.item.champion_id_type == 'team' && t.team_id == data.item.champion_id)
229
- const champion_athlete = athletes.find(t => data.item.champion_id_type == 'athlete' && t.athlete_id == data.item.champion_id)
406
+ const champion_team = champion_teams.find(t => data.item.champion_id_type == 'team' && t.team_id == data.item.champion_id)
407
+ const champion_athlete = champion_athletes.find(t => data.item.champion_id_type == 'athlete' && t.athlete_id == data.item.champion_id)
230
408
  return (
231
409
  <View style={{ borderBottomWidth:1, borderColor:Colors.borders.light, padding:5 }}>
232
410
  <PlayerBracketCard
@@ -237,12 +415,13 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
237
415
  competition_player_brackets={cpbs}
238
416
  bracket={bracket}
239
417
  bracket_competitions={comps}
240
- onView={onView}
241
- onEdit={onEditPlayerBracket}
418
+ onView={(bracket_id, player_bracket_id) => handleView(bracket_id, player_bracket_id)}
419
+ onEdit={() => setEditingPlayerBracket(data.item)}
420
+ onShowCompetitions={() => setShowComps({ player_bracket: data.item, entered_competitions:comps, entered_brackets: cpbs, champion_team, champion_athlete })}
242
421
  />
243
422
  </View>
244
423
  )
245
- }, [JSON.stringify(player_brackets)]);
424
+ };
246
425
 
247
426
  const renderLeagueFilters = (data:{ item:string, index:number }) => {
248
427
  const league = leagues.find(l => l.league_id == data.item);
@@ -251,7 +430,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
251
430
  return (
252
431
  <Button
253
432
  float
254
- style={{ flexDirection:'row', alignItems:'center', padding:5, paddingRight:10, paddingLeft:10, borderRadius:100, margin:5 }}
433
+ style={{ flexDirection:'row', alignItems:'center', padding:5, paddingRight:10, paddingLeft:10, borderRadius:100, margin:5, backgroundColor:selected?Colors.text.highlight:undefined }}
255
434
  onPress={() => selected ? setSelectedLeague(undefined): setSelectedLeague(data.item)}
256
435
  >
257
436
  <Image
@@ -267,7 +446,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
267
446
  const renderLeagueBrackets = (data:{ item:BracketProps, index:number }) => {
268
447
  return (
269
448
  <Button style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}
270
- onPress={() => onView(data.item.bracket_id, player_brackets.find(pb => pb.bracket_id == data.item.bracket_id)?.player_bracket_id, undefined)}>
449
+ onPress={() => handleView(data.item.bracket_id)}>
271
450
  <Icons.BracketIcon size={18} color={Colors.text.h1} />
272
451
  <View transparent style={{ flex:1, marginLeft:10, paddingLeft:5, borderLeftWidth:1, borderColor:Colors.borders.light }}>
273
452
  <Text theme='h2'>{data.item.bracket_name}</Text>
@@ -283,7 +462,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
283
462
  if(!league){ return <></> }
284
463
  const expanded = expanded_c_leagues.includes(data.item) ? true : false
285
464
  //Find all the brackets for this league
286
- let league_brackets = active_brackets.filter(b => b.league_id == data.item);
465
+ let league_brackets = competition_brackets.filter(b => b.league_id == data.item);
287
466
  let league_competitions = public_competitions.filter(bc => league_brackets.map(lb => lb.bracket_id.toString()).includes(bc.bracket_id.toString()));
288
467
  const num_comps = league_competitions.length
289
468
  let additional = league_competitions.length - 1
@@ -330,7 +509,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
330
509
  const league = leagues.find(l => l.league_id == data.item);
331
510
  if(!league){ return <></> }
332
511
  const expanded = expanded_leagues.includes(data.item) ? true : false
333
- let league_brackets = active_brackets.filter(b => b.league_id == data.item);
512
+ let league_brackets = tournament_brackets.filter(b => b.league_id == data.item);
334
513
  let additional = league_brackets.length - 1
335
514
  if(!expanded){
336
515
  league_brackets = league_brackets.slice(0,1);
@@ -371,17 +550,15 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
371
550
  )
372
551
  }
373
552
 
553
+
554
+
374
555
  const renderSections = (data:{ item:string, index:number }) => {
375
556
  switch(data.item){
376
557
  case 'toggle':
377
558
  return (
378
- <View style={{ margin:5 }}>
559
+ <View style={{ margin:10, marginTop:18 }}>
379
560
  <Toggle
380
- options={[
381
- { key: 'my_brackets', label:'My Brackets' },
382
- { key: 'tournaments', label:'Tournaments' },
383
- { key: 'competitions', label:'Competitions' }
384
- ]}
561
+ options={BracketCompetitionHelpers.getToggleOptions()}
385
562
  selected_option={active_toggle}
386
563
  onSelectOption={(key) => setActiveToggle(key)}
387
564
 
@@ -390,9 +567,21 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
390
567
  )
391
568
  case 'active_brackets':
392
569
  if(active_toggle != 'my_brackets'){ return <></> }
570
+ if(!player){
571
+ return (
572
+ <View style={{ padding:40, justifyContent:'center', alignItems:'center' }}>
573
+ <Button
574
+ float
575
+ type='success'
576
+ title='GET STARTED'
577
+ onPress={()=> onRequestAuthenticate()}
578
+ />
579
+ </View>
580
+ )
581
+ }
393
582
  return (
394
- <View nativeID='my_competitions'>
395
- <View type='header' style={{ padding:10, flexDirection:'row', alignItems:'center' }}>
583
+ <View nativeID='my_competitions' style={{ marginTop:18 }}>
584
+ <View style={{ padding:18, flexDirection:'row', alignItems:'center', borderBottomWidth:1, borderColor:Colors.borders.light }}>
396
585
  <View transparent style={{ flex:1, marginRight:10 }}>
397
586
  <Text theme='h1'>My Active Brackets</Text>
398
587
  <Text style={{ marginTop:4 }}>View / Edit your active brackets</Text>
@@ -400,24 +589,24 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
400
589
  <Button
401
590
  float
402
591
  style={{ padding:0, height:35, width:35, justifyContent:'center', alignItems:'center' }}
403
- onPress={() => setShowActiveSearch(!show_active_search)}
592
+ onPress={() => setActiveSearch({ visible: !active_search.visible, value:'' })}
404
593
  >
405
- {show_active_search ?
594
+ {active_search.visible ?
406
595
  <Icons.CloseIcon size={14} color={Colors.text.error} />
407
596
  :
408
597
  <Icons.SearchIcon size={14} color={Colors.text.action} />
409
598
  }
410
599
  </Button>
411
600
  </View>
412
- {show_active_search ?
601
+ {active_search.visible ?
413
602
  <SearchBox
414
- onChange={(text) => setActiveSearch(text)}
603
+ onChange={(text) => setActiveSearch({ ...active_search, value: text })}
415
604
  hide_search_button
416
605
  placeholder='Search Active Brackets'
417
606
  onFocusPosition={onFocusPosition}
418
607
  />
419
608
  :<></>}
420
- <View type='body' style={{ marginBottom:10, flexDirection:'row', flexWrap:'wrap', justifyContent:'center'}}>
609
+ <View type='header' style={{ padding:10, flexDirection:'row', flexWrap:'wrap', justifyContent:'center'}}>
421
610
  {active_bracket_ids.map((id, index) => {
422
611
  return renderBrackets({ item:id, index })
423
612
  })}
@@ -436,38 +625,38 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
436
625
  <Button
437
626
  float
438
627
  style={{ padding:0, height:35, width:35, justifyContent:'center', alignItems:'center' }}
439
- onPress={() => setShowBracketsSearch(!show_brackets_search)}
628
+ onPress={() => setTourneySearch({ visible: !tourney_search.visible, value: '' })}
440
629
  >
441
- {show_brackets_search ?
630
+ {tourney_search.visible ?
442
631
  <Icons.CloseIcon size={14} color={Colors.text.error} />
443
632
  :
444
633
  <Icons.SearchIcon size={14} color={Colors.text.action} />
445
634
  }
446
635
  </Button>
447
636
  </View>
448
- {show_brackets_search ?
637
+ {tourney_search.visible ?
449
638
 
450
639
  <View style={{ padding:5 }}>
451
640
  <FlatList
452
641
  key='unique_leagues'
453
642
  keyExtractor={(item) => item}
454
- data={unique_leages}
643
+ data={unique_tournament_leagues}
455
644
  renderItem={renderLeagueFilters}
456
645
  horizontal
457
646
  />
458
647
  </View>
459
648
  :<></>}
460
649
 
461
- {show_brackets_search ?
650
+ {tourney_search.visible ?
462
651
  <SearchBox
463
- onChange={(text) => setBracketsSearch(text)}
652
+ onChange={(text) => setTourneySearch({ ...tourney_search, value: text })}
464
653
  hide_search_button
465
654
  placeholder='Search Active Tournaments'
466
655
  onFocusPosition={onFocusPosition}
467
656
  />
468
657
  :<></>}
469
658
  <View type='body' style={{ marginTop:10, marginBottom:10, flexDirection:'row', flexWrap:'wrap', justifyContent:'center'}}>
470
- {unique_leages.map((id, index) => {
659
+ {unique_tournament_leagues.map((id, index) => {
471
660
  return renderLeagues({ item:id, index })
472
661
  })}
473
662
  </View>
@@ -476,35 +665,36 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
476
665
  )
477
666
  case 'past_brackets':
478
667
  if(active_toggle != 'my_brackets'){ return <></> }
668
+ if(!player){ return <></> }
479
669
  return (
480
- <View nativeID='past_brackets'>
481
- <View type='header' style={{ padding:10, flexDirection:'row', alignItems:'center' }}>
670
+ <View nativeID='past_brackets' style={{ marginTop:18 }}>
671
+ <View style={{ padding:18, flexDirection:'row', alignItems:'center', borderBottomWidth:1, borderColor:Colors.borders.light }}>
482
672
  <View transparent style={{ flex:1, marginRight:10 }}>
483
- <Text theme='h1'>MY PAST BRACKETS</Text>
673
+ <Text theme='h1'>My Past Brackets</Text>
484
674
  <Text style={{ marginTop:4 }}>View your past brackets</Text>
485
675
  </View>
486
676
  <Button
487
677
  float
488
678
  style={{ padding:0, height:35, width:35, justifyContent:'center', alignItems:'center' }}
489
- onPress={() => setShowPastSearch(!show_past_search)}
679
+ onPress={() => setPastSearch({ visible: !past_search.visible, value: '' })}
490
680
  >
491
- {show_past_search ?
681
+ {past_search.visible ?
492
682
  <Icons.CloseIcon size={14} color={Colors.text.error} />
493
683
  :
494
684
  <Icons.SearchIcon size={14} color={Colors.text.action} />
495
685
  }
496
686
  </Button>
497
687
  </View>
498
- {show_past_search ?
688
+ {past_search.visible ?
499
689
  <SearchBox
500
- onChange={(text) => setPastSearch(text)}
690
+ onChange={(text) => setPastSearch({ ...past_search, value:text })}
501
691
  hide_search_button
502
692
  placeholder='Search Past Brackets'
503
693
  onFocusPosition={onFocusPosition}
504
694
  />
505
695
  :<></>}
506
- <View type='body' style={{ marginBottom:10, flexDirection:'row', flexWrap:'wrap', justifyContent:'center'}}>
507
- {past_bracket_ids.map((id, index) => {
696
+ <View type='header' style={{ padding:10, flexDirection:'row', flexWrap:'wrap', justifyContent:'center'}}>
697
+ {closed_bracket_ids.map((id, index) => {
508
698
  return renderBrackets({ item:id, index })
509
699
  })}
510
700
  </View>
@@ -512,6 +702,7 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
512
702
  )
513
703
  case 'admin_competitions':
514
704
  if(active_toggle != 'competitions'){ return <></> }
705
+ if(!player){ return <></> }
515
706
  return (
516
707
  <View>
517
708
  <View type='header' style={{ padding:10, flexDirection:'row', alignItems:'center' }}>
@@ -524,23 +715,43 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
524
715
  title='PREV'
525
716
  type='text'
526
717
  style={{ padding:0, marginRight:10 }}
527
- onPress={() => onMoreAdmin(admin_offset - 1)}
718
+ onPress={() => getAdminComps(admin_offset - 1)}
528
719
  />
529
720
  :<></>}
530
721
  <Button
531
722
  title='MORE'
532
723
  type='text'
533
724
  style={{ padding:0 }}
534
- onPress={() => onMoreAdmin(admin_offset + 1)}
725
+ onPress={() => getAdminComps(admin_offset + 1)}
535
726
  />
536
727
  </View>
537
728
  <View style={{ padding:10 }}>
538
- <FlatList
539
- data={admin_competitions}
540
- renderItem={renderAdminCompetitions}
541
- keyExtractor={(item) => `admin_${item.bracket_competition_id.toString()}`}
542
- horizontal
543
- />
729
+ <View style={{ flexDirection:'row' }}>
730
+ {onCreateNewCompetition ?
731
+ <View float style={{ width:100, margin:5, borderWidth:1, borderColor:Colors.text.success }}>
732
+ <View type='header' style={{ borderTopRightRadius:8, borderTopLeftRadius:8, padding:5 }}>
733
+ <Text style={{ padding:5 }} theme='description' textAlign='center'>NEW</Text>
734
+ </View>
735
+ <View style={{ flex:1, justifyContent:'center', alignItems:'center' }}>
736
+ <Icons.BracketIcon size={40} color={Colors.text.h1} />
737
+ </View>
738
+ <View type='footer' style={{ padding:8, borderBottomLeftRadius:8, borderBottomRightRadius:8 }}>
739
+ <Button
740
+ title='CREATE'
741
+ type='success'
742
+ style={{padding:5}}
743
+ onPress={() => onCreateNewCompetition()}
744
+ />
745
+ </View>
746
+ </View>
747
+ :<></>}
748
+ <FlatList
749
+ data={admin_competitions}
750
+ renderItem={renderAdminCompetitions}
751
+ keyExtractor={(item) => `admin_${item.bracket_competition_id.toString()}`}
752
+ horizontal
753
+ />
754
+ </View>
544
755
  </View>
545
756
  </View>
546
757
  )
@@ -556,9 +767,9 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
556
767
  <Button
557
768
  float
558
769
  style={{ padding:0, height:35, width:35, justifyContent:'center', alignItems:'center' }}
559
- onPress={() => setShowCompetitionSearch(!show_competition_search)}
770
+ onPress={() => setCompSearch({ visible: !comp_search.visible, value: '' })}
560
771
  >
561
- {show_competition_search ?
772
+ {comp_search.visible ?
562
773
  <Icons.CloseIcon size={12} color={Colors.text.error} />
563
774
  :
564
775
  <Icons.SearchIcon size={12} color={Colors.text.action} />
@@ -575,16 +786,16 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
575
786
  </Button>
576
787
  :<></>}
577
788
  </View>
578
- {show_competition_search ?
789
+ {comp_search.visible ?
579
790
  <SearchBox
580
- onChange={(text) => setCompetitionSearch(text)}
581
- onSearch={(text) => console.log(text)}
791
+ onChange={(text) => setCompSearch({ ...comp_search, value:text })}
792
+ onSearch={(text) => handleSearchPrivate(text)}
582
793
  placeholder='Search or Enter Private Code'
583
794
  onFocusPosition={onFocusPosition}
584
795
  />
585
796
  :<></>}
586
797
  <View type='body' style={{ marginTop:10, marginBottom:10, flexDirection:'row', flexWrap:'wrap', justifyContent:'center'}}>
587
- {competition_league_ids.map((id, index) => {
798
+ {unique_competition_leagues.map((id, index) => {
588
799
  return renderLeaguesForCompetitions({ item:id, index })
589
800
  })}
590
801
  </View>
@@ -595,15 +806,43 @@ const RoomHome = ({ visible, width, player, leagues, active_brackets, public_com
595
806
  }
596
807
 
597
808
  if(!visible){ return <></> }
598
-
599
809
  return (
600
810
  <View style={{ flex:1 }}>
601
811
  <FlatList
602
812
  data={sections}
603
813
  key='room_sections'
814
+ refreshing={my_brackets_loading}
604
815
  keyExtractor={(item) => item}
605
816
  renderItem={renderSections}
606
817
  />
818
+ <EditPlayerBracket
819
+ player_bracket={editing_player_bracket}
820
+ view_mode={view_mode}
821
+ insets={insets}
822
+ onClose={() => setEditingPlayerBracket(undefined)}
823
+ onFocusPosition={onFocusPosition}
824
+ onUpdatePlayerBracket={(new_pb) => {
825
+ setEditingPlayerBracket(undefined);
826
+ setMyBrackets({
827
+ ...my_brackets_data,
828
+ player_brackets: player_brackets.filter(pb => pb.player_bracket_id != new_pb.player_bracket_id).concat(new_pb)
829
+ })
830
+ }}
831
+ />
832
+ <EnteredCompetitionsModal
833
+ player_bracket={show_comps.player_bracket}
834
+ onSelectCompetition={(bc) => {
835
+ if(!show_comps.player_bracket){ return }
836
+ onView(show_comps.player_bracket.bracket_id, show_comps.player_bracket.player_bracket_id, bc)
837
+ }}
838
+ insets={insets}
839
+ champion_team={show_comps.champion_team}
840
+ champion_athlete={show_comps.champion_athlete}
841
+ onClose={() => setShowComps({ entered_brackets:[], entered_competitions:[] })}
842
+ entered_brackets={show_comps.entered_brackets}
843
+ entered_competitions={show_comps.entered_competitions}
844
+ view_mode={view_mode}
845
+ />
607
846
  </View>
608
847
  )
609
848
  }