be-components 4.5.5 → 4.5.6

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 (101) hide show
  1. package/lib/commonjs/Bracket/api/index.js +0 -2
  2. package/lib/commonjs/Bracket/api/index.js.map +1 -1
  3. package/lib/commonjs/Bracket/components/BracketCompetitionActions.js +8 -7
  4. package/lib/commonjs/Bracket/components/BracketCompetitionActions.js.map +1 -1
  5. package/lib/commonjs/Bracket/components/BracketPlay/BracketRound.js +2 -0
  6. package/lib/commonjs/Bracket/components/BracketPlay/BracketRound.js.map +1 -1
  7. package/lib/commonjs/Bracket/components/BracketPlay/index.js +0 -8
  8. package/lib/commonjs/Bracket/components/BracketPlay/index.js.map +1 -1
  9. package/lib/commonjs/Bracket/components/EditPlayerBracket.js +32 -3
  10. package/lib/commonjs/Bracket/components/EditPlayerBracket.js.map +1 -1
  11. package/lib/commonjs/Bracket/components/EnteredCompetitionsModal.js +197 -0
  12. package/lib/commonjs/Bracket/components/EnteredCompetitionsModal.js.map +1 -0
  13. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js +3 -3
  14. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  15. package/lib/commonjs/Bracket/components/PlayerBracketCard.js +21 -4
  16. package/lib/commonjs/Bracket/components/PlayerBracketCard.js.map +1 -1
  17. package/lib/commonjs/Bracket/components/PlayerBrackets.js +27 -4
  18. package/lib/commonjs/Bracket/components/PlayerBrackets.js.map +1 -1
  19. package/lib/commonjs/Bracket/components/RoomHome.js +408 -107
  20. package/lib/commonjs/Bracket/components/RoomHome.js.map +1 -1
  21. package/lib/commonjs/Bracket/index.js +246 -420
  22. package/lib/commonjs/Bracket/index.js.map +1 -1
  23. package/lib/module/Bracket/api/index.js +0 -2
  24. package/lib/module/Bracket/api/index.js.map +1 -1
  25. package/lib/module/Bracket/components/BracketCompetitionActions.js +8 -7
  26. package/lib/module/Bracket/components/BracketCompetitionActions.js.map +1 -1
  27. package/lib/module/Bracket/components/BracketPlay/BracketRound.js +2 -0
  28. package/lib/module/Bracket/components/BracketPlay/BracketRound.js.map +1 -1
  29. package/lib/module/Bracket/components/BracketPlay/index.js +0 -8
  30. package/lib/module/Bracket/components/BracketPlay/index.js.map +1 -1
  31. package/lib/module/Bracket/components/EditPlayerBracket.js +33 -4
  32. package/lib/module/Bracket/components/EditPlayerBracket.js.map +1 -1
  33. package/lib/module/Bracket/components/EnteredCompetitionsModal.js +190 -0
  34. package/lib/module/Bracket/components/EnteredCompetitionsModal.js.map +1 -0
  35. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js +3 -3
  36. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  37. package/lib/module/Bracket/components/PlayerBracketCard.js +21 -4
  38. package/lib/module/Bracket/components/PlayerBracketCard.js.map +1 -1
  39. package/lib/module/Bracket/components/PlayerBrackets.js +28 -5
  40. package/lib/module/Bracket/components/PlayerBrackets.js.map +1 -1
  41. package/lib/module/Bracket/components/RoomHome.js +410 -109
  42. package/lib/module/Bracket/components/RoomHome.js.map +1 -1
  43. package/lib/module/Bracket/index.js +247 -421
  44. package/lib/module/Bracket/index.js.map +1 -1
  45. package/lib/typescript/lib/commonjs/Bracket/api/index.d.ts.map +1 -1
  46. package/lib/typescript/lib/commonjs/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  47. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/BracketRound.d.ts.map +1 -1
  48. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts +1 -2
  49. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  50. package/lib/typescript/lib/commonjs/Bracket/components/EditPlayerBracket.d.ts +3 -1
  51. package/lib/typescript/lib/commonjs/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  52. package/lib/typescript/lib/commonjs/Bracket/components/EnteredCompetitionsModal.d.ts +14 -0
  53. package/lib/typescript/lib/commonjs/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  54. package/lib/typescript/lib/commonjs/Bracket/components/PlayerBrackets.d.ts +4 -1
  55. package/lib/typescript/lib/commonjs/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  56. package/lib/typescript/lib/commonjs/Bracket/components/RoomHome.d.ts +3 -14
  57. package/lib/typescript/lib/commonjs/Bracket/components/RoomHome.d.ts.map +1 -1
  58. package/lib/typescript/lib/commonjs/Bracket/index.d.ts.map +1 -1
  59. package/lib/typescript/lib/module/Bracket/api/index.d.ts.map +1 -1
  60. package/lib/typescript/lib/module/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  61. package/lib/typescript/lib/module/Bracket/components/BracketPlay/BracketRound.d.ts.map +1 -1
  62. package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts +1 -2
  63. package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  64. package/lib/typescript/lib/module/Bracket/components/EditPlayerBracket.d.ts +5 -2
  65. package/lib/typescript/lib/module/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  66. package/lib/typescript/lib/module/Bracket/components/EnteredCompetitionsModal.d.ts +15 -0
  67. package/lib/typescript/lib/module/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  68. package/lib/typescript/lib/module/Bracket/components/PlayerBracketCard.d.ts +3 -1
  69. package/lib/typescript/lib/module/Bracket/components/PlayerBracketCard.d.ts.map +1 -1
  70. package/lib/typescript/lib/module/Bracket/components/PlayerBrackets.d.ts +6 -2
  71. package/lib/typescript/lib/module/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  72. package/lib/typescript/lib/module/Bracket/components/RoomHome.d.ts +3 -14
  73. package/lib/typescript/lib/module/Bracket/components/RoomHome.d.ts.map +1 -1
  74. package/lib/typescript/lib/module/Bracket/index.d.ts.map +1 -1
  75. package/lib/typescript/src/Bracket/api/index.d.ts.map +1 -1
  76. package/lib/typescript/src/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  77. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts +1 -2
  78. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  79. package/lib/typescript/src/Bracket/components/EditPlayerBracket.d.ts +8 -1
  80. package/lib/typescript/src/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  81. package/lib/typescript/src/Bracket/components/EnteredCompetitionsModal.d.ts +21 -0
  82. package/lib/typescript/src/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  83. package/lib/typescript/src/Bracket/components/PlayerBracketCard.d.ts +3 -2
  84. package/lib/typescript/src/Bracket/components/PlayerBracketCard.d.ts.map +1 -1
  85. package/lib/typescript/src/Bracket/components/PlayerBrackets.d.ts +9 -1
  86. package/lib/typescript/src/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  87. package/lib/typescript/src/Bracket/components/RoomHome.d.ts +10 -18
  88. package/lib/typescript/src/Bracket/components/RoomHome.d.ts.map +1 -1
  89. package/lib/typescript/src/Bracket/index.d.ts.map +1 -1
  90. package/package.json +1 -1
  91. package/src/Bracket/api/index.ts +0 -2
  92. package/src/Bracket/components/BracketCompetitionActions.tsx +7 -6
  93. package/src/Bracket/components/BracketPlay/BracketRound.tsx +2 -2
  94. package/src/Bracket/components/BracketPlay/index.tsx +13 -18
  95. package/src/Bracket/components/EditPlayerBracket.tsx +58 -42
  96. package/src/Bracket/components/EnteredCompetitionsModal.tsx +113 -0
  97. package/src/Bracket/components/ManageBracketCompetitionForm.tsx +3 -3
  98. package/src/Bracket/components/PlayerBracketCard.tsx +9 -4
  99. package/src/Bracket/components/PlayerBrackets.tsx +45 -33
  100. package/src/Bracket/components/RoomHome.tsx +335 -112
  101. package/src/Bracket/index.tsx +280 -410
@@ -1,4 +1,4 @@
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
3
  import { FlatList, Image } from 'react-native';
4
4
  import PlayerBracketCard from './PlayerBracketCard';
@@ -6,7 +6,9 @@ import SearchBox from '../../Components/SearchBox';
6
6
  import { Icons, Toggle } from '../../Components';
7
7
  import { useColors } from '../../constants/useColors';
8
8
  import moment from 'moment-mini';
9
- import { BracketComeptitionApi } from '../api';
9
+ import { BracketApi, BracketComeptitionApi } from '../api';
10
+ import EditPlayerBracket from './EditPlayerBracket';
11
+ import EnteredCompetitionsModal from './EnteredCompetitionsModal';
10
12
  const MIN_CARD_WIDTH = 330;
11
13
  const calcCardWidth = (width, margin) => {
12
14
  let num_cards_possible = Math.floor(width / MIN_CARD_WIDTH);
@@ -19,79 +21,241 @@ const calcCardWidth = (width, margin) => {
19
21
  };
20
22
  const sections = ['toggle', 'active_brackets', 'past_brackets', 'tournaments', 'admin_competitions', 'competitions'];
21
23
  const RoomHome = ({
24
+ view_mode,
22
25
  visible,
23
26
  width,
24
27
  player,
25
28
  leagues,
26
- active_brackets,
27
- public_competitions,
28
- admin_competitions,
29
- onMoreAdmin,
30
- admin_offset,
29
+ insets,
31
30
  onManageCompetition,
32
31
  onCreateNewCompetition,
33
32
  onView,
34
- onUpdatePlayerBracket,
35
- onEditPlayerBracket,
36
- onFocusPosition,
37
- brackets,
38
- player_brackets,
39
- bracket_competitions,
40
- competition_player_brackets,
41
- athletes,
42
- teams
33
+ onFocusPosition
43
34
  }) => {
44
35
  const Colors = useColors();
36
+ const [active_toggle, setActiveToggle] = useState('my_brackets');
37
+ const [show_comps, setShowComps] = useState({
38
+ entered_brackets: [],
39
+ entered_competitions: []
40
+ });
41
+ const [editing_player_bracket, setEditingPlayerBracket] = useState(undefined);
42
+ const [admin_data, setAdminData] = useState({
43
+ admin_loading: false,
44
+ admin_brackets: [],
45
+ admin_competitions: [],
46
+ admin_offset: 0
47
+ });
48
+ const {
49
+ admin_competitions,
50
+ admin_offset
51
+ } = admin_data;
52
+ const [competitions_data, setCompetitionsData] = useState({
53
+ competitions_loading: false,
54
+ competitions_loaded: false,
55
+ public_competitions: [],
56
+ competition_brackets: []
57
+ });
58
+ const {
59
+ public_competitions,
60
+ competition_brackets
61
+ } = competitions_data;
62
+ const [comp_search, setCompSearch] = useState({
63
+ visible: false,
64
+ value: ''
65
+ });
66
+ let visisble_comps = [...public_competitions];
67
+ if (comp_search.visible) {
68
+ visisble_comps = visisble_comps.filter(c => `${c.competition_name} ${c.competition_description}`.toLowerCase().includes(comp_search.value.toLowerCase()));
69
+ }
70
+ 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))];
71
+ const [tournaments_data, setTournamentsData] = useState({
72
+ tournaments_loading: false,
73
+ tournament_brackets: []
74
+ });
75
+ const {
76
+ tournament_brackets
77
+ } = tournaments_data;
78
+ let visisble_tourney_brackets = [...tournament_brackets];
79
+ const [selected_league, setSelectedLeague] = useState(undefined);
80
+ if (selected_league) {
81
+ visisble_tourney_brackets = visisble_tourney_brackets.filter(b => b.league_id == selected_league);
82
+ }
83
+ const [tourney_search, setTourneySearch] = useState({
84
+ visible: false,
85
+ value: ''
86
+ });
87
+ if (tourney_search.visible) {
88
+ visisble_tourney_brackets = visisble_tourney_brackets.filter(b => `${b.bracket_name}`.toLowerCase().includes(tourney_search.value.toLowerCase()));
89
+ }
90
+ const unique_tournament_leagues = [...new Set(visisble_tourney_brackets.map(b => b.league_id))];
91
+ const [my_brackets_data, setMyBrackets] = useState({
92
+ my_brackets_loading: false,
93
+ my_brackets_loaded: false,
94
+ competition_player_brackets: [],
95
+ my_brackets: [],
96
+ champion_athletes: [],
97
+ champion_teams: [],
98
+ my_competitions: [],
99
+ player_brackets: []
100
+ });
101
+ const {
102
+ my_brackets_loaded,
103
+ my_brackets_loading,
104
+ my_brackets,
105
+ my_competitions,
106
+ competition_player_brackets,
107
+ player_brackets,
108
+ champion_athletes,
109
+ champion_teams
110
+ } = my_brackets_data;
111
+ const active_brackets = player_brackets.filter(pb => pb.status == 'active');
112
+ const closed_brackets = player_brackets.filter(pb => pb.status == 'closed');
113
+ const [past_search, setPastSearch] = useState({
114
+ visible: false,
115
+ value: ''
116
+ });
117
+ let closed_bracket_ids = [...new Set(closed_brackets.map(b => b.bracket_id))].slice(0, 10);
118
+ if (past_search.visible) {
119
+ let filtered_brackets = [...closed_brackets].filter(b => `${b.bracket_name}`.toLowerCase().includes(past_search.value.toLowerCase()));
120
+ closed_bracket_ids = [...new Set(filtered_brackets.map(b => b.bracket_id))].slice(0, 10);
121
+ }
122
+ const [active_search, setActiveSearch] = useState({
123
+ visible: false,
124
+ value: ''
125
+ });
126
+ let active_bracket_ids = [...new Set(active_brackets.map(b => b.bracket_id))];
127
+ if (active_search.visible) {
128
+ let filtered_a_brackets = [...active_brackets].filter(b => `${b.bracket_name}`.toLowerCase().includes(active_search.value.toLowerCase()));
129
+ active_bracket_ids = [...new Set(filtered_a_brackets.map(b => b.bracket_id))].slice(0, 10);
130
+ }
45
131
  const [action_loading, setActionLoading] = useState(undefined); //This will be a bracket id
46
- const [active_toggle, setActiveToggle] = useState('competitions');
47
- const [past_search, setPastSearch] = useState('');
48
- const [show_active_search, setShowActiveSearch] = useState(false);
49
132
  const [expanded_brackets, setExpandedBrackets] = useState([]);
50
133
  const [expanded_leagues, setExpandedLeagues] = useState([]);
51
134
  const [expanded_c_leagues, setExpandedCLeagues] = useState([]);
52
- const [active_search, setActiveSearch] = useState('');
53
- const [show_past_search, setShowPastSearch] = useState(false);
54
- const [show_brackets_search, setShowBracketsSearch] = useState(false);
55
- const [selected_league, setSelectedLeague] = useState(undefined);
56
- const [brackets_search, setBracketsSearch] = useState('');
57
- console.log(brackets_search);
58
- const [competition_search, setCompetitionSearch] = useState('');
59
- console.log(competition_search);
60
- const [show_competition_search, setShowCompetitionSearch] = useState(false);
61
- let visible_active_brackets = [...active_brackets];
62
- const unique_leages = [...new Set(visible_active_brackets.map(b => b.league_id))];
63
- if (selected_league) {
64
- visible_active_brackets = visible_active_brackets.filter(b => b.league_id == selected_league);
65
- }
66
- //const inprogress_bracket_ids = [ ...new Set(visible_active_brackets.map(b => b.bracket_id)) ];
135
+ useEffect(() => {
136
+ if (!visible) {
137
+ return;
138
+ }
139
+ getData(active_toggle);
140
+ }, [visible, active_toggle]);
141
+ const getData = async toggle => {
142
+ switch (toggle) {
143
+ case 'my_brackets':
144
+ getMyBrackets();
145
+ return;
146
+ case 'tournaments':
147
+ getTournaments();
148
+ return;
149
+ case 'competitions':
150
+ getCompetitions();
151
+ return;
152
+ default:
153
+ return;
154
+ }
155
+ };
156
+ const getCompetitions = async () => {
157
+ setCompetitionsData({
158
+ ...competitions_data,
159
+ competitions_loading: true
160
+ });
161
+ const pub_comps = await BracketComeptitionApi.getActivePublicBrackets();
162
+ const unique_brackets = [...new Set(pub_comps.map(c => c.bracket_id))];
163
+ const comp_brackets = await BracketApi.getBracketsByIds(unique_brackets);
164
+ setCompetitionsData({
165
+ ...competitions_data,
166
+ public_competitions: pub_comps,
167
+ competitions_loaded: true,
168
+ competition_brackets: comp_brackets,
169
+ competitions_loading: false
170
+ });
171
+ getAdminComps(0);
172
+ };
173
+ const getAdminComps = async offset => {
174
+ const admin_comps = await BracketComeptitionApi.getMyAdminCompetitions(offset);
175
+ setAdminData({
176
+ admin_loading: false,
177
+ admin_brackets: [],
178
+ admin_competitions: admin_comps,
179
+ admin_offset: offset
180
+ });
181
+ };
182
+ const getTournaments = async () => {
183
+ setTournamentsData({
184
+ ...tournaments_data,
185
+ tournaments_loading: true
186
+ });
187
+ const tourney_brackets = await BracketApi.getActiveBrackets();
188
+ setTournamentsData({
189
+ ...tournaments_data,
190
+ tournaments_loading: false,
191
+ tournament_brackets: tourney_brackets
192
+ });
193
+ };
194
+ const getMyBrackets = async () => {
195
+ setMyBrackets({
196
+ ...my_brackets_data,
197
+ my_brackets_loading: true
198
+ });
199
+ const my_response = await BracketComeptitionApi.getMyPlayerBrackets();
200
+ const bracket_ids = [...new Set(my_response.player_brackets.map(pb => pb.bracket_id))];
201
+ let brackets = await BracketApi.getBracketsByIds(bracket_ids);
202
+ let champ_team_ids = my_response.player_brackets.filter(pb => pb.champion_id_type == 'team').map(b => b.champion_id ?? '');
203
+ const champ_teams = await BracketApi.getTeamsByIds(champ_team_ids);
204
+ let champ_athlete_ids = my_response.player_brackets.filter(pb => pb.champion_id_type == 'athlete').map(b => b.champion_id ?? '');
205
+ const champ_athletes = await BracketApi.getAthletesByIds(champ_athlete_ids);
206
+ //Filter to active and closed
207
+ setMyBrackets({
208
+ ...my_brackets_data,
209
+ my_brackets_loading: false,
210
+ my_brackets_loaded: true,
211
+ champion_athletes: champ_athletes,
212
+ champion_teams: champ_teams,
213
+ my_brackets: brackets,
214
+ player_brackets: my_response.player_brackets,
215
+ competition_player_brackets: my_response.competition_player_brackets,
216
+ my_competitions: my_response.bracket_competitions
217
+ });
218
+ };
219
+ const handleView = async (bracket_id, player_bracket_id, bracket_competition) => {
220
+ if (bracket_id && player_bracket_id && bracket_competition) {
221
+ return onView(bracket_id, player_bracket_id, bracket_competition);
222
+ }
223
+ //Ok! Now - what if we do not have a player_bracket
224
+ let init_pb_id = player_bracket_id;
225
+ if (!init_pb_id) {
226
+ //Lets try and find one!
227
+ init_pb_id = player_brackets.find(pb => pb.bracket_id == bracket_id && pb.status != 'deleted')?.player_bracket_id;
228
+ if (!init_pb_id && !my_brackets_loaded) {
229
+ //Lets try and get the plyaers brackets and see!
230
+ const my_pbs = await BracketComeptitionApi.getMyPlayerBrackets();
231
+ init_pb_id = my_pbs.player_brackets.find(pb => pb.bracket_id == bracket_id && pb.status != 'deleted')?.player_bracket_id;
232
+ }
233
+ }
67
234
 
68
- const filterPlayerBrackets = (bs, pbs, status, search) => {
69
- let init_pbs = pbs.filter(pb => pb.status == status);
70
- if (!search || search == '') {
71
- return init_pbs;
235
+ //Ok! Now - what if we do not have a bracket competition!
236
+ let init_bc = bracket_competition;
237
+ if (!init_bc) {
238
+ //First check if my competitions has any!
239
+ init_bc = my_competitions.find(c => c.bracket_id == bracket_id);
240
+ if (!init_bc) {
241
+ init_bc = public_competitions.find(pc => pc.bracket_id == bracket_id);
242
+ }
243
+ if (!init_bc) {
244
+ //Lets try and get one from the server
245
+ const comps_bc = await BracketComeptitionApi.getBracketCompetitionsByBracketId(bracket_id);
246
+ init_bc = comps_bc.find(bc => bc.bracket_id == bracket_id && !bc.invite_only);
247
+ }
72
248
  }
73
- let brackets = bs.filter(b => `${b.bracket_name.toLowerCase()}`.includes(search.toLowerCase()));
74
- return init_pbs.filter(pb => brackets.map(b => b.bracket_id.toString()).includes(pb.bracket_id.toString()));
249
+ return onView(bracket_id, init_pb_id, init_bc);
75
250
  };
76
- let visible_player_brackets = useMemo(() => {
77
- return filterPlayerBrackets(brackets, player_brackets, 'active', active_search);
78
- }, [brackets.length, player_brackets.length, active_search]);
79
- const active_bracket_ids = [...new Set(visible_player_brackets.map(pb => pb.bracket_id))];
80
- let past_player_brackets = useMemo(() => {
81
- return filterPlayerBrackets(brackets, player_brackets, 'closed', past_search);
82
- }, [brackets.length, player_brackets.length, past_search]);
83
- const past_bracket_ids = [...new Set(past_player_brackets.map(pb => pb.bracket_id))];
84
- const competition_bracket_ids = [...new Set(public_competitions.map(bc => bc.bracket_id))];
85
- const competition_brackets = brackets.filter(b => competition_bracket_ids.includes(b.bracket_id));
86
- const competition_league_ids = [...new Set(competition_brackets.map(cb => cb.league_id))];
87
251
  const pb_width = calcCardWidth(width, 6);
88
252
  const renderBrackets = data => {
89
- const bracket = brackets.find(b => b.bracket_id == data.item);
253
+ const bracket = my_brackets.find(b => b.bracket_id == data.item);
90
254
  if (!bracket) {
91
255
  return /*#__PURE__*/React.createElement(React.Fragment, null);
92
256
  }
93
257
  const expanded = expanded_brackets.includes(data.item) ? true : false;
94
- let my_player_brackets = player_brackets.filter(pb => pb.bracket_id == data.item);
258
+ let my_player_brackets = player_brackets.filter(pb => pb.bracket_id == data.item && pb.status != 'deleted');
95
259
  let additional = my_player_brackets.length - 1;
96
260
  if (!expanded) {
97
261
  my_player_brackets = my_player_brackets.slice(0, 1);
@@ -99,6 +263,7 @@ const RoomHome = ({
99
263
  const league = leagues.find(l => l.league_id == bracket.league_id);
100
264
  const act_loading = action_loading == data.item ? true : false;
101
265
  return /*#__PURE__*/React.createElement(View, {
266
+ key: `${data.item}_${data.index}_bracket`,
102
267
  float: true,
103
268
  style: {
104
269
  margin: 5,
@@ -109,7 +274,9 @@ const RoomHome = ({
109
274
  style: {
110
275
  flexDirection: 'row',
111
276
  alignItems: 'center',
112
- padding: 10
277
+ padding: 10,
278
+ borderTopRightRadius: 8,
279
+ borderTopLeftRadius: 8
113
280
  }
114
281
  }, league ? /*#__PURE__*/React.createElement(Image, {
115
282
  style: {
@@ -174,11 +341,14 @@ const RoomHome = ({
174
341
  completion_status: 'inprogress',
175
342
  status: 'active'
176
343
  });
177
- onUpdatePlayerBracket(new_pb);
178
344
  setActionLoading(undefined);
179
345
  if (!expanded) {
180
346
  setExpandedBrackets(expanded_brackets.concat(data.item));
181
347
  }
348
+ setMyBrackets({
349
+ ...my_brackets_data,
350
+ player_brackets: player_brackets.filter(pb => pb.player_bracket_id != new_pb.player_bracket_id).concat(new_pb)
351
+ });
182
352
  }
183
353
  }) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(View, {
184
354
  style: {
@@ -215,7 +385,7 @@ const RoomHome = ({
215
385
  borderBottomWidth: 1,
216
386
  borderColor: Colors.borders.light
217
387
  },
218
- 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)
388
+ onPress: () => handleView(data.item.bracket_id, undefined, data.item)
219
389
  }, /*#__PURE__*/React.createElement(View, {
220
390
  transparent: true
221
391
  }, /*#__PURE__*/React.createElement(Image, {
@@ -293,7 +463,9 @@ const RoomHome = ({
293
463
  })), /*#__PURE__*/React.createElement(View, {
294
464
  type: "footer",
295
465
  style: {
296
- padding: 8
466
+ padding: 8,
467
+ borderBottomLeftRadius: 8,
468
+ borderBottomRightRadius: 8
297
469
  }
298
470
  }, /*#__PURE__*/React.createElement(Button, {
299
471
  type: "action",
@@ -304,16 +476,24 @@ const RoomHome = ({
304
476
  onPress: () => onManageCompetition(data.item.bracket_competition_id)
305
477
  })));
306
478
  };
307
- const renderPlayerBrackets = useCallback(data => {
479
+ const handleSearchPrivate = async code => {
480
+ const bc = await BracketComeptitionApi.getBracketcompetitionByCode(code);
481
+ if (!bc) {
482
+ return alert('Unable to find private competition by that code');
483
+ }
484
+ let pb_response = await BracketComeptitionApi.getMyPlayerBrackets(bc.bracket_id);
485
+ return handleView(bc.bracket_id, pb_response.player_brackets[0]?.player_bracket_id, bc);
486
+ };
487
+ const renderPlayerBrackets = data => {
308
488
  const cpbs = competition_player_brackets.filter(cpb => cpb.status != 'deleted' && cpb.player_bracket_id == data.item.player_bracket_id);
309
- const comps = bracket_competitions.filter(bc => cpbs.map(cpb => cpb.bracket_competition_id.toString()).includes(bc.bracket_competition_id.toString()));
310
- const bracket = brackets.find(b => b.bracket_id == data.item.bracket_id);
489
+ const comps = my_competitions.filter(bc => cpbs.map(cpb => cpb.bracket_competition_id.toString()).includes(bc.bracket_competition_id.toString()));
490
+ const bracket = my_brackets.find(b => b.bracket_id == data.item.bracket_id);
311
491
  if (!bracket) {
312
492
  return /*#__PURE__*/React.createElement(React.Fragment, null);
313
493
  }
314
494
  const league = leagues.find(l => l.league_id == bracket.league_id);
315
- const champion_team = teams.find(t => data.item.champion_id_type == 'team' && t.team_id == data.item.champion_id);
316
- const champion_athlete = athletes.find(t => data.item.champion_id_type == 'athlete' && t.athlete_id == data.item.champion_id);
495
+ const champion_team = champion_teams.find(t => data.item.champion_id_type == 'team' && t.team_id == data.item.champion_id);
496
+ const champion_athlete = champion_athletes.find(t => data.item.champion_id_type == 'athlete' && t.athlete_id == data.item.champion_id);
317
497
  return /*#__PURE__*/React.createElement(View, {
318
498
  style: {
319
499
  borderBottomWidth: 1,
@@ -328,10 +508,17 @@ const RoomHome = ({
328
508
  competition_player_brackets: cpbs,
329
509
  bracket: bracket,
330
510
  bracket_competitions: comps,
331
- onView: onView,
332
- onEdit: onEditPlayerBracket
511
+ onView: (bracket_id, player_bracket_id) => handleView(bracket_id, player_bracket_id),
512
+ onEdit: () => setEditingPlayerBracket(data.item),
513
+ onShowCompetitions: () => setShowComps({
514
+ player_bracket: data.item,
515
+ entered_competitions: comps,
516
+ entered_brackets: cpbs,
517
+ champion_team,
518
+ champion_athlete
519
+ })
333
520
  }));
334
- }, [JSON.stringify(player_brackets)]);
521
+ };
335
522
  const renderLeagueFilters = data => {
336
523
  const league = leagues.find(l => l.league_id == data.item);
337
524
  if (!league) {
@@ -347,7 +534,8 @@ const RoomHome = ({
347
534
  paddingRight: 10,
348
535
  paddingLeft: 10,
349
536
  borderRadius: 100,
350
- margin: 5
537
+ margin: 5,
538
+ backgroundColor: selected ? Colors.text.highlight : undefined
351
539
  },
352
540
  onPress: () => selected ? setSelectedLeague(undefined) : setSelectedLeague(data.item)
353
541
  }, /*#__PURE__*/React.createElement(Image, {
@@ -374,7 +562,7 @@ const RoomHome = ({
374
562
  borderBottomWidth: 1,
375
563
  borderColor: Colors.borders.light
376
564
  },
377
- onPress: () => onView(data.item.bracket_id, player_brackets.find(pb => pb.bracket_id == data.item.bracket_id)?.player_bracket_id, undefined)
565
+ onPress: () => handleView(data.item.bracket_id)
378
566
  }, /*#__PURE__*/React.createElement(Icons.BracketIcon, {
379
567
  size: 18,
380
568
  color: Colors.text.h1
@@ -406,7 +594,7 @@ const RoomHome = ({
406
594
  }
407
595
  const expanded = expanded_c_leagues.includes(data.item) ? true : false;
408
596
  //Find all the brackets for this league
409
- let league_brackets = active_brackets.filter(b => b.league_id == data.item);
597
+ let league_brackets = competition_brackets.filter(b => b.league_id == data.item);
410
598
  let league_competitions = public_competitions.filter(bc => league_brackets.map(lb => lb.bracket_id.toString()).includes(bc.bracket_id.toString()));
411
599
  const num_comps = league_competitions.length;
412
600
  let additional = league_competitions.length - 1;
@@ -494,7 +682,7 @@ const RoomHome = ({
494
682
  return /*#__PURE__*/React.createElement(React.Fragment, null);
495
683
  }
496
684
  const expanded = expanded_leagues.includes(data.item) ? true : false;
497
- let league_brackets = active_brackets.filter(b => b.league_id == data.item);
685
+ let league_brackets = tournament_brackets.filter(b => b.league_id == data.item);
498
686
  let additional = league_brackets.length - 1;
499
687
  if (!expanded) {
500
688
  league_brackets = league_brackets.slice(0, 1);
@@ -579,7 +767,8 @@ const RoomHome = ({
579
767
  case 'toggle':
580
768
  return /*#__PURE__*/React.createElement(View, {
581
769
  style: {
582
- margin: 5
770
+ margin: 10,
771
+ marginTop: 18
583
772
  }
584
773
  }, /*#__PURE__*/React.createElement(Toggle, {
585
774
  options: [{
@@ -600,13 +789,17 @@ const RoomHome = ({
600
789
  return /*#__PURE__*/React.createElement(React.Fragment, null);
601
790
  }
602
791
  return /*#__PURE__*/React.createElement(View, {
603
- nativeID: "my_competitions"
792
+ nativeID: "my_competitions",
793
+ style: {
794
+ marginTop: 18
795
+ }
604
796
  }, /*#__PURE__*/React.createElement(View, {
605
- type: "header",
606
797
  style: {
607
- padding: 10,
798
+ padding: 18,
608
799
  flexDirection: 'row',
609
- alignItems: 'center'
800
+ alignItems: 'center',
801
+ borderBottomWidth: 1,
802
+ borderColor: Colors.borders.light
610
803
  }
611
804
  }, /*#__PURE__*/React.createElement(View, {
612
805
  transparent: true,
@@ -629,22 +822,28 @@ const RoomHome = ({
629
822
  justifyContent: 'center',
630
823
  alignItems: 'center'
631
824
  },
632
- onPress: () => setShowActiveSearch(!show_active_search)
633
- }, show_active_search ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
825
+ onPress: () => setActiveSearch({
826
+ visible: !active_search.visible,
827
+ value: ''
828
+ })
829
+ }, active_search.visible ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
634
830
  size: 14,
635
831
  color: Colors.text.error
636
832
  }) : /*#__PURE__*/React.createElement(Icons.SearchIcon, {
637
833
  size: 14,
638
834
  color: Colors.text.action
639
- }))), show_active_search ? /*#__PURE__*/React.createElement(SearchBox, {
640
- onChange: text => setActiveSearch(text),
835
+ }))), active_search.visible ? /*#__PURE__*/React.createElement(SearchBox, {
836
+ onChange: text => setActiveSearch({
837
+ ...active_search,
838
+ value: text
839
+ }),
641
840
  hide_search_button: true,
642
841
  placeholder: "Search Active Brackets",
643
842
  onFocusPosition: onFocusPosition
644
843
  }) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(View, {
645
- type: "body",
844
+ type: "header",
646
845
  style: {
647
- marginBottom: 10,
846
+ padding: 10,
648
847
  flexDirection: 'row',
649
848
  flexWrap: 'wrap',
650
849
  justifyContent: 'center'
@@ -687,25 +886,31 @@ const RoomHome = ({
687
886
  justifyContent: 'center',
688
887
  alignItems: 'center'
689
888
  },
690
- onPress: () => setShowBracketsSearch(!show_brackets_search)
691
- }, show_brackets_search ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
889
+ onPress: () => setTourneySearch({
890
+ visible: !tourney_search.visible,
891
+ value: ''
892
+ })
893
+ }, tourney_search.visible ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
692
894
  size: 14,
693
895
  color: Colors.text.error
694
896
  }) : /*#__PURE__*/React.createElement(Icons.SearchIcon, {
695
897
  size: 14,
696
898
  color: Colors.text.action
697
- }))), show_brackets_search ? /*#__PURE__*/React.createElement(View, {
899
+ }))), tourney_search.visible ? /*#__PURE__*/React.createElement(View, {
698
900
  style: {
699
901
  padding: 5
700
902
  }
701
903
  }, /*#__PURE__*/React.createElement(FlatList, {
702
904
  key: "unique_leagues",
703
905
  keyExtractor: item => item,
704
- data: unique_leages,
906
+ data: unique_tournament_leagues,
705
907
  renderItem: renderLeagueFilters,
706
908
  horizontal: true
707
- })) : /*#__PURE__*/React.createElement(React.Fragment, null), show_brackets_search ? /*#__PURE__*/React.createElement(SearchBox, {
708
- onChange: text => setBracketsSearch(text),
909
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null), tourney_search.visible ? /*#__PURE__*/React.createElement(SearchBox, {
910
+ onChange: text => setTourneySearch({
911
+ ...tourney_search,
912
+ value: text
913
+ }),
709
914
  hide_search_button: true,
710
915
  placeholder: "Search Active Tournaments",
711
916
  onFocusPosition: onFocusPosition
@@ -718,7 +923,7 @@ const RoomHome = ({
718
923
  flexWrap: 'wrap',
719
924
  justifyContent: 'center'
720
925
  }
721
- }, unique_leages.map((id, index) => {
926
+ }, unique_tournament_leagues.map((id, index) => {
722
927
  return renderLeagues({
723
928
  item: id,
724
929
  index
@@ -729,13 +934,17 @@ const RoomHome = ({
729
934
  return /*#__PURE__*/React.createElement(React.Fragment, null);
730
935
  }
731
936
  return /*#__PURE__*/React.createElement(View, {
732
- nativeID: "past_brackets"
937
+ nativeID: "past_brackets",
938
+ style: {
939
+ marginTop: 18
940
+ }
733
941
  }, /*#__PURE__*/React.createElement(View, {
734
- type: "header",
735
942
  style: {
736
- padding: 10,
943
+ padding: 18,
737
944
  flexDirection: 'row',
738
- alignItems: 'center'
945
+ alignItems: 'center',
946
+ borderBottomWidth: 1,
947
+ borderColor: Colors.borders.light
739
948
  }
740
949
  }, /*#__PURE__*/React.createElement(View, {
741
950
  transparent: true,
@@ -745,7 +954,7 @@ const RoomHome = ({
745
954
  }
746
955
  }, /*#__PURE__*/React.createElement(Text, {
747
956
  theme: "h1"
748
- }, "MY PAST BRACKETS"), /*#__PURE__*/React.createElement(Text, {
957
+ }, "My Past Brackets"), /*#__PURE__*/React.createElement(Text, {
749
958
  style: {
750
959
  marginTop: 4
751
960
  }
@@ -758,27 +967,33 @@ const RoomHome = ({
758
967
  justifyContent: 'center',
759
968
  alignItems: 'center'
760
969
  },
761
- onPress: () => setShowPastSearch(!show_past_search)
762
- }, show_past_search ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
970
+ onPress: () => setPastSearch({
971
+ visible: !past_search.visible,
972
+ value: ''
973
+ })
974
+ }, past_search.visible ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
763
975
  size: 14,
764
976
  color: Colors.text.error
765
977
  }) : /*#__PURE__*/React.createElement(Icons.SearchIcon, {
766
978
  size: 14,
767
979
  color: Colors.text.action
768
- }))), show_past_search ? /*#__PURE__*/React.createElement(SearchBox, {
769
- onChange: text => setPastSearch(text),
980
+ }))), past_search.visible ? /*#__PURE__*/React.createElement(SearchBox, {
981
+ onChange: text => setPastSearch({
982
+ ...past_search,
983
+ value: text
984
+ }),
770
985
  hide_search_button: true,
771
986
  placeholder: "Search Past Brackets",
772
987
  onFocusPosition: onFocusPosition
773
988
  }) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(View, {
774
- type: "body",
989
+ type: "header",
775
990
  style: {
776
- marginBottom: 10,
991
+ padding: 10,
777
992
  flexDirection: 'row',
778
993
  flexWrap: 'wrap',
779
994
  justifyContent: 'center'
780
995
  }
781
- }, past_bracket_ids.map((id, index) => {
996
+ }, closed_bracket_ids.map((id, index) => {
782
997
  return renderBrackets({
783
998
  item: id,
784
999
  index
@@ -814,24 +1029,72 @@ const RoomHome = ({
814
1029
  padding: 0,
815
1030
  marginRight: 10
816
1031
  },
817
- onPress: () => onMoreAdmin(admin_offset - 1)
1032
+ onPress: () => getAdminComps(admin_offset - 1)
818
1033
  }) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(Button, {
819
1034
  title: "MORE",
820
1035
  type: "text",
821
1036
  style: {
822
1037
  padding: 0
823
1038
  },
824
- onPress: () => onMoreAdmin(admin_offset + 1)
1039
+ onPress: () => getAdminComps(admin_offset + 1)
825
1040
  })), /*#__PURE__*/React.createElement(View, {
826
1041
  style: {
827
1042
  padding: 10
828
1043
  }
829
- }, /*#__PURE__*/React.createElement(FlatList, {
1044
+ }, /*#__PURE__*/React.createElement(View, {
1045
+ style: {
1046
+ flexDirection: 'row'
1047
+ }
1048
+ }, onCreateNewCompetition ? /*#__PURE__*/React.createElement(View, {
1049
+ float: true,
1050
+ style: {
1051
+ width: 100,
1052
+ margin: 5,
1053
+ borderWidth: 1,
1054
+ borderColor: Colors.text.success
1055
+ }
1056
+ }, /*#__PURE__*/React.createElement(View, {
1057
+ type: "header",
1058
+ style: {
1059
+ borderTopRightRadius: 8,
1060
+ borderTopLeftRadius: 8,
1061
+ padding: 5
1062
+ }
1063
+ }, /*#__PURE__*/React.createElement(Text, {
1064
+ style: {
1065
+ padding: 5
1066
+ },
1067
+ theme: "description",
1068
+ textAlign: "center"
1069
+ }, "NEW")), /*#__PURE__*/React.createElement(View, {
1070
+ style: {
1071
+ flex: 1,
1072
+ justifyContent: 'center',
1073
+ alignItems: 'center'
1074
+ }
1075
+ }, /*#__PURE__*/React.createElement(Icons.BracketIcon, {
1076
+ size: 40,
1077
+ color: Colors.text.h1
1078
+ })), /*#__PURE__*/React.createElement(View, {
1079
+ type: "footer",
1080
+ style: {
1081
+ padding: 8,
1082
+ borderBottomLeftRadius: 8,
1083
+ borderBottomRightRadius: 8
1084
+ }
1085
+ }, /*#__PURE__*/React.createElement(Button, {
1086
+ title: "CREATE",
1087
+ type: "success",
1088
+ style: {
1089
+ padding: 5
1090
+ },
1091
+ onPress: () => onCreateNewCompetition()
1092
+ }))) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(FlatList, {
830
1093
  data: admin_competitions,
831
1094
  renderItem: renderAdminCompetitions,
832
1095
  keyExtractor: item => `admin_${item.bracket_competition_id.toString()}`,
833
1096
  horizontal: true
834
- })));
1097
+ }))));
835
1098
  case 'competitions':
836
1099
  if (active_toggle != 'competitions') {
837
1100
  return /*#__PURE__*/React.createElement(React.Fragment, null);
@@ -866,8 +1129,11 @@ const RoomHome = ({
866
1129
  justifyContent: 'center',
867
1130
  alignItems: 'center'
868
1131
  },
869
- onPress: () => setShowCompetitionSearch(!show_competition_search)
870
- }, show_competition_search ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
1132
+ onPress: () => setCompSearch({
1133
+ visible: !comp_search.visible,
1134
+ value: ''
1135
+ })
1136
+ }, comp_search.visible ? /*#__PURE__*/React.createElement(Icons.CloseIcon, {
871
1137
  size: 12,
872
1138
  color: Colors.text.error
873
1139
  }) : /*#__PURE__*/React.createElement(Icons.SearchIcon, {
@@ -891,9 +1157,12 @@ const RoomHome = ({
891
1157
  }, "+"), /*#__PURE__*/React.createElement(Icons.TrophyIcon, {
892
1158
  color: Colors.text.white,
893
1159
  size: 14
894
- })) : /*#__PURE__*/React.createElement(React.Fragment, null)), show_competition_search ? /*#__PURE__*/React.createElement(SearchBox, {
895
- onChange: text => setCompetitionSearch(text),
896
- onSearch: text => console.log(text),
1160
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null)), comp_search.visible ? /*#__PURE__*/React.createElement(SearchBox, {
1161
+ onChange: text => setCompSearch({
1162
+ ...comp_search,
1163
+ value: text
1164
+ }),
1165
+ onSearch: text => handleSearchPrivate(text),
897
1166
  placeholder: "Search or Enter Private Code",
898
1167
  onFocusPosition: onFocusPosition
899
1168
  }) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(View, {
@@ -905,7 +1174,7 @@ const RoomHome = ({
905
1174
  flexWrap: 'wrap',
906
1175
  justifyContent: 'center'
907
1176
  }
908
- }, competition_league_ids.map((id, index) => {
1177
+ }, unique_competition_leagues.map((id, index) => {
909
1178
  return renderLeaguesForCompetitions({
910
1179
  item: id,
911
1180
  index
@@ -925,8 +1194,40 @@ const RoomHome = ({
925
1194
  }, /*#__PURE__*/React.createElement(FlatList, {
926
1195
  data: sections,
927
1196
  key: "room_sections",
1197
+ refreshing: my_brackets_loading,
928
1198
  keyExtractor: item => item,
929
1199
  renderItem: renderSections
1200
+ }), /*#__PURE__*/React.createElement(EditPlayerBracket, {
1201
+ player_bracket: editing_player_bracket,
1202
+ view_mode: view_mode,
1203
+ insets: insets,
1204
+ onClose: () => setEditingPlayerBracket(undefined),
1205
+ onFocusPosition: onFocusPosition,
1206
+ onUpdatePlayerBracket: new_pb => {
1207
+ setEditingPlayerBracket(undefined);
1208
+ setMyBrackets({
1209
+ ...my_brackets_data,
1210
+ player_brackets: player_brackets.filter(pb => pb.player_bracket_id != new_pb.player_bracket_id).concat(new_pb)
1211
+ });
1212
+ }
1213
+ }), /*#__PURE__*/React.createElement(EnteredCompetitionsModal, {
1214
+ player_bracket: show_comps.player_bracket,
1215
+ onSelectCompetition: bc => {
1216
+ if (!show_comps.player_bracket) {
1217
+ return;
1218
+ }
1219
+ onView(show_comps.player_bracket.bracket_id, show_comps.player_bracket.player_bracket_id, bc);
1220
+ },
1221
+ insets: insets,
1222
+ champion_team: show_comps.champion_team,
1223
+ champion_athlete: show_comps.champion_athlete,
1224
+ onClose: () => setShowComps({
1225
+ entered_brackets: [],
1226
+ entered_competitions: []
1227
+ }),
1228
+ entered_brackets: show_comps.entered_brackets,
1229
+ entered_competitions: show_comps.entered_competitions,
1230
+ view_mode: view_mode
930
1231
  }));
931
1232
  };
932
1233
  export default RoomHome;