be-components 1.0.3 → 1.0.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 (29) hide show
  1. package/lib/commonjs/Bracket/api/index.js +9 -0
  2. package/lib/commonjs/Bracket/api/index.js.map +1 -1
  3. package/lib/commonjs/Bracket/components/BracketCompetitionSelector.js +70 -4
  4. package/lib/commonjs/Bracket/components/BracketCompetitionSelector.js.map +1 -1
  5. package/lib/commonjs/Bracket/components/BracketPlay/index.js +3 -0
  6. package/lib/commonjs/Bracket/components/BracketPlay/index.js.map +1 -1
  7. package/lib/commonjs/Bracket/components/PlayerBracketManager.js +71 -3
  8. package/lib/commonjs/Bracket/components/PlayerBracketManager.js.map +1 -1
  9. package/lib/commonjs/Bracket/components/RoomMenu.js +1 -1
  10. package/lib/module/Bracket/api/index.js +9 -0
  11. package/lib/module/Bracket/api/index.js.map +1 -1
  12. package/lib/module/Bracket/components/BracketCompetitionSelector.js +71 -5
  13. package/lib/module/Bracket/components/BracketCompetitionSelector.js.map +1 -1
  14. package/lib/module/Bracket/components/BracketPlay/index.js +4 -1
  15. package/lib/module/Bracket/components/BracketPlay/index.js.map +1 -1
  16. package/lib/module/Bracket/components/PlayerBracketManager.js +71 -3
  17. package/lib/module/Bracket/components/PlayerBracketManager.js.map +1 -1
  18. package/lib/module/Bracket/components/RoomMenu.js +1 -1
  19. package/lib/typescript/src/Bracket/api/index.d.ts +1 -0
  20. package/lib/typescript/src/Bracket/api/index.d.ts.map +1 -1
  21. package/lib/typescript/src/Bracket/components/BracketCompetitionSelector.d.ts.map +1 -1
  22. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  23. package/lib/typescript/src/Bracket/components/PlayerBracketManager.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/Bracket/api/index.ts +5 -0
  26. package/src/Bracket/components/BracketCompetitionSelector.tsx +53 -9
  27. package/src/Bracket/components/BracketPlay/index.tsx +2 -1
  28. package/src/Bracket/components/PlayerBracketManager.tsx +47 -1
  29. package/src/Bracket/components/RoomMenu.tsx +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "be-components",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Components for BettorEdge Apps",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -160,6 +160,11 @@ const BracketCompetitionHelpers = {
160
160
  if(moment().isBefore(moment(bc.scheduled_datetime))){ return true }
161
161
  return false
162
162
  },
163
+ canMakePick: (bracket?:BracketProps) => {
164
+ if(!bracket){ return false }
165
+ if(moment().isAfter(moment(bracket.scheduled_datetime))){ return false }
166
+ return true
167
+ },
163
168
  isEnoughBalance: (bc:BracketCompetitionProps, player_balance?:PlayerBalanceProps) => {
164
169
  if(!player_balance) return false
165
170
  if(bc.market_type == 'FREE' && player_balance.free_market_balance < bc.buy_in){ return false }
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { FlatList, TouchableOpacity, View, Image } from 'react-native';
3
3
  import type { BracketCompetitionProps, BracketProps, LeagueProps } from '../../types';
4
- import { Icons, Text } from '../../Components';
4
+ import { Button, Icons, Text, TextInput } from '../../Components';
5
5
  import { BracketComeptitionApi } from '../api';
6
6
  import Colors from '../../constants/colors';
7
7
  import moment from 'moment-mini';
@@ -14,6 +14,8 @@ type BracketCompetitionSelectorProps = {
14
14
  onCompetitionSelect:(bracket_competition:BracketCompetitionProps) => void
15
15
  }
16
16
  const BracketCompetitionSelector = ({ visible, leagues, brackets, onClose, onCompetitionSelect }:BracketCompetitionSelectorProps) => {
17
+ const [ search_value, setSearchValue ] = useState('');
18
+ const [ search_error, setSearchError ] = useState<string|undefined>(undefined);
17
19
  const [ card_data, setData ] = useState<{
18
20
  loading:boolean,
19
21
  shown_brackets:string[]
@@ -24,8 +26,11 @@ const BracketCompetitionSelector = ({ visible, leagues, brackets, onClose, onCom
24
26
  bracket_competitions: []
25
27
  })
26
28
  const { loading, bracket_competitions, shown_brackets } = card_data;
27
-
28
- const unique_bracket_ids = [ ...new Set(bracket_competitions.map(bc => bc.bracket_id)) ]
29
+ let visible_competitions = [ ...bracket_competitions ];
30
+ if(search_value){
31
+ visible_competitions = visible_competitions.filter(c => `${c.competition_name.toLowerCase()}`.includes(search_value.toLowerCase()))
32
+ }
33
+ const unique_bracket_ids = [ ...new Set(visible_competitions.map(bc => bc.bracket_id)) ]
29
34
 
30
35
  useEffect(() => {
31
36
  if(!visible){ return }
@@ -40,6 +45,12 @@ const BracketCompetitionSelector = ({ visible, leagues, brackets, onClose, onCom
40
45
  })
41
46
  }
42
47
 
48
+ const handleFindPrivate = async() => {
49
+ const bc = await BracketComeptitionApi.getBracketcompetitionByCode(search_value)
50
+ if(!bc){ return setSearchError(`Unable to find competition with the provided code`) }
51
+ return onCompetitionSelect(bc)
52
+ }
53
+
43
54
  const renderCompetitions = (data: { item:BracketCompetitionProps, index:number } ) => {
44
55
  return (
45
56
  <TouchableOpacity style={{ padding:10, flexDirection:'row', alignItems:'center', borderBottomWidth:1, borderColor:Colors.shades.shade600 }}
@@ -64,7 +75,7 @@ const BracketCompetitionSelector = ({ visible, leagues, brackets, onClose, onCom
64
75
  const bracket = brackets.find(b => b.bracket_id == data.item);
65
76
  if(!bracket){ return <></> }
66
77
  const league = leagues.find(l => l.league_id == bracket.league_id);
67
- const comps = bracket_competitions.filter(bc => bc.bracket_id == data.item);
78
+ const comps = visible_competitions.filter(bc => bc.bracket_id == data.item);
68
79
  const selected = shown_brackets.includes(data.item)
69
80
  const started = moment().isAfter(moment(bracket.scheduled_datetime)) ? true : false;
70
81
  return (
@@ -111,11 +122,44 @@ const BracketCompetitionSelector = ({ visible, leagues, brackets, onClose, onCom
111
122
  <Text style={{ marginTop:4 }} size={14} color={Colors.brand.slate} weight='regular'>Select a competition below to see more details</Text>
112
123
  </View>
113
124
  </TouchableOpacity>
114
- <FlatList
115
- data={unique_bracket_ids}
116
- renderItem={renderBrackets}
117
- keyExtractor={(item) => item.toString()}
118
- />
125
+ <View>
126
+ <View style={{ padding:20 }}>
127
+ <View style={{ marginBottom:10 }}>
128
+ <Text size={14} color={Colors.brand.midnight} weight='semibold'>Have a private code?</Text>
129
+ <Text style={{ marginTop:3 }} size={12} color={Colors.brand.slate}>Enter it below and select search. If found, we will send you to the competition.</Text>
130
+ </View>
131
+ <View style={{ flexDirection:'row', alignItems:'center' }}>
132
+ <TextInput
133
+ style={{ flex:1 }}
134
+ value={search_value}
135
+ onChangeText={(text) => {
136
+ if(search_error){ setSearchError(undefined) }
137
+ setSearchValue(text)
138
+ }}
139
+ placeholder='Search or Enter Private Code'
140
+ placeholderTextColor={Colors.brand.slate}
141
+ />
142
+ {search_value ?
143
+ <Button
144
+ title='Find Private'
145
+ style={{ marginLeft:5 }}
146
+ padding={15}
147
+ title_color={Colors.shades.white}
148
+ backgroundColor={Colors.brand.electric}
149
+ onPress={() => handleFindPrivate()}
150
+ />
151
+ :<></>}
152
+ </View>
153
+ {search_error ?
154
+ <Text style={{ padding:10 }} size={14} color={Colors.utility.warning} weight='regular' textAlign='center'>{search_error}</Text>
155
+ :<></>}
156
+ </View>
157
+ <FlatList
158
+ data={unique_bracket_ids}
159
+ renderItem={renderBrackets}
160
+ keyExtractor={(item) => item.toString()}
161
+ />
162
+ </View>
119
163
  </View>
120
164
  )
121
165
  }
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { View, ActivityIndicator, TouchableOpacity, ScrollView, Image } from "react-native";
3
3
  import type { AthleteProps, BracketGroupProps, BracketProps, BracketRoundProps, CompetitionPlayerBracketProps, EventProps, MyPlayerProps, PlayerBracketPickProps, PlayerBracketProps, RoundEventProps, TeamProps } from '../../../types';
4
- import { BracketApi, BracketComeptitionApi } from '../../api';
4
+ import { BracketApi, BracketComeptitionApi, BracketCompetitionHelpers } from '../../api';
5
5
  import { Button, Icons, Text } from '../../../Components';
6
6
  import Colors from '../../../constants/colors';
7
7
  import BracketRoundSection from './BracketRound';
@@ -88,6 +88,7 @@ const BracketPlay = ({ visible, player, room_size, bracket_id, player_bracket_id
88
88
  }
89
89
 
90
90
  const handlePick = async(pick:PlayerBracketPickProps) => {
91
+ if(!BracketCompetitionHelpers.canMakePick(bracket)){ return alert('Bracket as already started') }
91
92
  if(!player){ return onRequestAuthenticate() }
92
93
  if(!bracket_id){ return }
93
94
  setRoundEventLoading(pick.round_event_id);
@@ -20,6 +20,8 @@ type PlayerBracketManagerProps = {
20
20
  }
21
21
 
22
22
  const PlayerBracketManager = ({ visible, teams, athletes, player_bracket, bracket_competitions, competition_player_brackets, onEditPicks, onSelectCompetition, onUpdateBracket, onClose }:PlayerBracketManagerProps) => {
23
+ const [ search_value, setSearchValue ] = useState('');
24
+ const [ search_error, setSearchError ] = useState<string|undefined>(undefined)
23
25
  const [ info_expanded, setInfoExpanded ] = useState(true);
24
26
  const [ manage_data, setData ] = useState<{
25
27
  loading:boolean,
@@ -31,12 +33,23 @@ const PlayerBracketManager = ({ visible, teams, athletes, player_bracket, bracke
31
33
  active_comp_toggle: 'entered'
32
34
  })
33
35
  const { draft_bracket, active_comp_toggle } = manage_data;
36
+ let visible_competitions = [ ...bracket_competitions ];
37
+ if(search_value){
38
+ visible_competitions = visible_competitions.filter(c => `${c.competition_name.toLowerCase()}`.includes(search_value.toLowerCase()))
39
+ }
34
40
 
35
41
  useEffect(() => {
36
42
  setData({ ...manage_data, draft_bracket: player_bracket })
37
43
  },[player_bracket])
38
44
 
39
45
 
46
+ const handleFindPrivate = async() => {
47
+ const bc = await BracketComeptitionApi.getBracketcompetitionByCode(search_value)
48
+ if(!bc){ return setSearchError(`Unable to find competition with the provided code`) }
49
+ return onSelectCompetition(bc)
50
+ }
51
+
52
+
40
53
  const renderCompetitions = (data: { item:BracketCompetitionProps, index:number }) => {
41
54
  const payout = BracketCompetitionHelpers.getPayout(data.item)
42
55
  return (
@@ -213,11 +226,44 @@ const PlayerBracketManager = ({ visible, teams, athletes, player_bracket, bracke
213
226
  keyExtractor={(item) => item.competition_player_bracket_id.toString()}
214
227
  />
215
228
  : active_comp_toggle == 'eligible' ?
229
+ <View>
230
+ <View style={{ padding:20, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }}>
231
+ <View style={{ marginBottom:10 }}>
232
+ <Text size={14} color={Colors.brand.midnight} weight='semibold'>Have a private code?</Text>
233
+ <Text style={{ marginTop:3 }} size={12} color={Colors.brand.slate}>Enter it below and select search. If found, we will send you to the competition.</Text>
234
+ </View>
235
+ <View style={{ flexDirection:'row', alignItems:'center' }}>
236
+ <TextInput
237
+ style={{ flex:1 }}
238
+ value={search_value}
239
+ onChangeText={(text) => {
240
+ if(search_error){ setSearchError(undefined) }
241
+ setSearchValue(text)
242
+ }}
243
+ placeholder='Search or Enter Private Code'
244
+ placeholderTextColor={Colors.brand.slate}
245
+ />
246
+ {search_value ?
247
+ <Button
248
+ title='Find Private'
249
+ style={{ marginLeft:5 }}
250
+ padding={15}
251
+ title_color={Colors.shades.white}
252
+ backgroundColor={Colors.brand.electric}
253
+ onPress={() => handleFindPrivate()}
254
+ />
255
+ :<></>}
256
+ </View>
257
+ {search_error ?
258
+ <Text style={{ padding:10 }} size={14} color={Colors.utility.warning} weight='regular' textAlign='center'>{search_error}</Text>
259
+ :<></>}
260
+ </View>
216
261
  <FlatList
217
- data={bracket_competitions}
262
+ data={visible_competitions}
218
263
  keyExtractor={(item) => item.bracket_competition_id.toString()}
219
264
  renderItem={renderCompetitions}
220
265
  />
266
+ </View>
221
267
  :<></>}
222
268
  </View>
223
269
  </View>
@@ -21,7 +21,7 @@ const RoomMenu = ({ visible, onOptionSelect, onClose }: RoomMenuProps ) => {
21
21
 
22
22
  const renderOptions = (data: { item:OptionType, index:number }) => {
23
23
  return (
24
- <TouchableOpacity style={{ flexDirection:'row', padding:10, alignItems:'center', borderBottomWidth:1, borderColor:Colors.shades.shade600 }}
24
+ <TouchableOpacity style={{ flexDirection:'row', padding:20, alignItems:'center', borderBottomWidth:1, borderColor:Colors.shades.shade600 }}
25
25
  onPress={() => onOptionSelect(data.item)}>
26
26
  <View style={{ flex:1 }}>
27
27
  <Text size={16} color={Colors.brand.midnight} weight='bold'>{data.item.label}</Text>