be-components 5.5.6 → 5.5.7

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 (45) hide show
  1. package/lib/commonjs/Components/Icons.js +28 -0
  2. package/lib/commonjs/Components/Icons.js.map +1 -1
  3. package/lib/commonjs/GolfScoreboard/api/index.js +127 -0
  4. package/lib/commonjs/GolfScoreboard/api/index.js.map +1 -1
  5. package/lib/commonjs/GolfScoreboard/components/LeaderBetsList.js +241 -0
  6. package/lib/commonjs/GolfScoreboard/components/LeaderBetsList.js.map +1 -0
  7. package/lib/commonjs/GolfScoreboard/index.js +146 -4
  8. package/lib/commonjs/GolfScoreboard/index.js.map +1 -1
  9. package/lib/module/Components/Icons.js +28 -0
  10. package/lib/module/Components/Icons.js.map +1 -1
  11. package/lib/module/GolfScoreboard/api/index.js +127 -0
  12. package/lib/module/GolfScoreboard/api/index.js.map +1 -1
  13. package/lib/module/GolfScoreboard/components/LeaderBetsList.js +234 -0
  14. package/lib/module/GolfScoreboard/components/LeaderBetsList.js.map +1 -0
  15. package/lib/module/GolfScoreboard/index.js +146 -4
  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 +37 -0
  20. package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts.map +1 -1
  21. package/lib/typescript/lib/commonjs/GolfScoreboard/components/LeaderBetsList.d.ts +11 -0
  22. package/lib/typescript/lib/commonjs/GolfScoreboard/components/LeaderBetsList.d.ts.map +1 -0
  23. package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts +2 -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 +37 -0
  28. package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts.map +1 -1
  29. package/lib/typescript/lib/module/GolfScoreboard/components/LeaderBetsList.d.ts +11 -0
  30. package/lib/typescript/lib/module/GolfScoreboard/components/LeaderBetsList.d.ts.map +1 -0
  31. package/lib/typescript/lib/module/GolfScoreboard/index.d.ts +2 -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 +3 -1
  36. package/lib/typescript/src/GolfScoreboard/api/index.d.ts.map +1 -1
  37. package/lib/typescript/src/GolfScoreboard/components/LeaderBetsList.d.ts +13 -0
  38. package/lib/typescript/src/GolfScoreboard/components/LeaderBetsList.d.ts.map +1 -0
  39. package/lib/typescript/src/GolfScoreboard/index.d.ts +2 -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 +15 -0
  43. package/src/GolfScoreboard/api/index.tsx +99 -2
  44. package/src/GolfScoreboard/components/LeaderBetsList.tsx +117 -0
  45. package/src/GolfScoreboard/index.tsx +94 -4
@@ -12,8 +12,10 @@ import LeaderBetSelector from './components/LeaderBetSelector';
12
12
  import MarketButton from '../MarketComponents/components/MarketButton';
13
13
  import { MarketComponentHelpers } from '../MarketComponents/api';
14
14
  import { MarketButtonHelpers } from '../MarketComponents/components/MarketButton/api';
15
+ import LeaderBetsList from './components/LeaderBetsList';
15
16
 
16
17
  type GolfScoreboardProps = {
18
+ player_id?:string,
17
19
  tournament_id:string,
18
20
  markets:MarketProps[],
19
21
  best_available:BestAvailableOrderProps[],
@@ -21,11 +23,22 @@ type GolfScoreboardProps = {
21
23
  onClose:() => void
22
24
  }
23
25
 
24
- const scorecard_sections = ['course', 'toggle','search','leaderboard', 'open_bets', 'holes'];
25
- const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClose }:GolfScoreboardProps) => {
26
+ const scorecard_sections = ['course', 'my_action', 'toggle','search','leaderboard', 'open_bets', 'holes'];
27
+ const GolfScoreboard = ({ player_id, tournament_id, markets, best_available, onOrder, onClose }:GolfScoreboardProps) => {
26
28
  const Colors = useColors();
29
+ const [ module_width, setModuleWidth ] = useState(0);
27
30
  const [ active_tab, setActiveTab ] = useState<'scorecard'|'holes'|'bets'>('scorecard');
28
31
  const [ search, setSearch ] = useState<string>('');
32
+ const [ my_data, setMyData ] = useState<{
33
+ my_loading:boolean,
34
+ orders:OrderProps[]
35
+ }>({
36
+ my_loading: false,
37
+ orders: []
38
+ });
39
+ const { orders } = my_data;
40
+ let hole_orders = orders.filter(o => markets.filter(mk => mk.length_variable).map(mk => mk.market_id.toString()).includes(o.market_id.toString()));
41
+ const order_stats = GolfHelpers.calcAllOrderStats(hole_orders);
29
42
  const [ hole_details, setHoleDetails ] = useState<number | undefined>(undefined);
30
43
  const [ scorecard_state, setScorecard ] = useState<{
31
44
  loading:boolean,
@@ -45,6 +58,9 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
45
58
  });
46
59
  const { loading, tournament, athletes, golf_leaders, golf_course, league, active_round, golf_statistics, prior_year, loaded_timestamp } = scorecard_state;
47
60
  const [ active_leader, setActiveLeader ] = useState<string|undefined>(undefined);
61
+ const [ active_order_leader, setActiveOrderLeader ] = useState<string|undefined>(undefined);
62
+ const order_leader = golf_leaders.find(l => l.athlete_id == active_order_leader);
63
+ const order_athlete = athletes.find(a => a.athlete_id == active_order_leader);
48
64
  const golf_leader = golf_leaders.find(l => l.athlete_id == active_leader);
49
65
  const golf_athlete = athletes.find(a => a.athlete_id == active_leader);
50
66
 
@@ -80,8 +96,28 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
80
96
  loaded_timestamp: timestamp,
81
97
  loading: false
82
98
  });
99
+
100
+ if(player_id){
101
+ setMyData({ ...my_data, my_loading:true });
102
+ let my_action = await GolfApi.getMyAction(tournament_id, 'tournament');
103
+ //Override orders from the supplied array of orders
104
+ setMyData({
105
+ ...my_data,
106
+ my_loading: false,
107
+ orders: my_action
108
+ })
109
+
110
+ }
111
+
83
112
  return { golf_leaders : golf_data.golf_leaders, active_round: golf_data.active_round }
84
113
  }
114
+
115
+ const getColor = (earnings:number) => {
116
+ if(earnings < 0){ return Colors.text.error }
117
+ if(earnings == 0){ return Colors.text.descriptionLight }
118
+ return Colors.text.success
119
+ }
120
+
85
121
  const validateOrder = async(order:OrderProps, market:MarketProps, loaded?:Moment):Promise<boolean> => {
86
122
  if(!market || !market.length_variable){ return false }
87
123
  let difference = 100
@@ -109,10 +145,16 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
109
145
  const athlete = athletes.find(a => a.athlete_id == data.item.athlete_id);
110
146
  if(!athlete){ return <></> }
111
147
  let current_round = data.item.leader_rounds.find(r => r.status == 'inprogress');
148
+ let leader_orders = hole_orders.filter(o => o.side_id == data.item.athlete_id);
149
+ let order_stats = GolfHelpers.calcAllOrderStats(leader_orders);
112
150
  return (
113
151
  <View style={{ borderBottomWidth:1, borderColor:Colors.borders.light }}>
114
152
  <View transparent type='row' style={{ padding:5 }}>
115
-
153
+ {data.item.place != 999 ?
154
+ <View style={{ padding:5 }}>
155
+ <Text theme='description'>{GolfHelpers.formatPlace(data.item.place)}</Text>
156
+ </View>
157
+ :<></>}
116
158
  <View float style={{ borderRadius:100, padding:2, marginLeft:5 }}>
117
159
  <AthleteImage
118
160
  athlete={athlete}
@@ -124,6 +166,12 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
124
166
  <Text theme='h2'>{athlete.first_name} {athlete.last_name}</Text>
125
167
  <Text theme='description' style={{ marginTop:3 }}>World Rank: {data.item.rank == 999 ? 'NA' : data.item.rank}</Text>
126
168
  </View>
169
+ {leader_orders.length > 0 ?
170
+ <Button float style={{ padding:10, marginRight:10, marginLeft:10, flexDirection:'row', alignItems:'center' }} onPress={() => setActiveOrderLeader(data.item.athlete_id)}>
171
+ <Icons.OrderIcon color={getColor(order_stats.earnings)} size={18}/>
172
+ <Text theme='description' style={{ marginLeft:3 }} color={getColor(order_stats.earnings)}>${order_stats.earnings.toFixed(2)}</Text>
173
+ </Button>
174
+ :<></>}
127
175
  <View>
128
176
  <Text textAlign='right' theme='h2' color={data.item.score < 0 ? Colors.text.error : Colors.text.h1}>{data.item.score_label}</Text>
129
177
  {data.item.tee_time && current_round?.thru == 0 ?
@@ -278,6 +326,34 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
278
326
  </View>
279
327
  </View>
280
328
  )
329
+ case 'my_action':
330
+ if(module_width == 0){ return <></> }
331
+ if(hole_orders.length == 0){ return <></> }
332
+ let padding = (3 * 10) + 20
333
+
334
+ const kpi_card_width = ((module_width - padding) / 3)
335
+ return (
336
+ <View>
337
+ <View style={{ padding:10 }}>
338
+ <Text theme='h1'>My Hole By Hole Action</Text>
339
+ </View>
340
+ <View style={{ flexDirection:'row', padding:10 }}>
341
+ <View float style={{ margin:5, padding:10, width:kpi_card_width }}>
342
+ <Text theme='h1'>${(order_stats.resolved_stake+order_stats.unresolved_stake).toFixed(2)}</Text>
343
+ <Text theme='description' style={{ marginTop:5 }}>Total Bet</Text>
344
+ </View>
345
+ <View float style={{ margin:5, padding:10, width:kpi_card_width }}>
346
+ <Text theme='h1'>${order_stats.unresolved_stake.toFixed(2)}</Text>
347
+ <Text theme='description' style={{ marginTop:5 }}>Unresolved Bets</Text>
348
+ </View>
349
+ <View float style={{ margin:5, padding:10, width:kpi_card_width }}>
350
+ <Text theme='h1' color={getColor(order_stats.earnings)}>${order_stats.earnings.toFixed(2)}</Text>
351
+ <Text theme='description' style={{ marginTop:5 }} color={getColor(order_stats.earnings)}>Earnings</Text>
352
+ </View>
353
+ </View>
354
+
355
+ </View>
356
+ )
281
357
  case 'toggle':
282
358
  return (
283
359
  <View style={{ padding:10 }}>
@@ -345,7 +421,10 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
345
421
  }
346
422
  return (
347
423
  <View style={{ flex:1 }}>
348
- <View style={{ flex:1 }}>
424
+ <View style={{ flex:1 }} onLayout={(ev) => {
425
+ const { width } = ev.nativeEvent.layout
426
+ setModuleWidth(width);
427
+ }}>
349
428
  {loading ?
350
429
  <ActivityIndicator
351
430
  style={{ padding:10, alignSelf:'center' }}
@@ -370,6 +449,17 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClo
370
449
  onPress={() => onClose()}
371
450
  />
372
451
  </View>
452
+ {tournament && order_leader && order_athlete ?
453
+ <LeaderBetsList
454
+ markets={markets}
455
+ orders={hole_orders}
456
+ active_round={active_round}
457
+ golf_leader={order_leader}
458
+ athlete={order_athlete}
459
+ onClose={() => setActiveOrderLeader(undefined)}
460
+
461
+ />
462
+ :<></>}
373
463
  {tournament && golf_leader && golf_course && active_round && golf_athlete ?
374
464
  <LeaderBetSelector
375
465
  golf_leader={golf_leader}