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.
- package/lib/commonjs/Engage/components/CompetitionCard.js +54 -1
- package/lib/commonjs/Engage/components/CompetitionCard.js.map +1 -1
- package/lib/commonjs/Group/api/index.js +203 -0
- package/lib/commonjs/Group/api/index.js.map +1 -0
- package/lib/commonjs/Group/components/GroupCTAButton.js +85 -0
- package/lib/commonjs/Group/components/GroupCTAButton.js.map +1 -0
- package/lib/commonjs/Group/components/GroupPlayerActionForm.js +166 -0
- package/lib/commonjs/Group/components/GroupPlayerActionForm.js.map +1 -0
- package/lib/commonjs/Group/components/ManageGroupForm.js +476 -0
- package/lib/commonjs/Group/components/ManageGroupForm.js.map +1 -0
- package/lib/commonjs/Group/index.js +671 -0
- package/lib/commonjs/Group/index.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Engage/components/CompetitionCard.js +54 -1
- package/lib/module/Engage/components/CompetitionCard.js.map +1 -1
- package/lib/module/Group/api/index.js +197 -0
- package/lib/module/Group/api/index.js.map +1 -0
- package/lib/module/Group/components/GroupCTAButton.js +78 -0
- package/lib/module/Group/components/GroupCTAButton.js.map +1 -0
- package/lib/module/Group/components/GroupPlayerActionForm.js +159 -0
- package/lib/module/Group/components/GroupPlayerActionForm.js.map +1 -0
- package/lib/module/Group/components/ManageGroupForm.js +469 -0
- package/lib/module/Group/components/ManageGroupForm.js.map +1 -0
- package/lib/module/Group/index.js +663 -0
- package/lib/module/Group/index.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Engage/components/CompetitionCard.d.ts +4 -1
- package/lib/typescript/lib/commonjs/Engage/components/CompetitionCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Group/api/index.d.ts +38 -0
- package/lib/typescript/lib/commonjs/Group/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Group/components/GroupCTAButton.d.ts +10 -0
- package/lib/typescript/lib/commonjs/Group/components/GroupCTAButton.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Group/components/GroupPlayerActionForm.d.ts +9 -0
- package/lib/typescript/lib/commonjs/Group/components/GroupPlayerActionForm.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Group/components/ManageGroupForm.d.ts +10 -0
- package/lib/typescript/lib/commonjs/Group/components/ManageGroupForm.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Group/index.d.ts +12 -0
- package/lib/typescript/lib/commonjs/Group/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Engage/components/CompetitionCard.d.ts +4 -1
- package/lib/typescript/lib/module/Engage/components/CompetitionCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Group/api/index.d.ts +37 -0
- package/lib/typescript/lib/module/Group/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/Group/components/GroupCTAButton.d.ts +10 -0
- package/lib/typescript/lib/module/Group/components/GroupCTAButton.d.ts.map +1 -0
- package/lib/typescript/lib/module/Group/components/GroupPlayerActionForm.d.ts +9 -0
- package/lib/typescript/lib/module/Group/components/GroupPlayerActionForm.d.ts.map +1 -0
- package/lib/typescript/lib/module/Group/components/ManageGroupForm.d.ts +10 -0
- package/lib/typescript/lib/module/Group/components/ManageGroupForm.d.ts.map +1 -0
- package/lib/typescript/lib/module/Group/index.d.ts +12 -0
- package/lib/typescript/lib/module/Group/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/Engage/components/CompetitionCard.d.ts +5 -2
- package/lib/typescript/src/Engage/components/CompetitionCard.d.ts.map +1 -1
- package/lib/typescript/src/Group/api/index.d.ts +47 -0
- package/lib/typescript/src/Group/api/index.d.ts.map +1 -0
- package/lib/typescript/src/Group/components/GroupCTAButton.d.ts +13 -0
- package/lib/typescript/src/Group/components/GroupCTAButton.d.ts.map +1 -0
- package/lib/typescript/src/Group/components/GroupPlayerActionForm.d.ts +12 -0
- package/lib/typescript/src/Group/components/GroupPlayerActionForm.d.ts.map +1 -0
- package/lib/typescript/src/Group/components/ManageGroupForm.d.ts +12 -0
- package/lib/typescript/src/Group/components/ManageGroupForm.d.ts.map +1 -0
- package/lib/typescript/src/Group/index.d.ts +14 -0
- package/lib/typescript/src/Group/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Engage/components/CompetitionCard.tsx +29 -2
- package/src/Group/api/index.ts +176 -0
- package/src/Group/components/GroupCTAButton.tsx +57 -0
- package/src/Group/components/GroupPlayerActionForm.tsx +137 -0
- package/src/Group/components/ManageGroupForm.tsx +239 -0
- package/src/Group/index.tsx +497 -0
- package/src/index.tsx +2 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Text, View } from "../Components/Themed"
|
|
3
|
+
import { GroupApi, GroupHelpers } from './api';
|
|
4
|
+
import type { CompetitionPayoutTypeProps, CompetitionPlayerProps, CompetitionProps, CompetitionRecordProps, CompetitionResultProps, CompetitionResultTypeProps, CompetitionTypeProps, GroupMessageProps, GroupPlayerProps, GroupProps, MyPlayerProps, OrderAnalyticsProps, OrderProps, PostProps, PublicPlayerProps } from '../types';
|
|
5
|
+
import { ActivityIndicator, FlatList, Image } from 'react-native';
|
|
6
|
+
import { Icons, Toggle } from '../Components';
|
|
7
|
+
import { useColors } from '../constants/useColors';
|
|
8
|
+
import moment from 'moment-mini';
|
|
9
|
+
import ManageGroupForm from './components/ManageGroupForm';
|
|
10
|
+
import GroupPlayerActionForm from './components/GroupPlayerActionForm';
|
|
11
|
+
import CompetitionCard from '../Engage/components/CompetitionCard';
|
|
12
|
+
import { PostCard } from '../SocialComponents';
|
|
13
|
+
import Pagination from '../Components/Pagination';
|
|
14
|
+
import GroupCTAButton from './components/GroupCTAButton';
|
|
15
|
+
|
|
16
|
+
type GroupComponentProps = {
|
|
17
|
+
group_id:string,
|
|
18
|
+
mode:'desktop'|'mobile',
|
|
19
|
+
onSelectChat?:(group:GroupProps) => void
|
|
20
|
+
onInvitePlayer:() => void,
|
|
21
|
+
onSelectPlayer:(p:PublicPlayerProps) => void,
|
|
22
|
+
onSelectCompetition:(c:CompetitionProps) => void,
|
|
23
|
+
player?:MyPlayerProps
|
|
24
|
+
}
|
|
25
|
+
type GroupStateProps = {
|
|
26
|
+
group?:GroupProps,
|
|
27
|
+
loading:boolean,
|
|
28
|
+
editing:boolean,
|
|
29
|
+
show_player_status:boolean,
|
|
30
|
+
active_toggle:string,
|
|
31
|
+
group_players:GroupPlayerProps[],
|
|
32
|
+
players:PublicPlayerProps[],
|
|
33
|
+
group_messages: GroupMessageProps[],
|
|
34
|
+
my_group_player?:GroupPlayerProps
|
|
35
|
+
}
|
|
36
|
+
type TimeOptionProps = {
|
|
37
|
+
to: number,
|
|
38
|
+
from:number,
|
|
39
|
+
option:string,
|
|
40
|
+
label:string
|
|
41
|
+
}
|
|
42
|
+
const sections = ['header','chat','me','toggle', 'competition_toggle', 'members', 'competitions', 'activity']
|
|
43
|
+
const GroupComponent = ({ group_id, player, mode, onInvitePlayer, onSelectCompetition, onSelectChat, onSelectPlayer } : GroupComponentProps) => {
|
|
44
|
+
const Colors = useColors();
|
|
45
|
+
const leader_options:TimeOptionProps[] = [
|
|
46
|
+
{ to: moment().subtract(1, 'days').unix(), from: moment().unix(), option: '24_hours', label: '24 Hours' },
|
|
47
|
+
{ to: moment().subtract(7, 'days').unix(), from: moment().unix(), option: '7_days', label: '7 Days' },
|
|
48
|
+
{ to: moment().subtract(30, 'days').unix(), from: moment().unix(), option: '30_days', label: '30 Days' },
|
|
49
|
+
{ to: moment().subtract(60, 'days').unix(), from: moment().unix(), option: '60_days', label: '60 Days' },
|
|
50
|
+
]
|
|
51
|
+
const [ activity_data, setActivityData ] = useState<{
|
|
52
|
+
loading:boolean,
|
|
53
|
+
orders:OrderProps[],
|
|
54
|
+
posts:PostProps[],
|
|
55
|
+
offset:number
|
|
56
|
+
}>({
|
|
57
|
+
loading: false,
|
|
58
|
+
posts:[],
|
|
59
|
+
orders:[],
|
|
60
|
+
offset:0
|
|
61
|
+
});
|
|
62
|
+
const [ comp_data, setCompData ] = useState<{
|
|
63
|
+
loading:boolean,
|
|
64
|
+
toggle: 'upcoming'|'history',
|
|
65
|
+
competition_types:CompetitionTypeProps[],
|
|
66
|
+
competition_result_types:CompetitionResultTypeProps[],
|
|
67
|
+
competition_payout_types:CompetitionPayoutTypeProps[],
|
|
68
|
+
active_competitions:CompetitionProps[],
|
|
69
|
+
competition_results:CompetitionResultProps[],
|
|
70
|
+
competition_records:CompetitionRecordProps[],
|
|
71
|
+
competition_players:CompetitionPlayerProps[],
|
|
72
|
+
offset:number
|
|
73
|
+
}>({
|
|
74
|
+
loading:false,
|
|
75
|
+
toggle: 'upcoming',
|
|
76
|
+
competition_payout_types:[],
|
|
77
|
+
competition_result_types:[],
|
|
78
|
+
competition_types:[],
|
|
79
|
+
active_competitions: [],
|
|
80
|
+
competition_players:[],
|
|
81
|
+
competition_records:[],
|
|
82
|
+
competition_results:[],
|
|
83
|
+
offset:0
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const [ group_analytics, setGroupAnalytics ] = useState<{
|
|
87
|
+
loading:boolean,
|
|
88
|
+
time_option?: TimeOptionProps,
|
|
89
|
+
order_analytics:OrderAnalyticsProps[]
|
|
90
|
+
}>({
|
|
91
|
+
loading:false,
|
|
92
|
+
time_option: leader_options[0],
|
|
93
|
+
order_analytics: []
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const { time_option, order_analytics } = group_analytics;
|
|
97
|
+
const [ group_data, setGroupData ] = useState<GroupStateProps>({
|
|
98
|
+
loading: false,
|
|
99
|
+
group_messages: [],
|
|
100
|
+
editing:false,
|
|
101
|
+
show_player_status:false,
|
|
102
|
+
active_toggle: 'members',
|
|
103
|
+
group_players: [],
|
|
104
|
+
players: []
|
|
105
|
+
});
|
|
106
|
+
const { loading, group, active_toggle, editing,show_player_status, group_messages, group_players, my_group_player, players } = group_data;
|
|
107
|
+
const { sorted_players, player_analytics } = GroupHelpers.sortMembers(group_players, order_analytics);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
getGroupData(group_id);
|
|
110
|
+
},[group_id]);
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
getToggleData(active_toggle);
|
|
115
|
+
},[active_toggle])
|
|
116
|
+
|
|
117
|
+
const getToggleData = async(toggle:string) => {
|
|
118
|
+
switch(toggle){
|
|
119
|
+
case 'members':
|
|
120
|
+
if(!time_option){ return }
|
|
121
|
+
return getGroupAnalytics(group_id, time_option);
|
|
122
|
+
case 'competitions':
|
|
123
|
+
return getCompetitionData(comp_data.toggle, 0);
|
|
124
|
+
case 'activity':
|
|
125
|
+
return getActitiyData(0);
|
|
126
|
+
default: return
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const getActitiyData = async(page:number) => {
|
|
131
|
+
setActivityData({ ...activity_data, loading: false });
|
|
132
|
+
const activity = await GroupApi.getPostsByGroupId(group_id, page);
|
|
133
|
+
let order_ids:string[] = []
|
|
134
|
+
activity.filter(a => a.memo_orders).map(mo => mo.memo_orders.map(o => order_ids.push(o)));
|
|
135
|
+
let activity_orders = await GroupApi.getBulkOrders(order_ids);
|
|
136
|
+
setActivityData({
|
|
137
|
+
...activity_data,
|
|
138
|
+
loading: false,
|
|
139
|
+
offset: page,
|
|
140
|
+
orders: activity_orders,
|
|
141
|
+
posts: activity.sort((a,b) => moment(a.create_datetime).unix() - moment(b.create_datetime).unix())
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const getCompetitionData = async(type:'upcoming' | 'history', page:number) => {
|
|
146
|
+
setCompData({ ...comp_data, loading:true });
|
|
147
|
+
let resp:undefined | { competitions:CompetitionProps[], competition_players:CompetitionPlayerProps[], competition_records:CompetitionRecordProps[], competition_results:CompetitionResultProps[] } = {
|
|
148
|
+
competitions:[], competition_players:[], competition_records:[], competition_results:[]
|
|
149
|
+
}
|
|
150
|
+
if(type == 'upcoming'){
|
|
151
|
+
resp = await GroupApi.getActiveCompetitions(group_id);
|
|
152
|
+
} else {
|
|
153
|
+
resp = await GroupApi.getHistoryCompetitions(group_id, page);
|
|
154
|
+
}
|
|
155
|
+
const opts = await GroupApi.getCompetitionOptions();
|
|
156
|
+
setCompData({
|
|
157
|
+
...comp_data,
|
|
158
|
+
loading:false,
|
|
159
|
+
toggle: type,
|
|
160
|
+
competition_players: resp.competition_players,
|
|
161
|
+
competition_records: resp.competition_records,
|
|
162
|
+
competition_results: resp.competition_results,
|
|
163
|
+
competition_payout_types: opts.competition_payout_types,
|
|
164
|
+
competition_result_types: opts.competition_result_types,
|
|
165
|
+
competition_types: opts.competition_types,
|
|
166
|
+
active_competitions: resp.competitions,
|
|
167
|
+
offset:page
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const getGroupAnalytics = async(id:string, time_option:TimeOptionProps) => {
|
|
172
|
+
setGroupAnalytics({ ...group_analytics, loading: true });
|
|
173
|
+
let analytics = await GroupApi.getGroupAnalytics(id, time_option.to, time_option.from);
|
|
174
|
+
setGroupAnalytics({
|
|
175
|
+
...group_analytics,
|
|
176
|
+
loading:false,
|
|
177
|
+
time_option: time_option,
|
|
178
|
+
order_analytics: analytics
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const getGroupData = async(id:string) => {
|
|
183
|
+
GroupApi.setEnvironment();
|
|
184
|
+
setGroupData({ ...group_data, loading: true });
|
|
185
|
+
const g_data = await GroupApi.getGroupById(id);
|
|
186
|
+
if(!g_data){
|
|
187
|
+
setGroupData({ ...group_data, loading: false });
|
|
188
|
+
return alert('Unable to get group information. Please try again later')
|
|
189
|
+
}
|
|
190
|
+
let player_ids = [ ...new Set(g_data.group_players.map(p => p.player_id).concat(g_data.group_messages.map(m => m.player_id)))]
|
|
191
|
+
let plyers = await GroupApi.getPlayersByIds(player_ids);
|
|
192
|
+
setGroupData({
|
|
193
|
+
...group_data,
|
|
194
|
+
loading: false,
|
|
195
|
+
players: plyers,
|
|
196
|
+
group: g_data.group,
|
|
197
|
+
show_player_status: !g_data.my_group_player ? true : g_data.my_group_player.status == 'active' ? false : true, //Show to join if we can
|
|
198
|
+
group_messages: g_data.group_messages,
|
|
199
|
+
group_players: g_data.group_players,
|
|
200
|
+
my_group_player: g_data.my_group_player
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const renderPlayers = (data:{ item:GroupPlayerProps, index:number }) => {
|
|
205
|
+
const player = players.find(p => p.player_id == data.item.player_id);
|
|
206
|
+
if(!player){ return <></> }
|
|
207
|
+
const player_analytic = player_analytics[data.item.player_id]
|
|
208
|
+
return (
|
|
209
|
+
<Button transparent style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light, borderRadius:0 }} onPress={() => onSelectPlayer(player)}>
|
|
210
|
+
<View float style={{ borderRadius:100, padding:2 }}>
|
|
211
|
+
<Image
|
|
212
|
+
source={{ uri: player.profile_pic }}
|
|
213
|
+
style={{ height:45, width:45, borderRadius:100 }}
|
|
214
|
+
resizeMode='contain'
|
|
215
|
+
/>
|
|
216
|
+
</View>
|
|
217
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
218
|
+
<Text theme='h1'>@{player.username}</Text>
|
|
219
|
+
<Text theme='description' style={{ marginTop:3 }}>Joined {moment(data.item.create_datetime).fromNow()}</Text>
|
|
220
|
+
</View>
|
|
221
|
+
{player_analytic ?
|
|
222
|
+
<Text theme='h2'>ROI {(player_analytic.roi_pct*100).toFixed(2)}%</Text>
|
|
223
|
+
:<></>}
|
|
224
|
+
</Button>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const renderCompetitions = (data:{ item:CompetitionProps, index:number }) => {
|
|
229
|
+
const type = comp_data.competition_types.find(t => t.competition_type_id == data.item.competition_type_id);
|
|
230
|
+
const result = comp_data.competition_result_types.find(r => r.competition_result_type_id == data.item.competition_result_type_id);
|
|
231
|
+
if(!type || !result){ return <></> }
|
|
232
|
+
const my_result = comp_data.competition_results.find(cr => cr.player_id == player?.player_id && cr.competition_id == data.item.competition_id)
|
|
233
|
+
const my_record = comp_data.competition_records.find(cr => cr.player_id == player?.player_id && cr.competition_id == data.item.competition_id)
|
|
234
|
+
return (
|
|
235
|
+
<CompetitionCard
|
|
236
|
+
competition={data.item}
|
|
237
|
+
player={player}
|
|
238
|
+
competition_type={type}
|
|
239
|
+
competition_record={my_record}
|
|
240
|
+
competition_result={my_result}
|
|
241
|
+
competition_result_type={result}
|
|
242
|
+
onCompetitionSelect={onSelectCompetition}
|
|
243
|
+
/>
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const renderPosts = (data:{ item:PostProps, index:number }) => {
|
|
248
|
+
let player = players.find(p => p.player_id == data.item.player_id);
|
|
249
|
+
let orders = activity_data.orders.filter(o => data.item.memo_orders.includes(o.order_id));
|
|
250
|
+
return (
|
|
251
|
+
<View style={{ padding:5 }}>
|
|
252
|
+
<PostCard
|
|
253
|
+
post={data.item}
|
|
254
|
+
player={player}
|
|
255
|
+
orders={orders}
|
|
256
|
+
onRequestAuthenticate={() => console.log('')}
|
|
257
|
+
onSelectArticle={() => console.log('')}
|
|
258
|
+
articles={[]}
|
|
259
|
+
width={300}
|
|
260
|
+
onSelectImage={() => console.log('')}
|
|
261
|
+
onSelectPlayer={onSelectPlayer}
|
|
262
|
+
onSelectTag={() => console.log('')}
|
|
263
|
+
/>
|
|
264
|
+
</View>
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const renderSections = (data:{ item:string, index:number }) => {
|
|
269
|
+
switch(data.item){
|
|
270
|
+
case 'header':
|
|
271
|
+
if(!group){ return <></> }
|
|
272
|
+
return (
|
|
273
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
274
|
+
<Image
|
|
275
|
+
source={{ uri: group.group_image?.url }}
|
|
276
|
+
style={{ height:50, width: 50 }}
|
|
277
|
+
resizeMode='cover'
|
|
278
|
+
/>
|
|
279
|
+
<View transparent style={{ flex:1, marginLeft:10, marginRight:10 }}>
|
|
280
|
+
<Text theme='h1'>{group.name}</Text>
|
|
281
|
+
<Text theme='description' style={{ marginTop:3 }}>{group.description}</Text>
|
|
282
|
+
</View>
|
|
283
|
+
{player?.player_id == group.group_admin ?
|
|
284
|
+
<Button float style={{ padding:10 }} onPress={() => setGroupData({ ...group_data, editing:true })}>
|
|
285
|
+
<Icons.EditIcon size={14} color={Colors.text.h1} />
|
|
286
|
+
</Button>
|
|
287
|
+
:<></>}
|
|
288
|
+
</View>
|
|
289
|
+
)
|
|
290
|
+
case 'chat':
|
|
291
|
+
if(!group || !onSelectChat){ return <></> }
|
|
292
|
+
return (
|
|
293
|
+
<View type='header' style={{ padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
294
|
+
<GroupCTAButton
|
|
295
|
+
group={group}
|
|
296
|
+
message_length={100}
|
|
297
|
+
players={players}
|
|
298
|
+
group_messages={group_messages}
|
|
299
|
+
group_players={group_players}
|
|
300
|
+
onSelectChat={onSelectChat}
|
|
301
|
+
/>
|
|
302
|
+
</View>
|
|
303
|
+
)
|
|
304
|
+
case 'me':
|
|
305
|
+
return (
|
|
306
|
+
<View type='row' style={{ padding:10 }}>
|
|
307
|
+
{player ?
|
|
308
|
+
<View style={{ flex:1 }} type='row' transparent>
|
|
309
|
+
<View float style={{ borderRadius:100, padding:2 }}>
|
|
310
|
+
<Image
|
|
311
|
+
style={{ height:30, width:30, borderRadius:100 }}
|
|
312
|
+
source={{ uri: player.profile_pic }}
|
|
313
|
+
resizeMode='contain'
|
|
314
|
+
/>
|
|
315
|
+
</View>
|
|
316
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
317
|
+
<Text theme='h1'>@{player.username}</Text>
|
|
318
|
+
<Text theme='description' style={{ marginTop:3 }}>Member since {moment(player.create_datetime).format('MM/DD/YYYY')}</Text>
|
|
319
|
+
</View>
|
|
320
|
+
{my_group_player?.status == 'invited' ?
|
|
321
|
+
<Button
|
|
322
|
+
type='action'
|
|
323
|
+
title='INVTED'
|
|
324
|
+
style={{ padding:10 }}
|
|
325
|
+
onPress={() => setGroupData({ ...group_data, show_player_status: true })}
|
|
326
|
+
/>
|
|
327
|
+
:<></>}
|
|
328
|
+
{!my_group_player || my_group_player.status == 'inactive' ?
|
|
329
|
+
<Button
|
|
330
|
+
type='success'
|
|
331
|
+
title='JOIN'
|
|
332
|
+
style={{ padding:10 }}
|
|
333
|
+
onPress={() => setGroupData({ ...group_data, show_player_status: true })}
|
|
334
|
+
/>
|
|
335
|
+
: my_group_player?.status != 'invited' ?
|
|
336
|
+
<Button
|
|
337
|
+
type='error'
|
|
338
|
+
title='LEAVE'
|
|
339
|
+
style={{ padding:10 }}
|
|
340
|
+
onPress={() => setGroupData({ ...group_data, show_player_status: true })}
|
|
341
|
+
/>
|
|
342
|
+
:<></>}
|
|
343
|
+
</View>
|
|
344
|
+
:<></>}
|
|
345
|
+
</View>
|
|
346
|
+
)
|
|
347
|
+
case 'toggle':
|
|
348
|
+
return (
|
|
349
|
+
<View style={{ padding:10 }}>
|
|
350
|
+
<Toggle
|
|
351
|
+
options={[
|
|
352
|
+
{ key: 'members', label: 'Members' },
|
|
353
|
+
{ key: 'activity', label: 'Activity' },
|
|
354
|
+
{ key: 'competitions', label: 'Competitions' }
|
|
355
|
+
]}
|
|
356
|
+
selected_option={active_toggle}
|
|
357
|
+
onSelectOption={(option) => setGroupData({ ...group_data, active_toggle: option })}
|
|
358
|
+
/>
|
|
359
|
+
{loading ?
|
|
360
|
+
<ActivityIndicator
|
|
361
|
+
size='large'
|
|
362
|
+
color={Colors.text.h1}
|
|
363
|
+
style={{ padding:20, alignSelf:'center' }}
|
|
364
|
+
/>
|
|
365
|
+
:<></>}
|
|
366
|
+
</View>
|
|
367
|
+
)
|
|
368
|
+
case 'activity':
|
|
369
|
+
if(active_toggle != 'activity'){ return <></> }
|
|
370
|
+
return (
|
|
371
|
+
<View style={{ padding:10 }}>
|
|
372
|
+
<Pagination
|
|
373
|
+
offset={activity_data.offset}
|
|
374
|
+
onNext={() => getActitiyData(activity_data.offset + 1)}
|
|
375
|
+
onPrevious={() => getActitiyData(activity_data.offset - 1)}
|
|
376
|
+
/>
|
|
377
|
+
<FlatList
|
|
378
|
+
data={activity_data.posts}
|
|
379
|
+
key={'post_list'}
|
|
380
|
+
keyExtractor={item => item.memo_post_id.toString()}
|
|
381
|
+
renderItem={renderPosts}
|
|
382
|
+
/>
|
|
383
|
+
</View>
|
|
384
|
+
)
|
|
385
|
+
case 'members':
|
|
386
|
+
if(active_toggle != 'members'){ return <></> }
|
|
387
|
+
return (
|
|
388
|
+
<View style={{ padding:10 }}>
|
|
389
|
+
<FlatList
|
|
390
|
+
data={sorted_players}
|
|
391
|
+
keyExtractor={item => item.group_player_id.toString()}
|
|
392
|
+
renderItem={renderPlayers}
|
|
393
|
+
key={'group_members'}
|
|
394
|
+
/>
|
|
395
|
+
</View>
|
|
396
|
+
)
|
|
397
|
+
case 'competition_toggle':
|
|
398
|
+
if(active_toggle != 'competitions'){ return <></> }
|
|
399
|
+
return (
|
|
400
|
+
<View style={{ padding:10 }}>
|
|
401
|
+
<Toggle
|
|
402
|
+
options={[
|
|
403
|
+
{ key: 'upcoming', label: 'Upcoming' },
|
|
404
|
+
{ key: 'history', label: 'History' }
|
|
405
|
+
]}
|
|
406
|
+
selected_option={comp_data.toggle}
|
|
407
|
+
onSelectOption={(option) => getCompetitionData(option as 'upcoming' | 'history', 0)}
|
|
408
|
+
/>
|
|
409
|
+
</View>
|
|
410
|
+
)
|
|
411
|
+
case 'competitions':
|
|
412
|
+
if(active_toggle != 'competitions'){ return <></> }
|
|
413
|
+
return (
|
|
414
|
+
<View transparent style={{ padding:10 }}>
|
|
415
|
+
<FlatList
|
|
416
|
+
key={'competition_list'}
|
|
417
|
+
keyExtractor={item => item.competition_id.toString()}
|
|
418
|
+
data={comp_data.active_competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
|
|
419
|
+
renderItem={renderCompetitions}
|
|
420
|
+
/>
|
|
421
|
+
</View>
|
|
422
|
+
)
|
|
423
|
+
default: return <></>
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return (
|
|
428
|
+
<View style={{ flex:1 }}>
|
|
429
|
+
<View style={{ flex:1 }}>
|
|
430
|
+
<FlatList
|
|
431
|
+
data={sections}
|
|
432
|
+
key={'group_list'}
|
|
433
|
+
keyExtractor={item => item}
|
|
434
|
+
renderItem={renderSections}
|
|
435
|
+
/>
|
|
436
|
+
{active_toggle == 'members' ?
|
|
437
|
+
<Toggle
|
|
438
|
+
options={leader_options.map(o => { return { key: o.option, label: o.label } })}
|
|
439
|
+
selected_option={time_option?.option}
|
|
440
|
+
onSelectOption={(option) => {
|
|
441
|
+
const selected = leader_options.find(o => o.option == option)
|
|
442
|
+
if(!selected){ return }
|
|
443
|
+
getGroupAnalytics(group_id, selected);
|
|
444
|
+
}}
|
|
445
|
+
/>
|
|
446
|
+
:active_toggle == 'competitions' ?
|
|
447
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
448
|
+
<View transparent style={{ flex:1, marginRight:10 }}>
|
|
449
|
+
<Text theme='h2'>CREATE A NEW COMPETITION</Text>
|
|
450
|
+
<Text theme='description' style={{ marginTop:3 }}>Create a new pick-em or other engagement for this group!</Text>
|
|
451
|
+
</View>
|
|
452
|
+
<Button
|
|
453
|
+
type='success'
|
|
454
|
+
style={{ padding:10 }}
|
|
455
|
+
title='CREATE'
|
|
456
|
+
onPress={() => console.log('New competition!')}
|
|
457
|
+
/>
|
|
458
|
+
</View>
|
|
459
|
+
:<></>}
|
|
460
|
+
</View>
|
|
461
|
+
{editing && group ?
|
|
462
|
+
<View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0 }}>
|
|
463
|
+
<View type='blur' style={mode == 'desktop'?{ justifyContent:'center', alignItems:'center', width: 500, height:500 }: { flex:1, justifyContent:'flex-end', padding:10 }}>
|
|
464
|
+
<ManageGroupForm
|
|
465
|
+
group={group}
|
|
466
|
+
onInvitePlayer={onInvitePlayer}
|
|
467
|
+
onClose={() => setGroupData({ ...group_data, editing: false })}
|
|
468
|
+
onUpdateGroup={(g) => setGroupData({ ...group_data, group: g })}
|
|
469
|
+
/>
|
|
470
|
+
</View>
|
|
471
|
+
</View>
|
|
472
|
+
:<></>}
|
|
473
|
+
{show_player_status && group && player ?
|
|
474
|
+
<View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0 }}>
|
|
475
|
+
<View type='blur' style={mode == 'desktop'?{ justifyContent:'center', alignItems:'center', width: 500, height:500 }: { flex:1, justifyContent:'flex-end', padding:10 }}>
|
|
476
|
+
<GroupPlayerActionForm
|
|
477
|
+
group={group}
|
|
478
|
+
group_player={my_group_player}
|
|
479
|
+
me={player}
|
|
480
|
+
onResponse={(new_gp) => {
|
|
481
|
+
setGroupData({
|
|
482
|
+
...group_data,
|
|
483
|
+
group_players: group_players.filter(gp => gp.group_player_id != new_gp.group_player_id).concat(new_gp),
|
|
484
|
+
my_group_player: new_gp,
|
|
485
|
+
show_player_status: false
|
|
486
|
+
})
|
|
487
|
+
}}
|
|
488
|
+
onClose={() => setGroupData({ ...group_data, show_player_status: false })}
|
|
489
|
+
/>
|
|
490
|
+
</View>
|
|
491
|
+
</View>
|
|
492
|
+
:<></>}
|
|
493
|
+
</View>
|
|
494
|
+
)
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export default GroupComponent
|
package/src/index.tsx
CHANGED
|
@@ -57,6 +57,7 @@ import ManageFilter from './BetMatch/components/ManageFilter';
|
|
|
57
57
|
import ClaritySmartEvents from './Clarity/SmartEvents';
|
|
58
58
|
import RankingsCard from './RankingsCard';
|
|
59
59
|
import GuideView from './Guide';
|
|
60
|
+
import GroupComponent from './Group';
|
|
60
61
|
|
|
61
62
|
export {
|
|
62
63
|
Authenticator,
|
|
@@ -70,6 +71,7 @@ export {
|
|
|
70
71
|
Ticker,
|
|
71
72
|
Premium,
|
|
72
73
|
LeaderboardCard,
|
|
74
|
+
GroupComponent,
|
|
73
75
|
LocationTracker,
|
|
74
76
|
BEClarity,
|
|
75
77
|
FlashMarket,
|