be-components 5.4.4 → 5.4.6

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 (46) hide show
  1. package/lib/commonjs/Components/Icons.js +27 -0
  2. package/lib/commonjs/Components/Icons.js.map +1 -1
  3. package/lib/commonjs/GolfScoreboard/api/index.js +119 -0
  4. package/lib/commonjs/GolfScoreboard/api/index.js.map +1 -1
  5. package/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.js +282 -0
  6. package/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.js.map +1 -0
  7. package/lib/commonjs/GolfScoreboard/index.js +202 -15
  8. package/lib/commonjs/GolfScoreboard/index.js.map +1 -1
  9. package/lib/module/Components/Icons.js +27 -0
  10. package/lib/module/Components/Icons.js.map +1 -1
  11. package/lib/module/GolfScoreboard/api/index.js +119 -0
  12. package/lib/module/GolfScoreboard/api/index.js.map +1 -1
  13. package/lib/module/GolfScoreboard/components/LeaderBetSelector.js +273 -0
  14. package/lib/module/GolfScoreboard/components/LeaderBetSelector.js.map +1 -0
  15. package/lib/module/GolfScoreboard/index.js +203 -16
  16. package/lib/module/GolfScoreboard/index.js.map +1 -1
  17. package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
  18. package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
  19. package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts +6 -0
  20. package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts.map +1 -1
  21. package/lib/typescript/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.d.ts +16 -0
  22. package/lib/typescript/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.d.ts.map +1 -0
  23. package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts +4 -1
  24. package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts.map +1 -1
  25. package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
  26. package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
  27. package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts +6 -0
  28. package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts.map +1 -1
  29. package/lib/typescript/lib/module/GolfScoreboard/components/LeaderBetSelector.d.ts +16 -0
  30. package/lib/typescript/lib/module/GolfScoreboard/components/LeaderBetSelector.d.ts.map +1 -0
  31. package/lib/typescript/lib/module/GolfScoreboard/index.d.ts +4 -1
  32. package/lib/typescript/lib/module/GolfScoreboard/index.d.ts.map +1 -1
  33. package/lib/typescript/src/Components/Icons.d.ts +1 -0
  34. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  35. package/lib/typescript/src/GolfScoreboard/api/index.d.ts +8 -1
  36. package/lib/typescript/src/GolfScoreboard/api/index.d.ts.map +1 -1
  37. package/lib/typescript/src/GolfScoreboard/components/LeaderBetSelector.d.ts +18 -0
  38. package/lib/typescript/src/GolfScoreboard/components/LeaderBetSelector.d.ts.map +1 -0
  39. package/lib/typescript/src/GolfScoreboard/index.d.ts +5 -1
  40. package/lib/typescript/src/GolfScoreboard/index.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/Components/Icons.tsx +16 -0
  43. package/src/GolfScoreboard/api/index.tsx +96 -2
  44. package/src/GolfScoreboard/components/LeaderBetSelector.tsx +192 -0
  45. package/src/GolfScoreboard/index.tsx +152 -18
  46. package/src/types.d.ts +30 -0
@@ -1,33 +1,52 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { Text, View } from "../Components/Themed"
3
- import type { AthleteProps, GolfCourseProps, GolfLeaderProps, LeagueProps, TournamentProps } from '../types';
2
+ import { Button, Text, View } from "../Components/Themed"
3
+ import type { AthleteProps, BestAvailableOrderProps, GolfCourseProps, GolfHoleProps, GolfLeaderProps, GolfTournamentStatisticsProps, LeagueProps, MarketProps, OrderProps, TournamentProps } from '../types';
4
4
  import { GolfApi, GolfHelpers } from './api';
5
5
  import { FlatList, Image } from 'react-native';
6
6
  import { useColors } from '../constants/useColors';
7
7
  import moment from 'moment-mini';
8
8
  import { AthleteImage } from '../Components/Jerseys';
9
+ import { Icons, Toggle } from '../Components';
10
+ import SearchBox from '../Components/SearchBox';
11
+ import LeaderBetSelector from './components/LeaderBetSelector';
9
12
 
10
13
  type GolfScoreboardProps = {
11
- tournament_id:string
14
+ tournament_id:string,
15
+ markets:MarketProps[],
16
+ best_available:BestAvailableOrderProps[],
17
+ onOrder:(order:OrderProps) => void
12
18
  }
13
19
 
14
- const scorecard_sections = ['course','leaderboard'];
15
- const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
20
+ const scorecard_sections = ['course', 'toggle','search','leaderboard', 'holes'];
21
+ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:GolfScoreboardProps) => {
16
22
  const Colors = useColors();
17
-
23
+ const [ active_tab, setActiveTab ] = useState<'scorecard'|'holes'>('scorecard');
24
+ const [ search, setSearch ] = useState<string>('');
25
+ const [ hole_details, setHoleDetails ] = useState<number | undefined>(undefined);
18
26
  const [ scorecard_state, setScorecard ] = useState<{
19
27
  loading:boolean,
20
28
  tournament?:TournamentProps,
21
29
  league?:LeagueProps,
22
30
  athletes:AthleteProps[],
23
31
  golf_leaders:GolfLeaderProps[],
24
- golf_course?:GolfCourseProps
32
+ golf_course?:GolfCourseProps,
33
+ golf_statistics?:GolfTournamentStatisticsProps,
34
+ active_round?:number
25
35
  }>({
26
36
  loading:false,
27
37
  golf_leaders:[],
28
38
  athletes:[]
29
39
  });
30
- const { loading, athletes, golf_leaders, golf_course, league } = scorecard_state;
40
+ const { loading, tournament, athletes, golf_leaders, golf_course, league, active_round, golf_statistics } = scorecard_state;
41
+ const [ active_leader, setActiveLeader ] = useState<string|undefined>(undefined);
42
+ const golf_leader = golf_leaders.find(l => l.athlete_id == active_leader);
43
+ const golf_athlete = athletes.find(a => a.athlete_id == active_leader);
44
+
45
+ let visible_leaders = [ ...golf_leaders ];
46
+ if(search){
47
+ let vis_athletes = athletes.filter(a => `${a.first_name} ${a.last_name}`.toLowerCase().includes(search.toLowerCase())).map(a => a.athlete_id);
48
+ visible_leaders = visible_leaders.filter(l => vis_athletes.includes(l.athlete_id));
49
+ }
31
50
 
32
51
  useEffect(() => {
33
52
  GolfApi.setEnvironment();
@@ -38,6 +57,7 @@ const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
38
57
  setScorecard({ ...scorecard_state, loading:true });
39
58
  const golf_data = await GolfApi.getScoreboard(tournament_id);
40
59
  const tourney = await GolfApi.getTournamentById(tournament_id);
60
+ const golf_stats = await GolfApi.getGolfStats(tournament_id);
41
61
  const lg = await GolfApi.getLeagueById(tourney?.league_id ?? '9');
42
62
  if(!golf_data){ return alert('Unable to process') }
43
63
  setScorecard({
@@ -46,6 +66,8 @@ const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
46
66
  league: lg,
47
67
  golf_course: golf_data.golf_course,
48
68
  golf_leaders: golf_data.golf_leaders,
69
+ golf_statistics: golf_stats,
70
+ active_round: golf_data.active_round,
49
71
  athletes:golf_data.athletes,
50
72
  loading: false
51
73
  })
@@ -58,11 +80,7 @@ const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
58
80
  return (
59
81
  <View style={{ borderBottomWidth:1, borderColor:Colors.borders.light }}>
60
82
  <View transparent type='row' style={{ padding:5 }}>
61
- {data.item.place != 999 ?
62
- <View transparent style={{ padding:10 }}>
63
- <Text theme='h2'>{GolfHelpers.formatPlace(data.item.place)}</Text>
64
- </View>
65
- :<></>}
83
+
66
84
  <View float style={{ borderRadius:100, padding:2, marginLeft:5 }}>
67
85
  <AthleteImage
68
86
  athlete={athlete}
@@ -78,18 +96,83 @@ const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
78
96
  <Text textAlign='right' theme='h2' color={data.item.score < 0 ? Colors.text.error : Colors.text.h1}>{data.item.score_label}</Text>
79
97
  {data.item.tee_time && current_round?.thru == 0 ?
80
98
  <Text textAlign='right' theme='description' style={{ marginTop:2 }}>{moment(data.item.tee_time).format('HH:mm a')}</Text>
99
+ :current_round && current_round?.thru > 0 ?
100
+ <Text textAlign='right' theme='description' style={{ marginTop:2 }}>Thru {current_round.thru}</Text>
81
101
  :<></>}
82
102
  </View>
83
- {current_round ?
84
- <View style={{ padding:5 }}>
85
- <Text>{current_round.thru > 0 ? current_round.thru : ''}</Text>
86
- </View>
103
+ {current_round && current_round.thru < 18 ?
104
+ <Button
105
+ title='BET'
106
+ type='success'
107
+ style={{ padding:10, marginLeft:10 }}
108
+ onPress={() => setActiveLeader(data.item.athlete_id)}
109
+ />
87
110
  :<></>}
88
111
  </View>
89
112
  </View>
90
113
  )
91
114
  }
92
115
 
116
+ const renderGolfers = (data:{ item:GolfLeaderProps, index:number }) => {
117
+ const athlete = athletes.find(a => a.athlete_id == data.item.athlete_id);
118
+ if(!athlete){ return <></> }
119
+ return (
120
+ <View float style={{ margin:4, width:120 }}>
121
+ <View type='header' style={{ borderTopRightRadius:8, borderTopLeftRadius:8, padding:5 }}>
122
+ <Text theme='h1'>{data.item.score_label}</Text>
123
+ </View>
124
+ <View transparent style={{ padding:10, flex:1 }}>
125
+ <AthleteImage
126
+ athlete={athlete}
127
+ size={24}
128
+ />
129
+ <Text style={{ marginTop:5 }} theme='h2' textAlign='center'>{athlete.first_name} {athlete.last_name}</Text>
130
+ </View>
131
+ <View type='footer' style={{ borderBottomLeftRadius:8, borderBottomRightRadius:8, padding:5 }}>
132
+ <Button
133
+ title='BET'
134
+ type='success'
135
+ style={{ padding:10 }}
136
+ onPress={() => setActiveLeader(data.item.athlete_id)}
137
+ />
138
+ </View>
139
+ </View>
140
+ )
141
+ }
142
+
143
+ const renderHoles = (data:{ item: GolfHoleProps, index:number }) => {
144
+ let golfers = GolfHelpers.getGolfersOnHole(golf_leaders, data.item.number, active_round);
145
+ let hole_stat = GolfHelpers.getHoleStats(data.item.number, golf_statistics, active_round);
146
+ const expanded = data.item.number == hole_details ? true : false
147
+ return (
148
+ <View>
149
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
150
+ <View transparent style={{ flex:1 }}>
151
+ <Text theme='h1'>Hole: {data.item.number}{data.item.name ? ` - ${data.item.name}`: ''} - Par {data.item.par}</Text>
152
+ {hole_stat ?
153
+ <Text theme='description' style={{ marginTop:3 }}>Stroke Avg {'\u2022'} {hole_stat.strokes_avg}{hole_stat?.previous_round ? hole_stat.previous_round: ''}</Text>
154
+ :<></>}
155
+ </View>
156
+ <Button float style={{ padding:5, flexDirection:'row', alignItems:'center', borderRadius:4 }} onPress={() => expanded ? setHoleDetails(undefined) : setHoleDetails(data.item.number)}>
157
+ <Icons.GolferIcon size={18} color={Colors.text.action}/>
158
+ <Text theme='action' size={18} style={{ marginLeft:5 }}>{golfers.length}</Text>
159
+ </Button>
160
+ </View>
161
+ {expanded ?
162
+ <View style={{ padding:10 }}>
163
+ <FlatList
164
+ key={'hole_golfer_list'}
165
+ data={golfers}
166
+ horizontal
167
+ renderItem={renderGolfers}
168
+ keyExtractor={(item) => `${data.item.number}_${item.athlete_id.toString()}`}
169
+ />
170
+ </View>
171
+ :<></>}
172
+ </View>
173
+ )
174
+ }
175
+
93
176
  const renderSections = (data:{ item:string, index:number }) => {
94
177
  switch(data.item){
95
178
  case 'course':
@@ -109,15 +192,51 @@ const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
109
192
  </View>
110
193
  </View>
111
194
  )
195
+ case 'toggle':
196
+ return (
197
+ <View style={{ padding:10 }}>
198
+ <Toggle
199
+ options={[
200
+ { key: 'scorecard', label: 'Leaderboard' },
201
+ { key: 'holes', label: 'Holes' }
202
+ ]}
203
+ selected_option={active_tab}
204
+ onSelectOption={(key) => setActiveTab(key as 'scorecard'|'holes')}
205
+ />
206
+ </View>
207
+ )
208
+ case 'search':
209
+ return (
210
+ <View style={{ padding:10 }}>
211
+ <SearchBox
212
+ hide_search_button
213
+ onChange={(text) => setSearch(text)}
214
+ />
215
+ </View>
216
+ )
112
217
  case 'leaderboard':
218
+ if(active_tab != 'scorecard'){ return <></> }
113
219
  return (
114
220
  <FlatList
115
- data={golf_leaders.sort((a,b) => a.place - b.place)}
221
+ data={visible_leaders.sort((a,b) => a.place - b.place)}
116
222
  keyExtractor={(item) => item.athlete_id.toString()}
223
+ windowSize={15}
224
+ maxToRenderPerBatch={15}
117
225
  renderItem={renderLeaders}
118
226
  key='leader_list'
119
227
  />
120
228
  )
229
+ case 'holes':
230
+ if(!golf_course){ return <></> }
231
+ if(active_tab != 'holes'){ return <></> }
232
+ return (
233
+ <FlatList
234
+ data={golf_course.holes.sort((a,b) => b.number - a.number)}
235
+ key={'hole_list'}
236
+ renderItem={renderHoles}
237
+ keyExtractor={(item) => item.number.toString()}
238
+ />
239
+ )
121
240
  default: return <></>
122
241
  }
123
242
  }
@@ -133,6 +252,21 @@ const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
133
252
  renderItem={renderSections}
134
253
  />
135
254
  </View>
255
+ {tournament && golf_leader && golf_course && active_round && golf_athlete ?
256
+ <LeaderBetSelector
257
+ golf_leader={golf_leader}
258
+ golf_course={golf_course}
259
+ markets={markets}
260
+ best_available_orders={best_available}
261
+ latest_trades={[]}
262
+ tournament={tournament}
263
+ active_round={active_round}
264
+ athlete={golf_athlete}
265
+ golf_statistics={golf_statistics}
266
+ onClose={() => setActiveLeader(undefined)}
267
+ onOrder={onOrder}
268
+ />
269
+ :<></>}
136
270
  </View>
137
271
  )
138
272
  }
package/src/types.d.ts CHANGED
@@ -100,6 +100,35 @@ export interface GolfRoundStatistics {
100
100
  hole_statistics: GolfHoleStatistics[]
101
101
  }
102
102
 
103
+ export interface GolfHoleStatistics {
104
+ round_number:number,
105
+ hole_number:number
106
+ par:number,
107
+ strokes: number,
108
+ players:number,
109
+ eagles:number,
110
+ birdies:number,
111
+ pars:number,
112
+ bogeys: number,
113
+ previous_round?:number,
114
+ double_bogeys:number,
115
+ holes_in_one: number,
116
+ other_scores:number,
117
+ strokes_avg:number,
118
+ avg_diff:number
119
+ }
120
+
121
+ export interface GolfTournamentStatisticsProps {
122
+ tournament_id:string,
123
+ round_statistics: GolfRoundStatistics[]
124
+ }
125
+
126
+ export interface GolfRoundStatistics {
127
+ tournament_id:string,
128
+ round_number: number,
129
+ hole_statistics: GolfHoleStatistics[]
130
+ }
131
+
103
132
  export interface GolfHoleStatistics {
104
133
  round_number:number,
105
134
  hole_number:number
@@ -1353,6 +1382,7 @@ export interface MarketProps {
1353
1382
  suggested?:boolean,
1354
1383
  var_1_required?:boolean;
1355
1384
  show_side_option?:boolean;
1385
+ length_variable?:number,
1356
1386
  resolver?:string;
1357
1387
  create_datetime: any;
1358
1388
  last_update_datetime: any;