be-components 6.6.0 → 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/Wallet/index.js +8 -1
- package/lib/commonjs/Wallet/index.js.map +1 -1
- 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/Wallet/index.js +8 -1
- package/lib/module/Wallet/index.js.map +1 -1
- 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/Wallet/index.d.ts.map +1 -1
- 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/Wallet/index.d.ts.map +1 -1
- 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/Wallet/index.d.ts.map +1 -1
- 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/Wallet/index.tsx +6 -1
- package/src/index.tsx +2 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Text, TextInput, View } from "../../Components/Themed";
|
|
3
|
+
import { FlatList } from 'react-native';
|
|
4
|
+
import type { FocusPositionProps, GroupProps } from '../../types';
|
|
5
|
+
import { Switch, Toggle } from '../../Components';
|
|
6
|
+
import { GroupApi } from '../api';
|
|
7
|
+
|
|
8
|
+
const sections = ['header','toggle','information', 'settings', 'invite', 'options']
|
|
9
|
+
type ManageGroupFormProps = {
|
|
10
|
+
group:GroupProps,
|
|
11
|
+
onUpdateGroup:(group:GroupProps) => void,
|
|
12
|
+
onInvitePlayer: () => void,
|
|
13
|
+
onClose:() => void,
|
|
14
|
+
onFocusPosition?:(position:FocusPositionProps) => void,
|
|
15
|
+
}
|
|
16
|
+
const ManageGroupForm = ({ group, onFocusPosition, onUpdateGroup, onClose, onInvitePlayer }: ManageGroupFormProps ) => {
|
|
17
|
+
const [ manage_state, setState ] = useState<{
|
|
18
|
+
loading:boolean,
|
|
19
|
+
draft_group:GroupProps,
|
|
20
|
+
active_toggle:string
|
|
21
|
+
}>({
|
|
22
|
+
draft_group: group,
|
|
23
|
+
loading:false,
|
|
24
|
+
active_toggle: 'information'
|
|
25
|
+
});
|
|
26
|
+
const { loading, draft_group, active_toggle } = manage_state;
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if(!group){ return }
|
|
30
|
+
setState({ ...manage_state,draft_group: group })
|
|
31
|
+
},[group]);
|
|
32
|
+
|
|
33
|
+
const handleSave = async(dg:GroupProps) => {
|
|
34
|
+
if(!dg){ return }
|
|
35
|
+
if(loading){ return }
|
|
36
|
+
console.log(dg)
|
|
37
|
+
setState({ ...manage_state, loading: true });
|
|
38
|
+
const new_group = await GroupApi.updateGroup(dg);
|
|
39
|
+
if(!new_group){
|
|
40
|
+
setState({ ...manage_state, loading:false })
|
|
41
|
+
return alert('Unable to update this group')
|
|
42
|
+
}
|
|
43
|
+
onUpdateGroup(new_group);
|
|
44
|
+
setState({ ...manage_state, loading:false })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const renderSections = (data:{ item:string, index:number }) => {
|
|
48
|
+
switch(data.item){
|
|
49
|
+
case 'header':
|
|
50
|
+
return (
|
|
51
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
52
|
+
<View transparent style={{ flex:1 }}>
|
|
53
|
+
<Text theme='h1'>EDIT YOUR GROUP</Text>
|
|
54
|
+
<Text theme='description' style={{ marginTop:3 }}>Use the form below to make updates to this group</Text>
|
|
55
|
+
</View>
|
|
56
|
+
<Button
|
|
57
|
+
title='X'
|
|
58
|
+
float
|
|
59
|
+
style={{ padding:10 }}
|
|
60
|
+
onPress={() => onClose()}
|
|
61
|
+
/>
|
|
62
|
+
</View>
|
|
63
|
+
)
|
|
64
|
+
case 'information':
|
|
65
|
+
if(!draft_group){ return <></> }
|
|
66
|
+
if(active_toggle != 'information'){ return <></> }
|
|
67
|
+
const is_changed = JSON.stringify({ name: draft_group.name, description: draft_group.description }) != JSON.stringify({ name: group.name, description:group.description }) ? true : false
|
|
68
|
+
return (
|
|
69
|
+
<View float style={{ margin:10 }}>
|
|
70
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
71
|
+
<View transparent style={{ flex:1 }}>
|
|
72
|
+
<Text theme='h1'>Edit Group Information</Text>
|
|
73
|
+
</View>
|
|
74
|
+
<Button
|
|
75
|
+
title='UPDATE'
|
|
76
|
+
type='success'
|
|
77
|
+
disabled={!is_changed}
|
|
78
|
+
loading={loading}
|
|
79
|
+
style={{ opacity: is_changed && !loading ? 1 : 0.5, padding:10 }}
|
|
80
|
+
onPress={() => handleSave(draft_group)}
|
|
81
|
+
/>
|
|
82
|
+
</View>
|
|
83
|
+
<View transparent nativeID='title' type='row' style={{ flexWrap:"wrap", padding:10 }}>
|
|
84
|
+
<View transparent style={{ flexGrow:1, minWidth:150 }}>
|
|
85
|
+
<Text theme='h1'>Group Name</Text>
|
|
86
|
+
<Text theme='description' style={{ marginTop:3 }}>Give this group a unique name</Text>
|
|
87
|
+
</View>
|
|
88
|
+
<TextInput
|
|
89
|
+
value={draft_group.name}
|
|
90
|
+
style={{ minWidth:150, flexGrow:1, margin:5 }}
|
|
91
|
+
onFocusPosition={onFocusPosition}
|
|
92
|
+
onChangeText={(text) => setState({ ...manage_state, draft_group: { ...draft_group, name: text } })}
|
|
93
|
+
/>
|
|
94
|
+
</View>
|
|
95
|
+
<View transparent nativeID='description' type='row' style={{ flexWrap:"wrap", padding:10 }}>
|
|
96
|
+
<View transparent style={{ flexGrow:1, minWidth:150 }}>
|
|
97
|
+
<Text theme='h1'>Group Description</Text>
|
|
98
|
+
<Text theme='description' style={{ marginTop:3 }}>Give this group a fun description</Text>
|
|
99
|
+
</View>
|
|
100
|
+
<TextInput
|
|
101
|
+
value={draft_group.description}
|
|
102
|
+
style={{ minWidth:300, flexGrow:1, margin:5 }}
|
|
103
|
+
onFocusPosition={onFocusPosition}
|
|
104
|
+
onChangeText={(text) => setState({ ...manage_state, draft_group: { ...draft_group, description: text } })}
|
|
105
|
+
/>
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
108
|
+
)
|
|
109
|
+
case 'invite':
|
|
110
|
+
if(!draft_group){ return <></> }
|
|
111
|
+
if(active_toggle != 'information'){ return <></> }
|
|
112
|
+
const code_changed = draft_group.invite_code != group.invite_code ? true : false
|
|
113
|
+
return (
|
|
114
|
+
<View float style={{ margin:10 }}>
|
|
115
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
116
|
+
<View transparent style={{ flex:1 }}>
|
|
117
|
+
<Text theme='h1'>Group Players</Text>
|
|
118
|
+
</View>
|
|
119
|
+
<Button
|
|
120
|
+
title='INVITE'
|
|
121
|
+
type='success'
|
|
122
|
+
loading={loading}
|
|
123
|
+
style={{ padding:10 }}
|
|
124
|
+
onPress={() => onInvitePlayer()}
|
|
125
|
+
/>
|
|
126
|
+
</View>
|
|
127
|
+
<View transparent type='body'>
|
|
128
|
+
<View transparent type='row' style={{ padding:10 }}>
|
|
129
|
+
<View transparent style={{flex:1 }}>
|
|
130
|
+
<Text theme='h1'>INVITE ONLY</Text>
|
|
131
|
+
<Text theme='description' style={{ marginTop:3 }}>Make this group invite only so players can only join if invited by you</Text>
|
|
132
|
+
</View>
|
|
133
|
+
<Switch
|
|
134
|
+
value={draft_group.invite_only}
|
|
135
|
+
onChange={(value) => handleSave({ ...draft_group, invite_only: value, invite_code: value ? `IC${group.group_id}`: '' }) }
|
|
136
|
+
switch_type='on_off'
|
|
137
|
+
/>
|
|
138
|
+
</View>
|
|
139
|
+
{draft_group.invite_only ?
|
|
140
|
+
<View transparent nativeID='title' type='row' style={{ flexWrap:"wrap" }}>
|
|
141
|
+
<View transparent style={{ flexGrow:1, minWidth:150, padding:10 }}>
|
|
142
|
+
<Text theme='h1'>INVITE CODE</Text>
|
|
143
|
+
<Text theme='description' style={{ marginTop:3 }}>You can set a custom code for users to find your group</Text>
|
|
144
|
+
</View>
|
|
145
|
+
<View transparent style={{ flexDirection:'row', alignItems:'center', minWidth:200, flexGrow:1, padding:10 }}>
|
|
146
|
+
<TextInput
|
|
147
|
+
value={draft_group.invite_code}
|
|
148
|
+
style={{ flexGrow:1, marginRight:5 }}
|
|
149
|
+
onFocusPosition={onFocusPosition}
|
|
150
|
+
onChangeText={(text) => setState({ ...manage_state, draft_group: { ...draft_group, invite_code: text } })}
|
|
151
|
+
/>
|
|
152
|
+
<Button
|
|
153
|
+
title='SAVE'
|
|
154
|
+
type='success'
|
|
155
|
+
disabled={!code_changed}
|
|
156
|
+
loading={loading}
|
|
157
|
+
style={{ opacity: code_changed && !loading ? 1 : 0.5, padding:10 }}
|
|
158
|
+
onPress={() => handleSave(draft_group)}
|
|
159
|
+
/>
|
|
160
|
+
</View>
|
|
161
|
+
</View>
|
|
162
|
+
:<></>}
|
|
163
|
+
</View>
|
|
164
|
+
</View>
|
|
165
|
+
)
|
|
166
|
+
case 'toggle':
|
|
167
|
+
return (
|
|
168
|
+
<View style={{ padding:10 }}>
|
|
169
|
+
<Toggle
|
|
170
|
+
options={[
|
|
171
|
+
{key: 'information', label: 'Information'},
|
|
172
|
+
{ key: 'settings', label: 'settings'}
|
|
173
|
+
]}
|
|
174
|
+
onSelectOption={(option) => setState({ ...manage_state, active_toggle: option })}
|
|
175
|
+
selected_option={active_toggle}
|
|
176
|
+
/>
|
|
177
|
+
</View>
|
|
178
|
+
)
|
|
179
|
+
case 'settings':
|
|
180
|
+
if(active_toggle != 'settings'){ return <></> }
|
|
181
|
+
return (
|
|
182
|
+
<View float style={{ margin:10 }}>
|
|
183
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
184
|
+
<View transparent style={{ flex:1 }}>
|
|
185
|
+
<Text theme='h1'>Edit Group Settings</Text>
|
|
186
|
+
</View>
|
|
187
|
+
</View>
|
|
188
|
+
<View transparent nativeID='title' type='row' style={{ padding:10 }}>
|
|
189
|
+
<View transparent style={{ flexGrow:1, minWidth:150 }}>
|
|
190
|
+
<Text theme='h1'>Show Leaderboard</Text>
|
|
191
|
+
<Text theme='description' style={{ marginTop:3 }}>Include a leaderboard for all players in this group</Text>
|
|
192
|
+
</View>
|
|
193
|
+
<Switch
|
|
194
|
+
value={draft_group.leaderboard_ind}
|
|
195
|
+
onChange={(value) => handleSave({ ...draft_group, leaderboard_ind: value }) }
|
|
196
|
+
switch_type='on_off'
|
|
197
|
+
/>
|
|
198
|
+
</View>
|
|
199
|
+
<View transparent nativeID='title' type='row' style={{ padding:10 }}>
|
|
200
|
+
<View transparent style={{ flexGrow:1, minWidth:150 }}>
|
|
201
|
+
<Text theme='h1'>Order Alerts</Text>
|
|
202
|
+
<Text theme='description' style={{ marginTop:3 }}>Log each order a player in this group makes.</Text>
|
|
203
|
+
</View>
|
|
204
|
+
<Switch
|
|
205
|
+
value={draft_group.order_alerts}
|
|
206
|
+
onChange={(value) => handleSave({ ...draft_group, order_alerts: value }) }
|
|
207
|
+
switch_type='on_off'
|
|
208
|
+
/>
|
|
209
|
+
</View>
|
|
210
|
+
<View transparent nativeID='title' type='row' style={{ padding:10 }}>
|
|
211
|
+
<View transparent style={{ flexGrow:1, minWidth:150 }}>
|
|
212
|
+
<Text theme='h1'>Competition Alerts</Text>
|
|
213
|
+
<Text theme='description' style={{ marginTop:3 }}>Log each competition a player in this group joins.</Text>
|
|
214
|
+
</View>
|
|
215
|
+
<Switch
|
|
216
|
+
value={draft_group.competition_alerts}
|
|
217
|
+
onChange={(value) => handleSave({ ...draft_group, competition_alerts: value }) }
|
|
218
|
+
switch_type='on_off'
|
|
219
|
+
/>
|
|
220
|
+
</View>
|
|
221
|
+
</View>
|
|
222
|
+
)
|
|
223
|
+
default: return <></>
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<View float style={{ flex:1 }}>
|
|
229
|
+
<FlatList
|
|
230
|
+
data={sections}
|
|
231
|
+
key={'group_sections_manage'}
|
|
232
|
+
keyExtractor={item => item}
|
|
233
|
+
renderItem={renderSections}
|
|
234
|
+
/>
|
|
235
|
+
</View>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export default ManageGroupForm
|