be-components 1.4.6 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/lib/commonjs/Engage/api/index.js +140 -0
  2. package/lib/commonjs/Engage/api/index.js.map +1 -0
  3. package/lib/commonjs/Engage/components/BracketCompetitionCard.js +221 -0
  4. package/lib/commonjs/Engage/components/BracketCompetitionCard.js.map +1 -0
  5. package/lib/commonjs/Engage/components/CompetitionCard.js +253 -0
  6. package/lib/commonjs/Engage/components/CompetitionCard.js.map +1 -0
  7. package/lib/commonjs/Engage/components/SquaresCompetitionCard.js +191 -0
  8. package/lib/commonjs/Engage/components/SquaresCompetitionCard.js.map +1 -0
  9. package/lib/commonjs/Engage/index.js +312 -0
  10. package/lib/commonjs/Engage/index.js.map +1 -0
  11. package/lib/commonjs/index.js +7 -0
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/module/Engage/api/index.js +134 -0
  14. package/lib/module/Engage/api/index.js.map +1 -0
  15. package/lib/module/Engage/components/BracketCompetitionCard.js +214 -0
  16. package/lib/module/Engage/components/BracketCompetitionCard.js.map +1 -0
  17. package/lib/module/Engage/components/CompetitionCard.js +246 -0
  18. package/lib/module/Engage/components/CompetitionCard.js.map +1 -0
  19. package/lib/module/Engage/components/SquaresCompetitionCard.js +184 -0
  20. package/lib/module/Engage/components/SquaresCompetitionCard.js.map +1 -0
  21. package/lib/module/Engage/index.js +303 -0
  22. package/lib/module/Engage/index.js.map +1 -0
  23. package/lib/module/index.js +2 -1
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/typescript/src/Engage/api/index.d.ts +25 -0
  26. package/lib/typescript/src/Engage/api/index.d.ts.map +1 -0
  27. package/lib/typescript/src/Engage/components/BracketCompetitionCard.d.ts +15 -0
  28. package/lib/typescript/src/Engage/components/BracketCompetitionCard.d.ts.map +1 -0
  29. package/lib/typescript/src/Engage/components/CompetitionCard.d.ts +14 -0
  30. package/lib/typescript/src/Engage/components/CompetitionCard.d.ts.map +1 -0
  31. package/lib/typescript/src/Engage/components/SquaresCompetitionCard.d.ts +12 -0
  32. package/lib/typescript/src/Engage/components/SquaresCompetitionCard.d.ts.map +1 -0
  33. package/lib/typescript/src/Engage/index.d.ts +11 -0
  34. package/lib/typescript/src/Engage/index.d.ts.map +1 -0
  35. package/lib/typescript/src/index.d.ts +2 -1
  36. package/lib/typescript/src/index.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/Engage/api/index.ts +124 -0
  39. package/src/Engage/components/BracketCompetitionCard.tsx +117 -0
  40. package/src/Engage/components/CompetitionCard.tsx +126 -0
  41. package/src/Engage/components/SquaresCompetitionCard.tsx +92 -0
  42. package/src/Engage/index.tsx +265 -0
  43. package/src/index.tsx +5 -1
@@ -0,0 +1,265 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { View, ActivityIndicator, FlatList } from 'react-native';
3
+ import type { BracketCompetitionProps, BracketProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, EventProps, LeagueProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
4
+ import Colors from '../constants/colors';
5
+ import { EngageApi, EngageHelpers } from './api';
6
+ import CompetitionCard from './components/CompetitionCard';
7
+ import { view_styles } from '../constants/styles';
8
+ import { Button, Text } from '../Components';
9
+ import SquaresCompetitionCard from './components/SquaresCompetitionCard';
10
+ import BracketCompetitionCard from './components/BracketCompetitionCard';
11
+ import moment from 'moment-mini';
12
+
13
+
14
+ type EngageModuleProps = {
15
+ player_id?:string,
16
+ onSelectCompetition:(c:CompetitionProps) => void,
17
+ onSelectBracketCompetition:(bc:BracketCompetitionProps) => void,
18
+ onSelectSquaresCompetition:(sc:SquaresCompetitionProps) => void
19
+ }
20
+
21
+ const EngageModule = ({ onSelectBracketCompetition, onSelectCompetition, onSelectSquaresCompetition }:EngageModuleProps) => {
22
+ const [ active_tab, setActiveTab ] = useState('competitions');
23
+ const [ module_data, setModuleData ] = useState<{
24
+ loading:boolean,
25
+ competitions:CompetitionProps[],
26
+ competition_types:CompetitionTypeProps[],
27
+ competition_result_types:CompetitionResultTypeProps[],
28
+ competition_payouts:CompetitionPayoutTypeProps[],
29
+ events:EventProps[],
30
+ leagues:LeagueProps[],
31
+ brackets:BracketProps[],
32
+ squares_competitions:SquaresCompetitionProps[],
33
+ bracket_competitions:BracketCompetitionProps[],
34
+ companies:CompanyProps[],
35
+ players:PublicPlayerProps[],
36
+ }>({
37
+ loading:false,
38
+ competitions: [],
39
+ companies:[],
40
+ leagues:[],
41
+ events:[],
42
+ brackets:[],
43
+ competition_types: [],
44
+ competition_result_types: [],
45
+ competition_payouts: [],
46
+ squares_competitions: [],
47
+ bracket_competitions:[],
48
+ players:[]
49
+ });
50
+ const { loading, competitions, competition_result_types, squares_competitions, brackets, leagues, bracket_competitions, events, competition_types, companies, players } = module_data;
51
+
52
+ useEffect(() => {
53
+ EngageApi.setEnvironment();
54
+ getDataFromServer()
55
+ },[])
56
+
57
+ const getDataFromServer = async() => {
58
+ setModuleData({
59
+ ...module_data,
60
+ loading:true,
61
+
62
+ })
63
+ const lgs = await EngageApi.getLeagues();
64
+ const comps = await EngageApi.getActivePublicCompetitions();
65
+ const brackets = await EngageApi.getActivePublicBrackets();
66
+ const squares = await EngageApi.getActivePublicSquares();
67
+ const company_ids = EngageHelpers.getCompanyIdsFromEngage(comps, squares, brackets);
68
+ const cpanys = await EngageApi.getCompaniesByIds(company_ids);
69
+ const player_ids = EngageHelpers.getPlayerIdsFromEngage(comps, squares, brackets);
70
+ const plyers = await EngageApi.getPlayersByPlayerIds(player_ids)
71
+ const opts = await EngageApi.getCompetitionOptions();
72
+ const event_ids = EngageHelpers.getEventIdsFromSquares(squares);
73
+ const evts = await EngageApi.getEventsByEventIds(event_ids);
74
+ const bracket_ids = EngageHelpers.getBracketIdsFromBracketComps(brackets);
75
+ const bcks = await EngageApi.getBracketsByIds(bracket_ids)
76
+
77
+ setModuleData({
78
+ ...module_data,
79
+ loading:false,
80
+ competitions:comps,
81
+ bracket_competitions:brackets,
82
+ competition_types: opts.competition_types,
83
+ competition_result_types: opts.competition_result_types,
84
+ competition_payouts: opts.competition_payout_types,
85
+ squares_competitions: squares,
86
+ companies: cpanys,
87
+ events: evts,
88
+ brackets: bcks,
89
+ leagues: lgs,
90
+ players: plyers
91
+ })
92
+ }
93
+
94
+ const renderSquaresCompetitions = (data: { item:SquaresCompetitionProps, index:number }) => {
95
+ const admin = players.find(p => p.player_id == data.item.admin_id);
96
+ const company = companies.find(c => c.company_id == data.item.company_id);
97
+ const event = events.find(e => e.event_id == data.item.event_id)
98
+ return (
99
+ <View>
100
+ <SquaresCompetitionCard
101
+ squares_competition={data.item}
102
+ company={company}
103
+ admin={admin}
104
+ event={event}
105
+ onSelectCompetition={(sc) => onSelectSquaresCompetition(sc)}
106
+ />
107
+ </View>
108
+ )
109
+ }
110
+
111
+
112
+ const renderBracketCompetitions = (data: { item:BracketCompetitionProps, index:number }) => {
113
+ const admin = players.find(p => p.player_id == data.item.admin_id);
114
+ const company = companies.find(c => c.company_id == data.item.company_id);
115
+ const competition_result_type = competition_result_types.find(t => t.competition_result_type_id == data.item.competition_result_type_id);
116
+ const bracket = brackets.find(b => b.bracket_id == data.item.bracket_id);
117
+ const league = leagues.find(e => e.league_id == bracket?.league_id)
118
+ if(!competition_result_type){ return <></> }
119
+ return (
120
+ <View>
121
+ <BracketCompetitionCard
122
+ bracket_competition={data.item}
123
+ company={company}
124
+ competition_result_type={competition_result_type}
125
+ admin={admin}
126
+ bracket={bracket}
127
+ league={league}
128
+ onCompetitionSelect={(sc) => onSelectBracketCompetition(sc)}
129
+ />
130
+ </View>
131
+ )
132
+ }
133
+
134
+
135
+ const renderCompetitions = (data: { item:CompetitionProps, index:number }) => {
136
+ const admin = players.find(p => p.player_id == data.item.admin_id);
137
+ const pacer = players.find(p => p.player_id == data.item.pacer_id);
138
+ const company = companies.find(c => c.company_id == data.item.company_id)
139
+ const competition_type = competition_types.find(t => t.competition_type_id == data.item.competition_type_id);
140
+ const competition_result_type = competition_result_types.find(t => t.competition_result_type_id == data.item.competition_result_type_id);
141
+ if(!competition_type || !competition_result_type){ return <></> }
142
+ return (
143
+ <View>
144
+ <CompetitionCard
145
+ competition={data.item}
146
+ company={company}
147
+ competition_type={competition_type}
148
+ competition_result_type={competition_result_type}
149
+ admin={admin}
150
+ pacer={pacer}
151
+ onCompetitionSelect={(c) => onSelectCompetition(c)}
152
+ />
153
+ </View>
154
+ )
155
+ }
156
+
157
+ if(loading){
158
+ return (
159
+ <View style={{flex:1, backgroundColor:Colors.shades.white}}>
160
+ <ActivityIndicator style={{ padding:20, alignSelf:'center' }} size='large' color={Colors.brand.midnight} />
161
+ </View>
162
+ )
163
+ }
164
+
165
+ return (
166
+ <View style={{ flex:1, backgroundColor:Colors.shades.white }}>
167
+ <View style={{ ...view_styles.body_row, margin:10, backgroundColor:Colors.shades.white, borderRadius:22, borderWidth:4, borderColor:Colors.shades.shade100}}>
168
+ <Button
169
+ title='COMPETITIONS'
170
+ title_color={active_tab == 'competitions' ? Colors.shades.white : Colors.brand.midnight}
171
+ title_weight={active_tab == 'competitions' ? 'bold' : 'regular'}
172
+ padding={15}
173
+ title_size={12}
174
+ style={{flex:1}}
175
+ borderRadiusOverride={{
176
+ borderTopLeftRadius: 22,
177
+ borderBottomLeftRadius:22,
178
+ borderTopRightRadius:0,
179
+ borderBottomRightRadius:0
180
+ }}
181
+ backgroundColor={active_tab == 'competitions' ? Colors.brand.midnight : Colors.shades.white}
182
+ onPress={() => setActiveTab('competitions')}
183
+ />
184
+ <Button
185
+ title='SQUARES'
186
+ title_size={12}
187
+ title_color={active_tab == 'squares' ? Colors.shades.white : Colors.brand.midnight}
188
+ title_weight={active_tab == 'squares' ? 'bold' : 'regular'}
189
+ padding={15}
190
+ style={{flex:1}}
191
+ borderRadius={0}
192
+ backgroundColor={active_tab == 'squares' ? Colors.brand.midnight : Colors.shades.white}
193
+ onPress={() => setActiveTab('squares')}
194
+ />
195
+ <Button
196
+ title='BRACKETS'
197
+ style={{flex:1}}
198
+ title_size={12}
199
+ title_color={active_tab == 'brackets' ? Colors.shades.white : Colors.brand.midnight}
200
+ title_weight={active_tab == 'brackets' ? 'bold' : 'regular'}
201
+ padding={15}
202
+ borderRadiusOverride={{
203
+ borderTopLeftRadius: 0,
204
+ borderBottomLeftRadius:0,
205
+ borderTopRightRadius:22,
206
+ borderBottomRightRadius:22
207
+ }}
208
+ backgroundColor={active_tab == 'brackets' ? Colors.brand.midnight : Colors.shades.white}
209
+ onPress={() => setActiveTab('brackets')}
210
+ />
211
+ </View>
212
+ {active_tab == 'competitions' ?
213
+ <View style={{ ...view_styles.section_body, padding:0 }}>
214
+ <View style={{ marginBottom:15, marginTop:10 }}>
215
+ <View style={{ ...view_styles.section_header, backgroundColor:Colors.shades.shade100, borderRadius:0 }}>
216
+ <View style={{ flex:1 }}>
217
+ <Text theme='header'>Public Competitions</Text>
218
+ <Text style={{ marginTop:3 }} theme='body'>Below are available pick-em and wager based competitions. All competitions are offered with 0 fees. All ticket sales are paid out to the winners!</Text>
219
+ </View>
220
+ </View>
221
+ </View>
222
+ <FlatList
223
+ data={competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
224
+ renderItem={renderCompetitions}
225
+ keyExtractor={(item) => item.competition_id.toString()}
226
+ />
227
+ </View>
228
+ :active_tab == 'squares' ?
229
+ <View style={{ ...view_styles.section_body, padding:0 }}>
230
+ <View style={{ marginBottom:15, marginTop:10 }}>
231
+ <View style={{ ...view_styles.section_header, backgroundColor:Colors.shades.shade100, borderRadius:0 }}>
232
+ <View style={{ flex:1 }}>
233
+ <Text theme='header'>Public Auction Squares</Text>
234
+ <Text style={{ marginTop:3 }} theme='body'>Below are available squares competitions. Bid on squares until the auction period ends. Win $ and prizes when your square hits at the end of each quarter!</Text>
235
+ </View>
236
+ </View>
237
+ </View>
238
+ <FlatList
239
+ data={squares_competitions.sort((a,b) => moment(a.begin_datetime).unix() - moment(b.begin_datetime).unix())}
240
+ renderItem={renderSquaresCompetitions}
241
+ keyExtractor={(item) => item.sq_comp_id.toString()}
242
+ />
243
+ </View>
244
+ :active_tab == 'brackets' ?
245
+ <View style={{ ...view_styles.section_body, padding:0 }}>
246
+ <View style={{ marginBottom:15, marginTop:10 }}>
247
+ <View style={{ ...view_styles.section_header, backgroundColor:Colors.shades.shade100, borderRadius:0 }}>
248
+ <View style={{ flex:1 }}>
249
+ <Text theme='header'>Public Bracket Competitions</Text>
250
+ <Text style={{ marginTop:3 }} theme='body'>Below are available bracket competitions. All competitions are offered with 0 fees. All ticket sales are paid out to the winners!</Text>
251
+ </View>
252
+ </View>
253
+ </View>
254
+ <FlatList
255
+ data={bracket_competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
256
+ renderItem={renderBracketCompetitions}
257
+ keyExtractor={(item) => item.bracket_competition_id.toString()}
258
+ />
259
+ </View>
260
+ :<></>}
261
+ </View>
262
+ )
263
+ }
264
+
265
+ export default EngageModule
package/src/index.tsx CHANGED
@@ -21,6 +21,9 @@ import PromotedOrder from "./PromotedOrder";
21
21
  import CompetitionManager from "./CompetitionManager";
22
22
  import CreateCompetitionForm from "./CompetitionManager/components/CreateCompetitionForm";
23
23
  import AdminCompetitionList from "./CompetitionManager/components/AdminCompetitionList";
24
+ import EngageModule from "./Engage";
25
+
26
+
24
27
  export {
25
28
  Authenticator,
26
29
  Observer,
@@ -48,5 +51,6 @@ export {
48
51
  BracketRoom,
49
52
  SquaresModule,
50
53
  SocketManager,
51
- PromotedOrder
54
+ PromotedOrder,
55
+ EngageModule
52
56
  }