be-components 6.6.1 → 6.6.2

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 (78) hide show
  1. package/lib/commonjs/Engage/components/CompetitionCard.js +54 -1
  2. package/lib/commonjs/Engage/components/CompetitionCard.js.map +1 -1
  3. package/lib/commonjs/Group/api/index.js +203 -0
  4. package/lib/commonjs/Group/api/index.js.map +1 -0
  5. package/lib/commonjs/Group/components/GroupCTAButton.js +85 -0
  6. package/lib/commonjs/Group/components/GroupCTAButton.js.map +1 -0
  7. package/lib/commonjs/Group/components/GroupPlayerActionForm.js +166 -0
  8. package/lib/commonjs/Group/components/GroupPlayerActionForm.js.map +1 -0
  9. package/lib/commonjs/Group/components/ManageGroupForm.js +476 -0
  10. package/lib/commonjs/Group/components/ManageGroupForm.js.map +1 -0
  11. package/lib/commonjs/Group/index.js +671 -0
  12. package/lib/commonjs/Group/index.js.map +1 -0
  13. package/lib/commonjs/index.js +7 -0
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/module/Engage/components/CompetitionCard.js +54 -1
  16. package/lib/module/Engage/components/CompetitionCard.js.map +1 -1
  17. package/lib/module/Group/api/index.js +197 -0
  18. package/lib/module/Group/api/index.js.map +1 -0
  19. package/lib/module/Group/components/GroupCTAButton.js +78 -0
  20. package/lib/module/Group/components/GroupCTAButton.js.map +1 -0
  21. package/lib/module/Group/components/GroupPlayerActionForm.js +159 -0
  22. package/lib/module/Group/components/GroupPlayerActionForm.js.map +1 -0
  23. package/lib/module/Group/components/ManageGroupForm.js +469 -0
  24. package/lib/module/Group/components/ManageGroupForm.js.map +1 -0
  25. package/lib/module/Group/index.js +663 -0
  26. package/lib/module/Group/index.js.map +1 -0
  27. package/lib/module/index.js +2 -1
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/typescript/lib/commonjs/Engage/components/CompetitionCard.d.ts +4 -1
  30. package/lib/typescript/lib/commonjs/Engage/components/CompetitionCard.d.ts.map +1 -1
  31. package/lib/typescript/lib/commonjs/Group/api/index.d.ts +38 -0
  32. package/lib/typescript/lib/commonjs/Group/api/index.d.ts.map +1 -0
  33. package/lib/typescript/lib/commonjs/Group/components/GroupCTAButton.d.ts +10 -0
  34. package/lib/typescript/lib/commonjs/Group/components/GroupCTAButton.d.ts.map +1 -0
  35. package/lib/typescript/lib/commonjs/Group/components/GroupPlayerActionForm.d.ts +9 -0
  36. package/lib/typescript/lib/commonjs/Group/components/GroupPlayerActionForm.d.ts.map +1 -0
  37. package/lib/typescript/lib/commonjs/Group/components/ManageGroupForm.d.ts +10 -0
  38. package/lib/typescript/lib/commonjs/Group/components/ManageGroupForm.d.ts.map +1 -0
  39. package/lib/typescript/lib/commonjs/Group/index.d.ts +12 -0
  40. package/lib/typescript/lib/commonjs/Group/index.d.ts.map +1 -0
  41. package/lib/typescript/lib/commonjs/index.d.ts +1 -0
  42. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  43. package/lib/typescript/lib/module/Engage/components/CompetitionCard.d.ts +4 -1
  44. package/lib/typescript/lib/module/Engage/components/CompetitionCard.d.ts.map +1 -1
  45. package/lib/typescript/lib/module/Group/api/index.d.ts +37 -0
  46. package/lib/typescript/lib/module/Group/api/index.d.ts.map +1 -0
  47. package/lib/typescript/lib/module/Group/components/GroupCTAButton.d.ts +10 -0
  48. package/lib/typescript/lib/module/Group/components/GroupCTAButton.d.ts.map +1 -0
  49. package/lib/typescript/lib/module/Group/components/GroupPlayerActionForm.d.ts +9 -0
  50. package/lib/typescript/lib/module/Group/components/GroupPlayerActionForm.d.ts.map +1 -0
  51. package/lib/typescript/lib/module/Group/components/ManageGroupForm.d.ts +10 -0
  52. package/lib/typescript/lib/module/Group/components/ManageGroupForm.d.ts.map +1 -0
  53. package/lib/typescript/lib/module/Group/index.d.ts +12 -0
  54. package/lib/typescript/lib/module/Group/index.d.ts.map +1 -0
  55. package/lib/typescript/lib/module/index.d.ts +2 -1
  56. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  57. package/lib/typescript/src/Engage/components/CompetitionCard.d.ts +5 -2
  58. package/lib/typescript/src/Engage/components/CompetitionCard.d.ts.map +1 -1
  59. package/lib/typescript/src/Group/api/index.d.ts +47 -0
  60. package/lib/typescript/src/Group/api/index.d.ts.map +1 -0
  61. package/lib/typescript/src/Group/components/GroupCTAButton.d.ts +13 -0
  62. package/lib/typescript/src/Group/components/GroupCTAButton.d.ts.map +1 -0
  63. package/lib/typescript/src/Group/components/GroupPlayerActionForm.d.ts +12 -0
  64. package/lib/typescript/src/Group/components/GroupPlayerActionForm.d.ts.map +1 -0
  65. package/lib/typescript/src/Group/components/ManageGroupForm.d.ts +12 -0
  66. package/lib/typescript/src/Group/components/ManageGroupForm.d.ts.map +1 -0
  67. package/lib/typescript/src/Group/index.d.ts +14 -0
  68. package/lib/typescript/src/Group/index.d.ts.map +1 -0
  69. package/lib/typescript/src/index.d.ts +2 -1
  70. package/lib/typescript/src/index.d.ts.map +1 -1
  71. package/package.json +1 -1
  72. package/src/Engage/components/CompetitionCard.tsx +29 -2
  73. package/src/Group/api/index.ts +176 -0
  74. package/src/Group/components/GroupCTAButton.tsx +57 -0
  75. package/src/Group/components/GroupPlayerActionForm.tsx +137 -0
  76. package/src/Group/components/ManageGroupForm.tsx +239 -0
  77. package/src/Group/index.tsx +497 -0
  78. package/src/index.tsx +2 -0
@@ -0,0 +1,663 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, View } from "../Components/Themed";
3
+ import { GroupApi, GroupHelpers } from './api';
4
+ import { ActivityIndicator, FlatList, Image } from 'react-native';
5
+ import { Icons, Toggle } from '../Components';
6
+ import { useColors } from '../constants/useColors';
7
+ import moment from 'moment-mini';
8
+ import ManageGroupForm from './components/ManageGroupForm';
9
+ import GroupPlayerActionForm from './components/GroupPlayerActionForm';
10
+ import CompetitionCard from '../Engage/components/CompetitionCard';
11
+ import { PostCard } from '../SocialComponents';
12
+ import Pagination from '../Components/Pagination';
13
+ import GroupCTAButton from './components/GroupCTAButton';
14
+ const sections = ['header', 'chat', 'me', 'toggle', 'competition_toggle', 'members', 'competitions', 'activity'];
15
+ const GroupComponent = ({
16
+ group_id,
17
+ player,
18
+ mode,
19
+ onInvitePlayer,
20
+ onSelectCompetition,
21
+ onSelectChat,
22
+ onSelectPlayer
23
+ }) => {
24
+ const Colors = useColors();
25
+ const leader_options = [{
26
+ to: moment().subtract(1, 'days').unix(),
27
+ from: moment().unix(),
28
+ option: '24_hours',
29
+ label: '24 Hours'
30
+ }, {
31
+ to: moment().subtract(7, 'days').unix(),
32
+ from: moment().unix(),
33
+ option: '7_days',
34
+ label: '7 Days'
35
+ }, {
36
+ to: moment().subtract(30, 'days').unix(),
37
+ from: moment().unix(),
38
+ option: '30_days',
39
+ label: '30 Days'
40
+ }, {
41
+ to: moment().subtract(60, 'days').unix(),
42
+ from: moment().unix(),
43
+ option: '60_days',
44
+ label: '60 Days'
45
+ }];
46
+ const [activity_data, setActivityData] = useState({
47
+ loading: false,
48
+ posts: [],
49
+ orders: [],
50
+ offset: 0
51
+ });
52
+ const [comp_data, setCompData] = useState({
53
+ loading: false,
54
+ toggle: 'upcoming',
55
+ competition_payout_types: [],
56
+ competition_result_types: [],
57
+ competition_types: [],
58
+ active_competitions: [],
59
+ competition_players: [],
60
+ competition_records: [],
61
+ competition_results: [],
62
+ offset: 0
63
+ });
64
+ const [group_analytics, setGroupAnalytics] = useState({
65
+ loading: false,
66
+ time_option: leader_options[0],
67
+ order_analytics: []
68
+ });
69
+ const {
70
+ time_option,
71
+ order_analytics
72
+ } = group_analytics;
73
+ const [group_data, setGroupData] = useState({
74
+ loading: false,
75
+ group_messages: [],
76
+ editing: false,
77
+ show_player_status: false,
78
+ active_toggle: 'members',
79
+ group_players: [],
80
+ players: []
81
+ });
82
+ const {
83
+ loading,
84
+ group,
85
+ active_toggle,
86
+ editing,
87
+ show_player_status,
88
+ group_messages,
89
+ group_players,
90
+ my_group_player,
91
+ players
92
+ } = group_data;
93
+ const {
94
+ sorted_players,
95
+ player_analytics
96
+ } = GroupHelpers.sortMembers(group_players, order_analytics);
97
+ useEffect(() => {
98
+ getGroupData(group_id);
99
+ }, [group_id]);
100
+ useEffect(() => {
101
+ getToggleData(active_toggle);
102
+ }, [active_toggle]);
103
+ const getToggleData = async toggle => {
104
+ switch (toggle) {
105
+ case 'members':
106
+ if (!time_option) {
107
+ return;
108
+ }
109
+ return getGroupAnalytics(group_id, time_option);
110
+ case 'competitions':
111
+ return getCompetitionData(comp_data.toggle, 0);
112
+ case 'activity':
113
+ return getActitiyData(0);
114
+ default:
115
+ return;
116
+ }
117
+ };
118
+ const getActitiyData = async page => {
119
+ setActivityData({
120
+ ...activity_data,
121
+ loading: false
122
+ });
123
+ const activity = await GroupApi.getPostsByGroupId(group_id, page);
124
+ let order_ids = [];
125
+ activity.filter(a => a.memo_orders).map(mo => mo.memo_orders.map(o => order_ids.push(o)));
126
+ let activity_orders = await GroupApi.getBulkOrders(order_ids);
127
+ setActivityData({
128
+ ...activity_data,
129
+ loading: false,
130
+ offset: page,
131
+ orders: activity_orders,
132
+ posts: activity.sort((a, b) => moment(a.create_datetime).unix() - moment(b.create_datetime).unix())
133
+ });
134
+ };
135
+ const getCompetitionData = async (type, page) => {
136
+ setCompData({
137
+ ...comp_data,
138
+ loading: true
139
+ });
140
+ let resp = {
141
+ competitions: [],
142
+ competition_players: [],
143
+ competition_records: [],
144
+ competition_results: []
145
+ };
146
+ if (type == 'upcoming') {
147
+ resp = await GroupApi.getActiveCompetitions(group_id);
148
+ } else {
149
+ resp = await GroupApi.getHistoryCompetitions(group_id, page);
150
+ }
151
+ const opts = await GroupApi.getCompetitionOptions();
152
+ setCompData({
153
+ ...comp_data,
154
+ loading: false,
155
+ toggle: type,
156
+ competition_players: resp.competition_players,
157
+ competition_records: resp.competition_records,
158
+ competition_results: resp.competition_results,
159
+ competition_payout_types: opts.competition_payout_types,
160
+ competition_result_types: opts.competition_result_types,
161
+ competition_types: opts.competition_types,
162
+ active_competitions: resp.competitions,
163
+ offset: page
164
+ });
165
+ };
166
+ const getGroupAnalytics = async (id, time_option) => {
167
+ setGroupAnalytics({
168
+ ...group_analytics,
169
+ loading: true
170
+ });
171
+ let analytics = await GroupApi.getGroupAnalytics(id, time_option.to, time_option.from);
172
+ setGroupAnalytics({
173
+ ...group_analytics,
174
+ loading: false,
175
+ time_option: time_option,
176
+ order_analytics: analytics
177
+ });
178
+ };
179
+ const getGroupData = async id => {
180
+ GroupApi.setEnvironment();
181
+ setGroupData({
182
+ ...group_data,
183
+ loading: true
184
+ });
185
+ const g_data = await GroupApi.getGroupById(id);
186
+ if (!g_data) {
187
+ setGroupData({
188
+ ...group_data,
189
+ loading: false
190
+ });
191
+ return alert('Unable to get group information. Please try again later');
192
+ }
193
+ let player_ids = [...new Set(g_data.group_players.map(p => p.player_id).concat(g_data.group_messages.map(m => m.player_id)))];
194
+ let plyers = await GroupApi.getPlayersByIds(player_ids);
195
+ setGroupData({
196
+ ...group_data,
197
+ loading: false,
198
+ players: plyers,
199
+ group: g_data.group,
200
+ show_player_status: !g_data.my_group_player ? true : g_data.my_group_player.status == 'active' ? false : true,
201
+ //Show to join if we can
202
+ group_messages: g_data.group_messages,
203
+ group_players: g_data.group_players,
204
+ my_group_player: g_data.my_group_player
205
+ });
206
+ };
207
+ const renderPlayers = data => {
208
+ const player = players.find(p => p.player_id == data.item.player_id);
209
+ if (!player) {
210
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
211
+ }
212
+ const player_analytic = player_analytics[data.item.player_id];
213
+ return /*#__PURE__*/React.createElement(Button, {
214
+ transparent: true,
215
+ style: {
216
+ flexDirection: 'row',
217
+ alignItems: 'center',
218
+ padding: 10,
219
+ borderBottomWidth: 1,
220
+ borderColor: Colors.borders.light,
221
+ borderRadius: 0
222
+ },
223
+ onPress: () => onSelectPlayer(player)
224
+ }, /*#__PURE__*/React.createElement(View, {
225
+ float: true,
226
+ style: {
227
+ borderRadius: 100,
228
+ padding: 2
229
+ }
230
+ }, /*#__PURE__*/React.createElement(Image, {
231
+ source: {
232
+ uri: player.profile_pic
233
+ },
234
+ style: {
235
+ height: 45,
236
+ width: 45,
237
+ borderRadius: 100
238
+ },
239
+ resizeMode: "contain"
240
+ })), /*#__PURE__*/React.createElement(View, {
241
+ transparent: true,
242
+ style: {
243
+ flex: 1,
244
+ marginLeft: 10
245
+ }
246
+ }, /*#__PURE__*/React.createElement(Text, {
247
+ theme: "h1"
248
+ }, "@", player.username), /*#__PURE__*/React.createElement(Text, {
249
+ theme: "description",
250
+ style: {
251
+ marginTop: 3
252
+ }
253
+ }, "Joined ", moment(data.item.create_datetime).fromNow())), player_analytic ? /*#__PURE__*/React.createElement(Text, {
254
+ theme: "h2"
255
+ }, "ROI ", (player_analytic.roi_pct * 100).toFixed(2), "%") : /*#__PURE__*/React.createElement(React.Fragment, null));
256
+ };
257
+ const renderCompetitions = data => {
258
+ const type = comp_data.competition_types.find(t => t.competition_type_id == data.item.competition_type_id);
259
+ const result = comp_data.competition_result_types.find(r => r.competition_result_type_id == data.item.competition_result_type_id);
260
+ if (!type || !result) {
261
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
262
+ }
263
+ const my_result = comp_data.competition_results.find(cr => cr.player_id == player?.player_id && cr.competition_id == data.item.competition_id);
264
+ const my_record = comp_data.competition_records.find(cr => cr.player_id == player?.player_id && cr.competition_id == data.item.competition_id);
265
+ return /*#__PURE__*/React.createElement(CompetitionCard, {
266
+ competition: data.item,
267
+ player: player,
268
+ competition_type: type,
269
+ competition_record: my_record,
270
+ competition_result: my_result,
271
+ competition_result_type: result,
272
+ onCompetitionSelect: onSelectCompetition
273
+ });
274
+ };
275
+ const renderPosts = data => {
276
+ let player = players.find(p => p.player_id == data.item.player_id);
277
+ let orders = activity_data.orders.filter(o => data.item.memo_orders.includes(o.order_id));
278
+ return /*#__PURE__*/React.createElement(View, {
279
+ style: {
280
+ padding: 5
281
+ }
282
+ }, /*#__PURE__*/React.createElement(PostCard, {
283
+ post: data.item,
284
+ player: player,
285
+ orders: orders,
286
+ onRequestAuthenticate: () => console.log(''),
287
+ onSelectArticle: () => console.log(''),
288
+ articles: [],
289
+ width: 300,
290
+ onSelectImage: () => console.log(''),
291
+ onSelectPlayer: onSelectPlayer,
292
+ onSelectTag: () => console.log('')
293
+ }));
294
+ };
295
+ const renderSections = data => {
296
+ switch (data.item) {
297
+ case 'header':
298
+ if (!group) {
299
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
300
+ }
301
+ return /*#__PURE__*/React.createElement(View, {
302
+ type: "header",
303
+ style: {
304
+ flexDirection: 'row',
305
+ alignItems: 'center',
306
+ padding: 10,
307
+ borderBottomWidth: 1,
308
+ borderColor: Colors.borders.light
309
+ }
310
+ }, /*#__PURE__*/React.createElement(Image, {
311
+ source: {
312
+ uri: group.group_image?.url
313
+ },
314
+ style: {
315
+ height: 50,
316
+ width: 50
317
+ },
318
+ resizeMode: "cover"
319
+ }), /*#__PURE__*/React.createElement(View, {
320
+ transparent: true,
321
+ style: {
322
+ flex: 1,
323
+ marginLeft: 10,
324
+ marginRight: 10
325
+ }
326
+ }, /*#__PURE__*/React.createElement(Text, {
327
+ theme: "h1"
328
+ }, group.name), /*#__PURE__*/React.createElement(Text, {
329
+ theme: "description",
330
+ style: {
331
+ marginTop: 3
332
+ }
333
+ }, group.description)), player?.player_id == group.group_admin ? /*#__PURE__*/React.createElement(Button, {
334
+ float: true,
335
+ style: {
336
+ padding: 10
337
+ },
338
+ onPress: () => setGroupData({
339
+ ...group_data,
340
+ editing: true
341
+ })
342
+ }, /*#__PURE__*/React.createElement(Icons.EditIcon, {
343
+ size: 14,
344
+ color: Colors.text.h1
345
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null));
346
+ case 'chat':
347
+ if (!group || !onSelectChat) {
348
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
349
+ }
350
+ return /*#__PURE__*/React.createElement(View, {
351
+ type: "header",
352
+ style: {
353
+ padding: 10,
354
+ borderBottomWidth: 1,
355
+ borderColor: Colors.borders.light
356
+ }
357
+ }, /*#__PURE__*/React.createElement(GroupCTAButton, {
358
+ group: group,
359
+ message_length: 100,
360
+ players: players,
361
+ group_messages: group_messages,
362
+ group_players: group_players,
363
+ onSelectChat: onSelectChat
364
+ }));
365
+ case 'me':
366
+ return /*#__PURE__*/React.createElement(View, {
367
+ type: "row",
368
+ style: {
369
+ padding: 10
370
+ }
371
+ }, player ? /*#__PURE__*/React.createElement(View, {
372
+ style: {
373
+ flex: 1
374
+ },
375
+ type: "row",
376
+ transparent: true
377
+ }, /*#__PURE__*/React.createElement(View, {
378
+ float: true,
379
+ style: {
380
+ borderRadius: 100,
381
+ padding: 2
382
+ }
383
+ }, /*#__PURE__*/React.createElement(Image, {
384
+ style: {
385
+ height: 30,
386
+ width: 30,
387
+ borderRadius: 100
388
+ },
389
+ source: {
390
+ uri: player.profile_pic
391
+ },
392
+ resizeMode: "contain"
393
+ })), /*#__PURE__*/React.createElement(View, {
394
+ transparent: true,
395
+ style: {
396
+ flex: 1,
397
+ marginLeft: 10
398
+ }
399
+ }, /*#__PURE__*/React.createElement(Text, {
400
+ theme: "h1"
401
+ }, "@", player.username), /*#__PURE__*/React.createElement(Text, {
402
+ theme: "description",
403
+ style: {
404
+ marginTop: 3
405
+ }
406
+ }, "Member since ", moment(player.create_datetime).format('MM/DD/YYYY'))), my_group_player?.status == 'invited' ? /*#__PURE__*/React.createElement(Button, {
407
+ type: "action",
408
+ title: "INVTED",
409
+ style: {
410
+ padding: 10
411
+ },
412
+ onPress: () => setGroupData({
413
+ ...group_data,
414
+ show_player_status: true
415
+ })
416
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null), !my_group_player || my_group_player.status == 'inactive' ? /*#__PURE__*/React.createElement(Button, {
417
+ type: "success",
418
+ title: "JOIN",
419
+ style: {
420
+ padding: 10
421
+ },
422
+ onPress: () => setGroupData({
423
+ ...group_data,
424
+ show_player_status: true
425
+ })
426
+ }) : my_group_player?.status != 'invited' ? /*#__PURE__*/React.createElement(Button, {
427
+ type: "error",
428
+ title: "LEAVE",
429
+ style: {
430
+ padding: 10
431
+ },
432
+ onPress: () => setGroupData({
433
+ ...group_data,
434
+ show_player_status: true
435
+ })
436
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)) : /*#__PURE__*/React.createElement(React.Fragment, null));
437
+ case 'toggle':
438
+ return /*#__PURE__*/React.createElement(View, {
439
+ style: {
440
+ padding: 10
441
+ }
442
+ }, /*#__PURE__*/React.createElement(Toggle, {
443
+ options: [{
444
+ key: 'members',
445
+ label: 'Members'
446
+ }, {
447
+ key: 'activity',
448
+ label: 'Activity'
449
+ }, {
450
+ key: 'competitions',
451
+ label: 'Competitions'
452
+ }],
453
+ selected_option: active_toggle,
454
+ onSelectOption: option => setGroupData({
455
+ ...group_data,
456
+ active_toggle: option
457
+ })
458
+ }), loading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
459
+ size: "large",
460
+ color: Colors.text.h1,
461
+ style: {
462
+ padding: 20,
463
+ alignSelf: 'center'
464
+ }
465
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null));
466
+ case 'activity':
467
+ if (active_toggle != 'activity') {
468
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
469
+ }
470
+ return /*#__PURE__*/React.createElement(View, {
471
+ style: {
472
+ padding: 10
473
+ }
474
+ }, /*#__PURE__*/React.createElement(Pagination, {
475
+ offset: activity_data.offset,
476
+ onNext: () => getActitiyData(activity_data.offset + 1),
477
+ onPrevious: () => getActitiyData(activity_data.offset - 1)
478
+ }), /*#__PURE__*/React.createElement(FlatList, {
479
+ data: activity_data.posts,
480
+ key: 'post_list',
481
+ keyExtractor: item => item.memo_post_id.toString(),
482
+ renderItem: renderPosts
483
+ }));
484
+ case 'members':
485
+ if (active_toggle != 'members') {
486
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
487
+ }
488
+ return /*#__PURE__*/React.createElement(View, {
489
+ style: {
490
+ padding: 10
491
+ }
492
+ }, /*#__PURE__*/React.createElement(FlatList, {
493
+ data: sorted_players,
494
+ keyExtractor: item => item.group_player_id.toString(),
495
+ renderItem: renderPlayers,
496
+ key: 'group_members'
497
+ }));
498
+ case 'competition_toggle':
499
+ if (active_toggle != 'competitions') {
500
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
501
+ }
502
+ return /*#__PURE__*/React.createElement(View, {
503
+ style: {
504
+ padding: 10
505
+ }
506
+ }, /*#__PURE__*/React.createElement(Toggle, {
507
+ options: [{
508
+ key: 'upcoming',
509
+ label: 'Upcoming'
510
+ }, {
511
+ key: 'history',
512
+ label: 'History'
513
+ }],
514
+ selected_option: comp_data.toggle,
515
+ onSelectOption: option => getCompetitionData(option, 0)
516
+ }));
517
+ case 'competitions':
518
+ if (active_toggle != 'competitions') {
519
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
520
+ }
521
+ return /*#__PURE__*/React.createElement(View, {
522
+ transparent: true,
523
+ style: {
524
+ padding: 10
525
+ }
526
+ }, /*#__PURE__*/React.createElement(FlatList, {
527
+ key: 'competition_list',
528
+ keyExtractor: item => item.competition_id.toString(),
529
+ data: comp_data.active_competitions.sort((a, b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix()),
530
+ renderItem: renderCompetitions
531
+ }));
532
+ default:
533
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
534
+ }
535
+ };
536
+ return /*#__PURE__*/React.createElement(View, {
537
+ style: {
538
+ flex: 1
539
+ }
540
+ }, /*#__PURE__*/React.createElement(View, {
541
+ style: {
542
+ flex: 1
543
+ }
544
+ }, /*#__PURE__*/React.createElement(FlatList, {
545
+ data: sections,
546
+ key: 'group_list',
547
+ keyExtractor: item => item,
548
+ renderItem: renderSections
549
+ }), active_toggle == 'members' ? /*#__PURE__*/React.createElement(Toggle, {
550
+ options: leader_options.map(o => {
551
+ return {
552
+ key: o.option,
553
+ label: o.label
554
+ };
555
+ }),
556
+ selected_option: time_option?.option,
557
+ onSelectOption: option => {
558
+ const selected = leader_options.find(o => o.option == option);
559
+ if (!selected) {
560
+ return;
561
+ }
562
+ getGroupAnalytics(group_id, selected);
563
+ }
564
+ }) : active_toggle == 'competitions' ? /*#__PURE__*/React.createElement(View, {
565
+ type: "footer",
566
+ style: {
567
+ flexDirection: 'row',
568
+ alignItems: 'center',
569
+ padding: 10
570
+ }
571
+ }, /*#__PURE__*/React.createElement(View, {
572
+ transparent: true,
573
+ style: {
574
+ flex: 1,
575
+ marginRight: 10
576
+ }
577
+ }, /*#__PURE__*/React.createElement(Text, {
578
+ theme: "h2"
579
+ }, "CREATE A NEW COMPETITION"), /*#__PURE__*/React.createElement(Text, {
580
+ theme: "description",
581
+ style: {
582
+ marginTop: 3
583
+ }
584
+ }, "Create a new pick-em or other engagement for this group!")), /*#__PURE__*/React.createElement(Button, {
585
+ type: "success",
586
+ style: {
587
+ padding: 10
588
+ },
589
+ title: "CREATE",
590
+ onPress: () => console.log('New competition!')
591
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null)), editing && group ? /*#__PURE__*/React.createElement(View, {
592
+ type: "blur",
593
+ style: {
594
+ position: 'absolute',
595
+ top: 0,
596
+ left: 0,
597
+ right: 0,
598
+ bottom: 0
599
+ }
600
+ }, /*#__PURE__*/React.createElement(View, {
601
+ type: "blur",
602
+ style: mode == 'desktop' ? {
603
+ justifyContent: 'center',
604
+ alignItems: 'center',
605
+ width: 500,
606
+ height: 500
607
+ } : {
608
+ flex: 1,
609
+ justifyContent: 'flex-end',
610
+ padding: 10
611
+ }
612
+ }, /*#__PURE__*/React.createElement(ManageGroupForm, {
613
+ group: group,
614
+ onInvitePlayer: onInvitePlayer,
615
+ onClose: () => setGroupData({
616
+ ...group_data,
617
+ editing: false
618
+ }),
619
+ onUpdateGroup: g => setGroupData({
620
+ ...group_data,
621
+ group: g
622
+ })
623
+ }))) : /*#__PURE__*/React.createElement(React.Fragment, null), show_player_status && group && player ? /*#__PURE__*/React.createElement(View, {
624
+ type: "blur",
625
+ style: {
626
+ position: 'absolute',
627
+ top: 0,
628
+ left: 0,
629
+ right: 0,
630
+ bottom: 0
631
+ }
632
+ }, /*#__PURE__*/React.createElement(View, {
633
+ type: "blur",
634
+ style: mode == 'desktop' ? {
635
+ justifyContent: 'center',
636
+ alignItems: 'center',
637
+ width: 500,
638
+ height: 500
639
+ } : {
640
+ flex: 1,
641
+ justifyContent: 'flex-end',
642
+ padding: 10
643
+ }
644
+ }, /*#__PURE__*/React.createElement(GroupPlayerActionForm, {
645
+ group: group,
646
+ group_player: my_group_player,
647
+ me: player,
648
+ onResponse: new_gp => {
649
+ setGroupData({
650
+ ...group_data,
651
+ group_players: group_players.filter(gp => gp.group_player_id != new_gp.group_player_id).concat(new_gp),
652
+ my_group_player: new_gp,
653
+ show_player_status: false
654
+ });
655
+ },
656
+ onClose: () => setGroupData({
657
+ ...group_data,
658
+ show_player_status: false
659
+ })
660
+ }))) : /*#__PURE__*/React.createElement(React.Fragment, null));
661
+ };
662
+ export default GroupComponent;
663
+ //# sourceMappingURL=index.js.map