be-components 6.8.2 → 6.8.4

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 (72) hide show
  1. package/lib/commonjs/Competition/index.js +91 -55
  2. package/lib/commonjs/Competition/index.js.map +1 -1
  3. package/lib/commonjs/Components/ImageUploader.js +3 -1
  4. package/lib/commonjs/Components/ImageUploader.js.map +1 -1
  5. package/lib/commonjs/CreateEngagement/index.js +4 -3
  6. package/lib/commonjs/CreateEngagement/index.js.map +1 -1
  7. package/lib/commonjs/Squares/index.js +12 -1
  8. package/lib/commonjs/Squares/index.js.map +1 -1
  9. package/lib/commonjs/SquaresManager/api/index.js +129 -0
  10. package/lib/commonjs/SquaresManager/api/index.js.map +1 -0
  11. package/lib/commonjs/SquaresManager/index.js +629 -0
  12. package/lib/commonjs/SquaresManager/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/Competition/index.js +91 -55
  16. package/lib/module/Competition/index.js.map +1 -1
  17. package/lib/module/Components/ImageUploader.js +3 -1
  18. package/lib/module/Components/ImageUploader.js.map +1 -1
  19. package/lib/module/CreateEngagement/index.js +4 -3
  20. package/lib/module/CreateEngagement/index.js.map +1 -1
  21. package/lib/module/Squares/index.js +12 -1
  22. package/lib/module/Squares/index.js.map +1 -1
  23. package/lib/module/SquaresManager/api/index.js +123 -0
  24. package/lib/module/SquaresManager/api/index.js.map +1 -0
  25. package/lib/module/SquaresManager/index.js +621 -0
  26. package/lib/module/SquaresManager/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/Competition/index.d.ts.map +1 -1
  30. package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts +2 -1
  31. package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts.map +1 -1
  32. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
  33. package/lib/typescript/lib/commonjs/Squares/index.d.ts +2 -1
  34. package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
  35. package/lib/typescript/lib/commonjs/SquaresManager/api/index.d.ts +19 -0
  36. package/lib/typescript/lib/commonjs/SquaresManager/api/index.d.ts.map +1 -0
  37. package/lib/typescript/lib/commonjs/SquaresManager/index.d.ts +13 -0
  38. package/lib/typescript/lib/commonjs/SquaresManager/index.d.ts.map +1 -0
  39. package/lib/typescript/lib/commonjs/index.d.ts +1 -0
  40. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  41. package/lib/typescript/lib/module/Competition/index.d.ts.map +1 -1
  42. package/lib/typescript/lib/module/Components/ImageUploader.d.ts +2 -1
  43. package/lib/typescript/lib/module/Components/ImageUploader.d.ts.map +1 -1
  44. package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
  45. package/lib/typescript/lib/module/Squares/index.d.ts +2 -1
  46. package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
  47. package/lib/typescript/lib/module/SquaresManager/api/index.d.ts +18 -0
  48. package/lib/typescript/lib/module/SquaresManager/api/index.d.ts.map +1 -0
  49. package/lib/typescript/lib/module/SquaresManager/index.d.ts +13 -0
  50. package/lib/typescript/lib/module/SquaresManager/index.d.ts.map +1 -0
  51. package/lib/typescript/lib/module/index.d.ts +2 -1
  52. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  53. package/lib/typescript/src/Competition/index.d.ts.map +1 -1
  54. package/lib/typescript/src/Components/ImageUploader.d.ts +3 -1
  55. package/lib/typescript/src/Components/ImageUploader.d.ts.map +1 -1
  56. package/lib/typescript/src/Squares/index.d.ts +2 -1
  57. package/lib/typescript/src/Squares/index.d.ts.map +1 -1
  58. package/lib/typescript/src/SquaresManager/api/index.d.ts +36 -0
  59. package/lib/typescript/src/SquaresManager/api/index.d.ts.map +1 -0
  60. package/lib/typescript/src/SquaresManager/index.d.ts +16 -0
  61. package/lib/typescript/src/SquaresManager/index.d.ts.map +1 -0
  62. package/lib/typescript/src/index.d.ts +2 -1
  63. package/lib/typescript/src/index.d.ts.map +1 -1
  64. package/package.json +1 -1
  65. package/src/Competition/index.tsx +69 -49
  66. package/src/Components/ImageUploader.tsx +4 -3
  67. package/src/CreateEngagement/index.tsx +6 -2
  68. package/src/Squares/index.tsx +7 -1
  69. package/src/SquaresManager/api/index.ts +99 -0
  70. package/src/SquaresManager/index.tsx +395 -0
  71. package/src/index.tsx +2 -0
  72. package/src/types.d.ts +1 -1
@@ -321,7 +321,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
321
321
  const { height, width } = ev.nativeEvent.layout;
322
322
  setSize({ height, width });
323
323
  }}>
324
- <View style={{ flex:1 }}>
324
+ <View transparent style={{ flex:1 }}>
325
325
  <FlatList
326
326
  data={sections}
327
327
  key={'create_engagement_list'}
@@ -428,6 +428,7 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
428
428
  <Text theme='description' color={active_engagement == 'squares' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create an auction squares game. Bid on squares until the auction ends. Buy and sell squares throughout the game.</Text>
429
429
  </View>
430
430
  </Button>
431
+ {false ?
431
432
  <Button
432
433
  key='bracket'
433
434
  float
@@ -440,6 +441,8 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
440
441
  <Text theme='description' color={active_engagement == 'bracket' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create a bracket. Make picks until the championship. Pick more correctly and win!</Text>
441
442
  </View>
442
443
  </Button>
444
+ :<></>}
445
+ {false ?
443
446
  <Button
444
447
  key='flash'
445
448
  float
@@ -452,6 +455,7 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
452
455
  <Text theme='description' color={active_engagement == 'flash' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create a custom flash market. Players bet on the perimutuel outcomes, get it right and get paid!</Text>
453
456
  </View>
454
457
  </Button>
458
+ :<></>}
455
459
  </View>
456
460
  )
457
461
  }
@@ -669,7 +673,7 @@ const CreateSquares = ({onFocusPosition, onUpdateDraft}:SCProps) => {
669
673
  : active_event ?
670
674
  <Button style={{ borderColor:active_event?Colors.text.success:Colors.text.warning }} float onPress={() => setSQData({ ...sq_data, league_schedule: true })}>
671
675
  <Text theme='h1'>{active_event.event_title}</Text>
672
- </Button>
676
+ </Button>
673
677
  :<></>}
674
678
  </View>
675
679
  </View>
@@ -25,6 +25,7 @@ type SquaresModuleProps = {
25
25
  distinct_id:string,
26
26
  view_mode:'desktop'|'mobile',
27
27
  sq_comp_id:string,
28
+ onManageSquares?:(sc:SquaresCompetitionProps) => void,
28
29
  insets?: { top:number, bottom:number },
29
30
  onRequestAuthenticate: (auth_strategy_id?:string) => void,
30
31
  onShareCompetition:(squares_competition:SquaresCompetitionProps) => void,
@@ -34,7 +35,7 @@ type SquaresModuleProps = {
34
35
 
35
36
  const squares_sections = ['header', 'toggle', 'event', 'board', 'board_stats', 'my_stats', 'results', 'my_squares', 'winners','hidden_prizes','details', 'owners']
36
37
 
37
- const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id, onRequestAuthenticate, onShareCompetition, onPlayerSelect }:SquaresModuleProps) => {
38
+ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id, onManageSquares, onRequestAuthenticate, onShareCompetition, onPlayerSelect }:SquaresModuleProps) => {
38
39
  const C = useColors();
39
40
  const [ active_tab, setActiveTab ] = useState('board');
40
41
  const [ needs_reload, setNeedsReload ] = useState(false);
@@ -338,6 +339,11 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
338
339
  <Text theme='h1'>{squares_competition.sq_comp_name}</Text>
339
340
  <Text style={{ marginTop:4 }} theme='h2'>{squares_competition.sq_comp_description}</Text>
340
341
  </View>
342
+ {onManageSquares && player_id == squares_competition?.admin_id ?
343
+ <Button float style={{ padding:10, marginRight:10 }} onPress={() => onManageSquares(squares_competition)}>
344
+ <Icons.SettingsIcon size={18} color={C.text.h1} />
345
+ </Button>
346
+ :<></>}
341
347
  <Button float onPress={() => onShareCompetition(squares_competition)}>
342
348
  <Icons.ShareIcon color={C.text.h1} size={14} />
343
349
  </Button>
@@ -0,0 +1,99 @@
1
+ import axios from "axios";
2
+ import type { CompanyProps, EventProps, GroupPlayerProps, GroupProps, LeagueProps, PlayerSquareProps, SquareOfferProps, SquarePrizeProps, SquareProps, SquareResultProps, SquaresCompetitionProps, SquaresPayoutProps, SquaresTypeProps } from "../../types";
3
+ import { APIOverrides } from "../../ApiOverrides";
4
+ import type { CompanyMemberProps } from "../../Authenticator/api/types";
5
+
6
+ let AUTH_SVC_API = ''
7
+ let TP_SVC_API = ''
8
+ let EVENT_SVC_API = ''
9
+ let SOCIAL_SVC_API = ''
10
+ export { SquaresManagerApi }
11
+
12
+
13
+ const SquaresManagerApi = {
14
+ setEnvironment: () => {
15
+ const endpoints = APIOverrides.getEndpoints();
16
+ TP_SVC_API = endpoints['TP_SVC_API'] as string;
17
+ EVENT_SVC_API = endpoints['EVENT_SVC_API'] as string;
18
+ //MK_SVC_API = endpoints['MK_SVC_API'] as string;
19
+ AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
20
+ SOCIAL_SVC_API = endpoints['SOCIAL_SVC_API'] as string;
21
+ },
22
+ getLeagues: async():Promise<LeagueProps[]> => {
23
+ try {
24
+ const resp = await axios.get(`${EVENT_SVC_API}/v1/leagues`);
25
+ return resp.data.leagues
26
+ } catch (e) {
27
+ return []
28
+ }
29
+ },
30
+ getEventsByEventIds: async(event_ids:string[]):Promise<EventProps[]> => {
31
+ try {
32
+ if(event_ids.length == 0){ return [] }
33
+ const resp = await axios.post(`${EVENT_SVC_API}/v1/events/bulk/get`, { attribute:'event_id', values: event_ids })
34
+ return resp.data.events
35
+ } catch (e) {
36
+ return []
37
+ }
38
+ },
39
+ getSquareCompetitionById: async(sq_comp_id:string):Promise<undefined | { squares_competition:SquaresCompetitionProps, square_results:SquareResultProps[], squares:SquareProps[], player_squares:PlayerSquareProps[], square_offers:SquareOfferProps[], squares_type:SquaresTypeProps, squares_payout_type: SquaresPayoutProps, player_square_history:PlayerSquareProps[], square_prizes:SquarePrizeProps[] }> => {
40
+ try {
41
+ const resp = await axios.get(`${TP_SVC_API}/tp/squares/comp/details/${sq_comp_id}`)
42
+ return resp.data
43
+ } catch (e) {
44
+ return undefined
45
+ }
46
+ },
47
+ updateSquaresCompetition: async(squares_competition:SquaresCompetitionProps):Promise<SquaresCompetitionProps|undefined> => {
48
+ try {
49
+ const resp = await axios.post(`${TP_SVC_API}/v1/squares/competition/update`, { squares_competition });
50
+ return resp.data.squares_competition
51
+ } catch (e) {
52
+ return undefined
53
+ }
54
+ },
55
+ getMyCompanies : async():Promise<{companies:CompanyProps[], company_members:CompanyMemberProps[]}> => {
56
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/companies/me`)
57
+ const { companies, company_members } = resp.data
58
+ return { companies, company_members }
59
+ },
60
+ getMyGroups: async(offset:number):Promise<{groups: GroupProps[], group_players:GroupPlayerProps[]}> => {
61
+ try {
62
+ const resp = await axios.get(`${SOCIAL_SVC_API}/v2/groups/me/multiple?offset=${offset}`);
63
+ return resp.data
64
+ } catch (e) {
65
+ return { group_players: [], groups: [] }
66
+ }
67
+ },
68
+
69
+ createSquaresCompetition: async(squares_competition:SquaresCompetitionProps):Promise<SquaresCompetitionProps | undefined> => {
70
+ try {
71
+ const resp = await axios.post(`${TP_SVC_API}/v1/squares/competition/create`, { squares_competition });
72
+ return resp.data.squares_competition
73
+ } catch (e) {
74
+ console.log(e)
75
+ return undefined
76
+ }
77
+ },
78
+ activateSquares: async(sq_comp_id:string):Promise<undefined | { squares_competition:SquaresCompetitionProps }> => {
79
+ try {
80
+ const resp = await axios.post(`${TP_SVC_API}/v1/squares/competition/activate`, { sq_comp_id });
81
+ return resp.data
82
+ } catch (e) {
83
+ return undefined
84
+ }
85
+ }
86
+ }
87
+
88
+
89
+ export const SquaresManagerHelpers = {
90
+ isValid: (draft_squares?:SquaresCompetitionProps) => {
91
+ if(!draft_squares){ return ['Invalid'] }
92
+ let errors:string[] = []
93
+ if(!draft_squares){ errors.push('Please complete steps'); return errors }
94
+ if(!draft_squares.sq_comp_name){ errors.push('Please add a squares name') }
95
+ if(!draft_squares.sq_comp_description){ errors.push('Please add a description') }
96
+ if(!draft_squares.event_id){ errors.push('Please add an event') }
97
+ return errors
98
+ }
99
+ }
@@ -0,0 +1,395 @@
1
+ import React, { useEffect, useState } from "react"
2
+ import { SquaresManagerApi, SquaresManagerHelpers } from "./api";
3
+ import { Button, Text, TextInput, View } from "../Components/Themed";
4
+ import { FlatList, Image, type ViewStyle } from "react-native";
5
+ import type { CompanyProps, EventProps, FocusPositionProps, GroupProps, LeagueProps, MyPlayerProps, SquaresCompetitionProps } from "../types";
6
+ import { useColors } from "../constants/useColors";
7
+ import LeagueSchedule from "../MarketComponents/components/LeagueSchedule";
8
+ import { Icons, Switch, Toggle } from "../Components";
9
+ import moment from "moment-mini";
10
+ import ImageUploader from "../Components/ImageUploader";
11
+ import GroupSelector from "../CompetitionManager/components/GroupSelector";
12
+ import CompanySelector from "../CompetitionManager/components/CompanySelector";
13
+
14
+ type SquaresManagerProps = {
15
+ sq_comp_id:string,
16
+ onFocusPosition?:(pos:FocusPositionProps) => void,
17
+ float?:boolean,
18
+ player?:MyPlayerProps,
19
+ onActivate:(sq:SquaresCompetitionProps) => void,
20
+ onClose:() => void,
21
+ header_style?:ViewStyle,
22
+ footer_style?:ViewStyle
23
+ }
24
+ const sections = ['header','toggle','info','event']
25
+ const SquaresManager = ({ sq_comp_id, float, player, header_style, onFocusPosition, footer_style, onClose, onActivate }:SquaresManagerProps) => {
26
+ const Colors = useColors();
27
+ const [ my_data, setMyData ] = useState<{
28
+ groups:GroupProps[],
29
+ companies:CompanyProps[]
30
+ }>({
31
+ groups: [],
32
+ companies: []
33
+ });
34
+ const { groups, companies } = my_data;
35
+ const [ sq_state, setState ] = useState<{
36
+ loading: boolean,
37
+ active_tab: 'info'|'event',
38
+ leagues_visible?:boolean,
39
+ active_event?:EventProps,
40
+ active_league?:LeagueProps,
41
+ min_square_price:string,
42
+ leagues:LeagueProps[],
43
+ league_schedule:boolean,
44
+ draft_competition?:SquaresCompetitionProps,
45
+ squares_competition?:SquaresCompetitionProps
46
+ }>({
47
+ loading:false,
48
+ active_tab: 'info',
49
+ leagues_visible:false,
50
+ leagues:[],
51
+ min_square_price: '0',
52
+ league_schedule: false
53
+ });
54
+ const { loading, squares_competition, min_square_price, active_tab, leagues, league_schedule, draft_competition, leagues_visible, active_event, active_league } = sq_state
55
+ const active_group = groups.find(g => g.group_id == draft_competition?.group_id)
56
+ const active_company = companies.find(c => c.company_id == draft_competition?.company_id);
57
+
58
+ useEffect(() => {
59
+ SquaresManagerApi.setEnvironment();
60
+ getData(sq_comp_id)
61
+ if(player){ getMyData() }
62
+ },[sq_comp_id, player]);
63
+
64
+ const errors = SquaresManagerHelpers.isValid(draft_competition);
65
+
66
+ const getMyData = async() => {
67
+ const my_groups = await SquaresManagerApi.getMyGroups(0);
68
+ const my_comps = await SquaresManagerApi.getMyCompanies();
69
+ setMyData({
70
+ ...my_data,
71
+ groups: my_groups.groups,
72
+ companies: my_comps.companies
73
+ });
74
+ }
75
+
76
+ const getData = async(id:string) => {
77
+ setState({ ...sq_state, loading: true });
78
+ const sq_data = await SquaresManagerApi.getSquareCompetitionById(id);
79
+ const lgs = await SquaresManagerApi.getLeagues();
80
+ if(!sq_data){ return alert('Unable to get Squares Details - please try again') }
81
+ let active_ev_id = sq_data.squares_competition.event_id
82
+ let active_ev:EventProps | undefined = undefined
83
+ if(active_ev_id){
84
+ const evs = await SquaresManagerApi.getEventsByEventIds([active_ev_id])
85
+ active_ev = evs[0]
86
+ }
87
+ let active_league = lgs.find(l => l.league_id == active_ev?.league_id);
88
+ setState({
89
+ ...sq_state,
90
+ loading: false,
91
+ leagues: lgs.filter(l => l.sport == 'Football'),
92
+ active_event: active_ev,
93
+ min_square_price: sq_data.squares_competition.minimum_square_price.toFixed(2),
94
+ active_league: active_league,
95
+ draft_competition: sq_data.squares_competition,
96
+ squares_competition: sq_data.squares_competition
97
+ })
98
+ }
99
+
100
+ const handleActivate = async() => {
101
+ if(!squares_competition || loading){ return }
102
+ if(errors.length > 0){ return alert(errors.map(e => e)) }
103
+ setState({ ...sq_state, loading: true });
104
+ const activate_resp = await SquaresManagerApi.activateSquares(squares_competition.sq_comp_id);
105
+ if(!activate_resp){ return alert('Unable to activate competition') }
106
+ setState({
107
+ ...sq_state, loading:false,
108
+ squares_competition: activate_resp.squares_competition,
109
+ draft_competition: activate_resp.squares_competition
110
+ });
111
+ onActivate(activate_resp.squares_competition)
112
+ }
113
+
114
+ const updateCompetition = async(sq_comp:SquaresCompetitionProps) => {
115
+ if(errors.length > 0){ return alert(errors.map(e => e)) }
116
+ if(loading){ return }//No mashy
117
+ setState({ ...sq_state, loading:true });
118
+ const new_comp = await SquaresManagerApi.updateSquaresCompetition({ ...sq_comp, minimum_square_price: parseFloat(min_square_price)});
119
+ if(!new_comp){ return alert('Unable to update squares competition') }
120
+ setState({
121
+ ...sq_state,
122
+ squares_competition: new_comp,
123
+ draft_competition: new_comp,
124
+ loading:false,
125
+
126
+ })
127
+ }
128
+
129
+ const renderLeagues = (data:{item:LeagueProps, index:number}) => {
130
+ const selected = active_league?.league_id == data.item.league_id ? true : false
131
+
132
+ return (
133
+ <Button
134
+ transparent
135
+ style={{ flexDirection:'row', borderRadius:0, padding:10, alignItems:'center', borderBottomWidth:1, borderColor:Colors.borders.light }}
136
+ onPress={() => setState({ ...sq_state, active_league: selected?undefined : data.item, leagues_visible:false, league_schedule: selected?false:true })}
137
+ >
138
+ <Image
139
+ source={{ uri: data.item.league_image }}
140
+ style={{ height:30, width:30 }}
141
+ resizeMode='contain'
142
+ />
143
+ <View transparent style={{ flex:1, marginLeft:10 }}>
144
+ <Text theme='h1'>{data.item.league_name}</Text>
145
+ <Text theme='description' style={{ marginTop:3 }}>{data.item.sport}</Text>
146
+ </View>
147
+ </Button>
148
+ )
149
+ }
150
+
151
+
152
+ const renderSections = (data:{ item:string, index:number }) => {
153
+ switch(data.item){
154
+ case 'header':
155
+ if(!squares_competition || !draft_competition){ return <></> }
156
+ return (
157
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, ...header_style }}>
158
+ <ImageUploader style={{padding:0}} public_id={`sq_pic_${squares_competition.sq_comp_id}`} onFinishUpload={async(obj) => {
159
+ updateCompetition({ ...draft_competition, image: { ...obj, url: obj.secure_url } })
160
+
161
+ }}>
162
+ <View transparent style={{ alignItems:'center' }}>
163
+ {draft_competition.image?
164
+ <Image
165
+ source={{ uri: draft_competition.image?.url }}
166
+ resizeMode="cover"
167
+ style={{ height:40, width:40 }}
168
+ />
169
+ :
170
+ <Icons.ImageIcon size={30} color={Colors.text.h1} />
171
+ }
172
+ </View>
173
+
174
+ <Text theme="action" textAlign="center">{draft_competition.image?.url ? 'Change' : 'Add Image'}</Text>
175
+ </ImageUploader>
176
+ <View transparent style={{flex:1, marginLeft:10, marginRight:10}}>
177
+ <Text theme='h1'>{squares_competition.sq_comp_name}</Text>
178
+ <Text theme="description" style={{ marginTop:3 }}>{squares_competition.sq_comp_description}</Text>
179
+ </View>
180
+ <Button
181
+ title="X"
182
+ style={{ padding:10 }}
183
+ float
184
+ title_color={Colors.text.error}
185
+ onPress={() => onClose()}
186
+ />
187
+ </View>
188
+ )
189
+ case 'toggle':
190
+ return (
191
+ <View transparent>
192
+ <Toggle
193
+ border_radius={0}
194
+ toggle_padding={10}
195
+ padding={0}
196
+ options={[
197
+ { key: 'info', label: 'Info', icon: <Icons.MenuIcon size={14} color={Colors.text.warning} /> },
198
+ { key: 'event', label: 'Event', icon: <Icons.ActivityIcon size={14} color={Colors.text.warning} /> },
199
+ ]}
200
+ selected_option={active_tab}
201
+ onSelectOption={(key) => setState({ ...sq_state, active_tab: key as 'info'|'event'})}
202
+ title_renderer={(option) => {
203
+ const selected = option.key == active_tab ? true : false
204
+ return (
205
+ <View transparent style={{ justifyContent:'center', alignItems:'center' }}>
206
+ <View transparent>
207
+ {option.icon}
208
+ </View>
209
+ <Text style={{ marginTop:5 }} theme={selected?'h2':'description'} color={selected?Colors.toggle.text.active : Colors.toggle.text.inactive}>{option.label}</Text>
210
+ </View>
211
+ )
212
+ }}
213
+ />
214
+ </View>
215
+ )
216
+ case 'info':
217
+ if(!draft_competition){ return <></> }
218
+ if(active_tab != 'info'){ return <></> }
219
+ return (
220
+ <View>
221
+ <View style={{ padding:10 }}>
222
+ <Text theme='h1' style={{ marginBottom:10 }}>Competition Name</Text>
223
+ <TextInput
224
+ placeholder='Add Name here...'
225
+ value={draft_competition.sq_comp_name}
226
+ onFocusPosition={onFocusPosition}
227
+ style={{ borderColor:draft_competition.sq_comp_name ? Colors.text.success : Colors.text.warning }}
228
+ onChangeText={(text) => setState({ ...sq_state, draft_competition: { ...draft_competition, sq_comp_name: text }})}
229
+ />
230
+ </View>
231
+ <View style={{ padding:10 }}>
232
+ <Text theme='h1' style={{ marginBottom:10 }}>Competition Description</Text>
233
+ <TextInput
234
+ placeholder='Add Decription here...'
235
+ onFocusPosition={onFocusPosition}
236
+ value={draft_competition.sq_comp_description}
237
+ style={{ borderColor:draft_competition.sq_comp_description ? Colors.text.success : Colors.text.warning }}
238
+ onChangeText={(text) => setState({ ...sq_state, draft_competition: { ...draft_competition, sq_comp_description: text } })}
239
+ />
240
+ </View>
241
+ <View style={{ padding:10 }}>
242
+ <Text theme='h1' style={{ marginBottom:10 }}>Minimum Squares Price</Text>
243
+ <TextInput
244
+ placeholder='1'
245
+ onFocusPosition={onFocusPosition}
246
+ value={min_square_price}
247
+ style={{ textAlign:'center', borderColor:draft_competition.minimum_square_price <= 0 ? Colors.text.warning : Colors.text.success }}
248
+ onChangeText={(text) => setState({ ...sq_state, min_square_price: text })}
249
+ />
250
+ </View>
251
+ <View type='row' nativeID="invite_only" style={{ flexWrap:'wrap', padding:20, borderBottomWidth:1, borderColor:Colors.borders.light }}>
252
+ <View style={{ flex:1, marginRight:15 }}>
253
+ <Text theme='h1'>Make Private</Text>
254
+ <Text style={{ marginTop:3 }} theme='description'>Only access this competition using an invite code.</Text>
255
+ </View>
256
+ <Switch
257
+ value={draft_competition.invite_only_ind}
258
+ switch_type="on_off"
259
+ onChange={(value) => {
260
+ if(player?.role != 'admin'){ return alert('You do not have access to make public competitions at this time.') }
261
+ updateCompetition({ ...draft_competition, invite_only_ind: value })
262
+ }}
263
+ />
264
+ </View>
265
+ {draft_competition.invite_only_ind ?
266
+ <View style={{ padding:10 }}>
267
+ <Text theme='h1' style={{ marginBottom:10 }}>Competition Invite Code</Text>
268
+ <TextInput
269
+ placeholder='Add Invite Code here...'
270
+ onFocusPosition={onFocusPosition}
271
+ value={draft_competition.competition_code}
272
+ style={{ borderColor:draft_competition.competition_code ? Colors.text.success : Colors.text.warning }}
273
+ onChangeText={(text) => setState({ ...sq_state, draft_competition: { ...draft_competition, competition_code: text } })}
274
+ />
275
+ </View>
276
+ :<></>}
277
+ {groups.length > 0 ?
278
+ <View style={{ padding:20, borderBottomWidth:1, borderColor:Colors.borders.light }}>
279
+ <View style={{ marginBottom:10 }}>
280
+ <Text theme='h1'>My Groups</Text>
281
+ <Text style={{ marginTop:3 }} theme='description'>Add this competition to a group that you are a member of</Text>
282
+ </View>
283
+ <GroupSelector
284
+ active_group={active_group}
285
+ groups={groups}
286
+ onSelectGroup={(g) => updateCompetition({ ...draft_competition, group_id: g?.group_id })}
287
+ />
288
+ </View>
289
+ :<></>}
290
+ {companies.length > 0 ?
291
+ <View style={{ padding:20, borderBottomWidth:1, borderColor:Colors.borders.light }}>
292
+ <View style={{ marginBottom:10 }}>
293
+ <Text theme='h1'>My Companies</Text>
294
+ <Text style={{ marginTop:3 }} theme='description'>Add this competition to a company that you are a member of</Text>
295
+ </View>
296
+ <CompanySelector
297
+ active_company={active_company}
298
+ companies={companies}
299
+ onSelectCompany={(c) => updateCompetition({ ...draft_competition, company_id: c?.company_id })}
300
+ />
301
+ </View>
302
+ :<></>}
303
+ </View>
304
+ )
305
+ case 'event':
306
+ if(active_tab != 'event'){ return <></> }
307
+ return (
308
+ <View>
309
+ <View style={{ padding:10 }}>
310
+ <Text theme='h1' style={{ marginBottom:10 }}>Squares Event</Text>
311
+ <Button float style={{ borderColor:active_league?Colors.text.success:Colors.text.warning }} onPress={() => setState({ ...sq_state, leagues_visible: !leagues_visible })}>
312
+ <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
313
+ <Text style={{ flex:1, marginRight:10 }} theme='h1'>{active_league?.league_name ?? 'Select League'}</Text>
314
+ <Icons.ChevronIcon direction={leagues_visible?'up':'down'} color={Colors.text.h1} size={8} />
315
+ </View>
316
+ {leagues_visible ?
317
+ <View transparent style={{ marginTop:20 }}>
318
+ <FlatList
319
+ data={leagues.sort((a,b) => a.priority - b.priority)}
320
+ key={'competition_reult_types'}
321
+ keyExtractor={item => item.league_id.toString()}
322
+ renderItem={renderLeagues}
323
+ />
324
+ </View>
325
+ :<></>}
326
+ </Button>
327
+ </View>
328
+ <View float style={{ margin:10 }}>
329
+ {active_league && league_schedule ?
330
+ <LeagueSchedule
331
+ onSelectEvent={(e) => {
332
+ if(!draft_competition){ return }
333
+ setState({
334
+ ...sq_state,
335
+ active_event: e,
336
+ league_schedule:false,
337
+ draft_competition: {
338
+ ...draft_competition,
339
+ sport: active_league?.league_name ?? draft_competition.sport,
340
+ begin_datetime: moment(e.scheduled_datetime).add(4, 'minutes'),
341
+ event_id: e.event_id
342
+ }
343
+ });
344
+ }}
345
+ league={active_league}
346
+ active_event={active_event?.event_id}
347
+ />
348
+ : active_event ?
349
+ <Button style={{ borderColor:active_event?Colors.text.success:Colors.text.warning }} float onPress={() => setState({ ...sq_state, league_schedule: true })}>
350
+ <Text theme='h1'>{active_event.event_title}</Text>
351
+ </Button>
352
+ :<></>}
353
+ </View>
354
+ </View>
355
+
356
+ )
357
+ default: return <></>
358
+ }
359
+ }
360
+ const is_changed = JSON.stringify(squares_competition) != JSON.stringify(draft_competition) ? true : parseFloat(min_square_price) != draft_competition?.minimum_square_price ? true : false
361
+ return (
362
+ <View float={float} style={{ flex:1 }}>
363
+ <View transparent style={{ flex:1 }}>
364
+ <FlatList
365
+ data={sections}
366
+ key={'manage_squares'}
367
+ keyExtractor={item => item}
368
+ renderItem={renderSections}
369
+ />
370
+ </View>
371
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, ...footer_style }}>
372
+ <Button
373
+ disabled={!is_changed}
374
+ style={{ flex:1, opacity: !is_changed || loading || errors.length > 0 ? 0.5: 1 }}
375
+ loading={loading}
376
+ title="SAVE"
377
+ type='action'
378
+ onPress={() => draft_competition ? updateCompetition(draft_competition) : console.log('')}
379
+ />
380
+ {squares_competition?.status == 'pending' ?
381
+ <Button
382
+ disabled={errors.length > 0 || loading ? true : false}
383
+ style={{ flex:2, marginLeft:10, opacity: errors.length > 0 ? 0.5: 1 }}
384
+ loading={loading}
385
+ title="ACTIVATE!"
386
+ type='success'
387
+ onPress={() => handleActivate()}
388
+ />
389
+ :<></>}
390
+ </View>
391
+ </View>
392
+ )
393
+ }
394
+
395
+ export default SquaresManager
package/src/index.tsx CHANGED
@@ -60,6 +60,7 @@ import GuideView from './Guide';
60
60
  import GroupComponent from './Group';
61
61
  import CreateGroupWizard from './Group/components/CreateGroupWizard';
62
62
  import CreateEngagement from './CreateEngagement';
63
+ import SquaresManager from './SquaresManager';
63
64
  export {
64
65
  Authenticator,
65
66
  Observer,
@@ -67,6 +68,7 @@ export {
67
68
  BEEventApi,
68
69
  RankingsCard,
69
70
  BELinkApi,
71
+ SquaresManager,
70
72
  GuideView,
71
73
  BetMatch,
72
74
  ManageFilter,
package/src/types.d.ts CHANGED
@@ -2205,7 +2205,7 @@ export interface SquaresCompetitionProps {
2205
2205
  market_type:'FOR_MONEY'|'FREE', potential_winnings:number, last_iteration_scored:number, competition_code?:string, available_squares?:number,
2206
2206
  begin_datetime:any, create_datetime:any, last_update_datetime:any, complete_datetime?:any, event_backup?:EventProps, guaranteed_payout?:number,
2207
2207
  sq_comp_description?:string, image?:{ url:string }, prize_override?:string, prize_image?:{url:string},
2208
- auth_strategy_id?:string, group_id?:string
2208
+ auth_strategy_id?:string, group_id?:string, status?:string
2209
2209
  }
2210
2210
 
2211
2211
  export interface SquaresExpectedValueProps {