be-components 5.5.0 → 5.5.1
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.
- package/lib/commonjs/GolfScoreboard/api/index.js +48 -2
- package/lib/commonjs/GolfScoreboard/api/index.js.map +1 -1
- package/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.js +13 -3
- package/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.js.map +1 -1
- package/lib/commonjs/GolfScoreboard/index.js +76 -11
- package/lib/commonjs/GolfScoreboard/index.js.map +1 -1
- package/lib/commonjs/MarketComponents/api/index.js +9 -0
- package/lib/commonjs/MarketComponents/api/index.js.map +1 -1
- package/lib/module/GolfScoreboard/api/index.js +48 -2
- package/lib/module/GolfScoreboard/api/index.js.map +1 -1
- package/lib/module/GolfScoreboard/components/LeaderBetSelector.js +13 -3
- package/lib/module/GolfScoreboard/components/LeaderBetSelector.js.map +1 -1
- package/lib/module/GolfScoreboard/index.js +76 -11
- package/lib/module/GolfScoreboard/index.js.map +1 -1
- package/lib/module/MarketComponents/api/index.js +9 -0
- package/lib/module/MarketComponents/api/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts +22 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.d.ts +2 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/components/LeaderBetSelector.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts +2 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/MarketComponents/api/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/MarketComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts +22 -1
- package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/GolfScoreboard/components/LeaderBetSelector.d.ts +2 -1
- package/lib/typescript/lib/module/GolfScoreboard/components/LeaderBetSelector.d.ts.map +1 -1
- package/lib/typescript/lib/module/GolfScoreboard/index.d.ts +2 -1
- package/lib/typescript/lib/module/GolfScoreboard/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/MarketComponents/api/index.d.ts +1 -0
- package/lib/typescript/lib/module/MarketComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/GolfScoreboard/api/index.d.ts +8 -3
- package/lib/typescript/src/GolfScoreboard/api/index.d.ts.map +1 -1
- package/lib/typescript/src/GolfScoreboard/components/LeaderBetSelector.d.ts +2 -1
- package/lib/typescript/src/GolfScoreboard/components/LeaderBetSelector.d.ts.map +1 -1
- package/lib/typescript/src/GolfScoreboard/index.d.ts +2 -1
- package/lib/typescript/src/GolfScoreboard/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketComponents/api/index.d.ts +3 -2
- package/lib/typescript/src/MarketComponents/api/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/GolfScoreboard/api/index.tsx +43 -5
- package/src/GolfScoreboard/components/LeaderBetSelector.tsx +14 -5
- package/src/GolfScoreboard/index.tsx +60 -14
- package/src/MarketComponents/api/index.ts +11 -2
- package/src/types.d.ts +3 -1
|
@@ -4,7 +4,7 @@ import type { AthleteProps, BestAvailableOrderProps, GolfCourseProps, GolfHolePr
|
|
|
4
4
|
import { GolfApi, GolfHelpers } from './api';
|
|
5
5
|
import { ActivityIndicator, FlatList, Image } from 'react-native';
|
|
6
6
|
import { useColors } from '../constants/useColors';
|
|
7
|
-
import moment from 'moment-mini';
|
|
7
|
+
import moment, { type Moment } from 'moment-mini';
|
|
8
8
|
import { AthleteImage } from '../Components/Jerseys';
|
|
9
9
|
import { Icons, Toggle } from '../Components';
|
|
10
10
|
import SearchBox from '../Components/SearchBox';
|
|
@@ -17,11 +17,12 @@ type GolfScoreboardProps = {
|
|
|
17
17
|
tournament_id:string,
|
|
18
18
|
markets:MarketProps[],
|
|
19
19
|
best_available:BestAvailableOrderProps[],
|
|
20
|
-
onOrder:(order:OrderProps) => void
|
|
20
|
+
onOrder:(order:OrderProps) => void,
|
|
21
|
+
onClose:() => void
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const scorecard_sections = ['course', 'toggle','search','leaderboard', 'open_bets', 'holes'];
|
|
24
|
-
const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:GolfScoreboardProps) => {
|
|
25
|
+
const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder, onClose }:GolfScoreboardProps) => {
|
|
25
26
|
const Colors = useColors();
|
|
26
27
|
const [ active_tab, setActiveTab ] = useState<'scorecard'|'holes'|'bets'>('scorecard');
|
|
27
28
|
const [ search, setSearch ] = useState<string>('');
|
|
@@ -31,16 +32,18 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:Golf
|
|
|
31
32
|
tournament?:TournamentProps,
|
|
32
33
|
league?:LeagueProps,
|
|
33
34
|
athletes:AthleteProps[],
|
|
35
|
+
prior_year?:boolean,
|
|
34
36
|
golf_leaders:GolfLeaderProps[],
|
|
35
37
|
golf_course?:GolfCourseProps,
|
|
36
38
|
golf_statistics?:GolfTournamentStatisticsProps,
|
|
37
|
-
active_round?:number
|
|
39
|
+
active_round?:number,
|
|
40
|
+
loaded_timestamp?:Moment
|
|
38
41
|
}>({
|
|
39
42
|
loading:false,
|
|
40
43
|
golf_leaders:[],
|
|
41
44
|
athletes:[]
|
|
42
45
|
});
|
|
43
|
-
const { loading, tournament, athletes, golf_leaders, golf_course, league, active_round, golf_statistics } = scorecard_state;
|
|
46
|
+
const { loading, tournament, athletes, golf_leaders, golf_course, league, active_round, golf_statistics, prior_year, loaded_timestamp } = scorecard_state;
|
|
44
47
|
const [ active_leader, setActiveLeader ] = useState<string|undefined>(undefined);
|
|
45
48
|
const golf_leader = golf_leaders.find(l => l.athlete_id == active_leader);
|
|
46
49
|
const golf_athlete = athletes.find(a => a.athlete_id == active_leader);
|
|
@@ -53,16 +56,16 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:Golf
|
|
|
53
56
|
|
|
54
57
|
useEffect(() => {
|
|
55
58
|
GolfApi.setEnvironment();
|
|
56
|
-
getData(tournament_id)
|
|
59
|
+
getData(tournament_id, moment())
|
|
57
60
|
},[tournament_id]);
|
|
58
61
|
|
|
59
|
-
const getData = async(tournament_id:string) => {
|
|
62
|
+
const getData = async(tournament_id:string, timestamp:Moment):Promise<{ golf_leaders:GolfLeaderProps[], active_round?:number } | undefined> => {
|
|
60
63
|
setScorecard({ ...scorecard_state, loading:true });
|
|
61
64
|
const golf_data = await GolfApi.getScoreboard(tournament_id);
|
|
62
65
|
const tourney = await GolfApi.getTournamentById(tournament_id);
|
|
63
66
|
const golf_stats = await GolfApi.getGolfStats(tournament_id);
|
|
64
67
|
const lg = await GolfApi.getLeagueById(tourney?.league_id ?? '9');
|
|
65
|
-
if(!golf_data){ return
|
|
68
|
+
if(!golf_data){ return undefined }
|
|
66
69
|
if(best_available.length > 0){ setActiveTab('bets') }
|
|
67
70
|
setScorecard({
|
|
68
71
|
...scorecard_state,
|
|
@@ -70,11 +73,36 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:Golf
|
|
|
70
73
|
league: lg,
|
|
71
74
|
golf_course: golf_data.golf_course,
|
|
72
75
|
golf_leaders: golf_data.golf_leaders,
|
|
73
|
-
golf_statistics: golf_stats,
|
|
76
|
+
golf_statistics: golf_stats?.golf_tournament_statistics,
|
|
77
|
+
prior_year: golf_stats?.prior_year,
|
|
74
78
|
active_round: golf_data.active_round,
|
|
75
79
|
athletes:golf_data.athletes,
|
|
80
|
+
loaded_timestamp: timestamp,
|
|
76
81
|
loading: false
|
|
77
|
-
})
|
|
82
|
+
});
|
|
83
|
+
return { golf_leaders : golf_data.golf_leaders, active_round: golf_data.active_round }
|
|
84
|
+
}
|
|
85
|
+
const validateOrder = async(order:OrderProps, market:MarketProps, loaded?:Moment):Promise<boolean> => {
|
|
86
|
+
if(!market || !market.length_variable){ return false }
|
|
87
|
+
let difference = 100
|
|
88
|
+
if(loaded){
|
|
89
|
+
difference = moment().diff(loaded,'seconds')
|
|
90
|
+
}
|
|
91
|
+
if(difference > 90){
|
|
92
|
+
//We need to load the data again and confirm that the bet is valid!
|
|
93
|
+
let reloaded_data = await getData(order.event_id, moment());
|
|
94
|
+
if(!reloaded_data){ return false }
|
|
95
|
+
let leader = reloaded_data.golf_leaders.find(gl => gl.athlete_id == order.side_id);
|
|
96
|
+
if(!leader){ return false }
|
|
97
|
+
let curr_hole = GolfHelpers.getCurrentHole(leader, reloaded_data.active_round);
|
|
98
|
+
//if(curr_hole == 0){ return true }
|
|
99
|
+
let bet_hole = market.length_variable
|
|
100
|
+
let hole_buffer = bet_hole - curr_hole
|
|
101
|
+
if(hole_buffer < 2){
|
|
102
|
+
return false
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return true
|
|
78
106
|
}
|
|
79
107
|
|
|
80
108
|
const renderLeaders = (data:{ item:GolfLeaderProps, index:number }) => {
|
|
@@ -157,10 +185,13 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:Golf
|
|
|
157
185
|
locked={false}
|
|
158
186
|
order={data.item}
|
|
159
187
|
onLongPress={() => console.log('LONG PRESSED')}
|
|
160
|
-
onPress={(order) => {
|
|
188
|
+
onPress={async(order) => {
|
|
161
189
|
const order_title = MarketComponentHelpers.getOrderTitleForTournament(order, market, tournament, athlete);
|
|
162
190
|
if(!order_title){ return alert('Unable to process order') }
|
|
163
|
-
|
|
191
|
+
let new_order = { ...order, title:order_title, league_id:tournament.league_id }
|
|
192
|
+
const valid = await validateOrder(new_order, market, loaded_timestamp)
|
|
193
|
+
if(!valid){ return alert('Unable to process order') }
|
|
194
|
+
onOrder(new_order)
|
|
164
195
|
}}
|
|
165
196
|
/>
|
|
166
197
|
</View>
|
|
@@ -326,11 +357,19 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:Golf
|
|
|
326
357
|
data={scorecard_sections}
|
|
327
358
|
key={'golf_list'}
|
|
328
359
|
refreshing={loading}
|
|
329
|
-
onRefresh={() => getData(tournament_id)}
|
|
360
|
+
onRefresh={() => getData(tournament_id, moment())}
|
|
330
361
|
keyExtractor={item => item}
|
|
331
362
|
renderItem={renderSections}
|
|
332
363
|
/>
|
|
333
364
|
</View>
|
|
365
|
+
<View type='footer' style={{ padding:10 }}>
|
|
366
|
+
<Button
|
|
367
|
+
title='CLOSE'
|
|
368
|
+
type='close'
|
|
369
|
+
style={{ padding:10 }}
|
|
370
|
+
onPress={() => onClose()}
|
|
371
|
+
/>
|
|
372
|
+
</View>
|
|
334
373
|
{tournament && golf_leader && golf_course && active_round && golf_athlete ?
|
|
335
374
|
<LeaderBetSelector
|
|
336
375
|
golf_leader={golf_leader}
|
|
@@ -340,10 +379,17 @@ const GolfScoreboard = ({ tournament_id, markets, best_available, onOrder }:Golf
|
|
|
340
379
|
latest_trades={[]}
|
|
341
380
|
tournament={tournament}
|
|
342
381
|
active_round={active_round}
|
|
382
|
+
prior_year={prior_year}
|
|
343
383
|
athlete={golf_athlete}
|
|
344
384
|
golf_statistics={golf_statistics}
|
|
345
385
|
onClose={() => setActiveLeader(undefined)}
|
|
346
|
-
onOrder={
|
|
386
|
+
onOrder={async(order) => {
|
|
387
|
+
let market = markets.find(m => m.market_id == order.market_id);
|
|
388
|
+
if(!market){ return alert('Unable to process') }
|
|
389
|
+
const valid = await validateOrder(order, market, loaded_timestamp);
|
|
390
|
+
if(!valid){ return alert('Unable to process this order') }
|
|
391
|
+
onOrder(order)
|
|
392
|
+
}}
|
|
347
393
|
/>
|
|
348
394
|
:<></>}
|
|
349
395
|
</View>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { APIOverrides } from "../../ApiOverrides"
|
|
3
|
-
import type { AthleteProps, BestAvailableResponseProps, ContestStatProps, EventOrderStatProps, EventProps, ExternalPriceProps, LeagueProps, MarketProps, MarketSideOptionProps, MatchProps, OrderProps, PodcastProps, TeamProps, TournamentProps, TradeProps } from "../../types"
|
|
3
|
+
import type { AthleteProps, BestAvailableOrderProps, BestAvailableResponseProps, ContestStatProps, EventOrderStatProps, EventProps, ExternalPriceProps, LeagueProps, MarketProps, MarketSideOptionProps, MatchProps, OrderProps, PodcastProps, TeamProps, TournamentProps, TradeProps } from "../../types"
|
|
4
4
|
import moment from 'moment-mini';
|
|
5
5
|
|
|
6
6
|
let EVENT_SVC_API = ''
|
|
@@ -217,6 +217,15 @@ const MarketComponentHelpers = {
|
|
|
217
217
|
let open_order_count = event_order_stats.reduce((a,b) => a + parseInt(b.open_order_count as string), 0);
|
|
218
218
|
return { liquidity, open_order_count }
|
|
219
219
|
},
|
|
220
|
+
calcPotentialWinnings : (amt:number, odds:number):number => {
|
|
221
|
+
if (odds > 0) {
|
|
222
|
+
var earningsMultiplyer = ((odds/100) + 1);
|
|
223
|
+
return earningsMultiplyer * amt;
|
|
224
|
+
} else {
|
|
225
|
+
var earningsMultiplyer = ((100/(Math.abs(odds))) + 1);
|
|
226
|
+
return earningsMultiplyer * amt
|
|
227
|
+
}
|
|
228
|
+
},
|
|
220
229
|
getVar1Label: (market:MarketProps, var_1:number, side?:string) => {
|
|
221
230
|
if(side == 'over'){ return `O ${var_1}` }
|
|
222
231
|
if(side == 'under'){ return `U ${var_1}` }
|
|
@@ -367,7 +376,7 @@ const MarketComponentHelpers = {
|
|
|
367
376
|
})
|
|
368
377
|
return new_title
|
|
369
378
|
},
|
|
370
|
-
getOrderTitleForTournament : (order:OrderProps, market:MarketProps, tournament:TournamentProps, athlete?:AthleteProps, team?:TeamProps):string | undefined => {
|
|
379
|
+
getOrderTitleForTournament : (order:OrderProps | BestAvailableOrderProps, market:MarketProps, tournament:TournamentProps, athlete?:AthleteProps, team?:TeamProps):string | undefined => {
|
|
371
380
|
if(!tournament){ return undefined }
|
|
372
381
|
let market_side = market.side_options.find(o => o.side == order.side)
|
|
373
382
|
if(!market_side){ return order.side }
|
package/src/types.d.ts
CHANGED
|
@@ -1381,6 +1381,8 @@ export interface MarketProps {
|
|
|
1381
1381
|
primary_market:boolean,
|
|
1382
1382
|
suggested?:boolean,
|
|
1383
1383
|
var_1_required?:boolean;
|
|
1384
|
+
lock_probability?:boolean,
|
|
1385
|
+
max_order?:number,
|
|
1384
1386
|
show_side_option?:boolean;
|
|
1385
1387
|
length_variable?:number,
|
|
1386
1388
|
resolver?:string;
|
|
@@ -2044,7 +2046,7 @@ export interface BestAvailableOrderProps {
|
|
|
2044
2046
|
show?:boolean,
|
|
2045
2047
|
potential_winnings:number,
|
|
2046
2048
|
reversed?:boolean,
|
|
2047
|
-
og_order
|
|
2049
|
+
og_order?:BestAvailableOrderProps,
|
|
2048
2050
|
side_id:string,
|
|
2049
2051
|
side_type:string,
|
|
2050
2052
|
var_1:number,
|