be-components 2.4.7 → 2.4.8
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/LocationTracker/LocationStatus.js.map +1 -1
- package/lib/commonjs/LocationTracker/api/index.js +14 -0
- package/lib/commonjs/LocationTracker/api/index.js.map +1 -1
- package/lib/commonjs/MarketMaker/api/index.js +240 -0
- package/lib/commonjs/MarketMaker/api/index.js.map +1 -0
- package/lib/commonjs/MarketMaker/components/Contest.js +75 -0
- package/lib/commonjs/MarketMaker/components/Contest.js.map +1 -0
- package/lib/commonjs/MarketMaker/components/ContestMarkets.js +19 -0
- package/lib/commonjs/MarketMaker/components/ContestMarkets.js.map +1 -0
- package/lib/commonjs/MarketMaker/components/ContestSelector.js +111 -0
- package/lib/commonjs/MarketMaker/components/ContestSelector.js.map +1 -0
- package/lib/commonjs/MarketMaker/components/Dashboard.js +105 -0
- package/lib/commonjs/MarketMaker/components/Dashboard.js.map +1 -0
- package/lib/commonjs/MarketMaker/components/MarketSelector.js +81 -0
- package/lib/commonjs/MarketMaker/components/MarketSelector.js.map +1 -0
- package/lib/commonjs/MarketMaker/index.js +191 -0
- package/lib/commonjs/MarketMaker/index.js.map +1 -0
- package/lib/commonjs/SocialComponents/api/index.js +0 -1
- package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.d.js +4 -0
- package/lib/module/LocationTracker/LocationStatus.js.map +1 -1
- package/lib/module/LocationTracker/api/index.js +14 -0
- package/lib/module/LocationTracker/api/index.js.map +1 -1
- package/lib/module/MarketMaker/api/index.js +234 -0
- package/lib/module/MarketMaker/api/index.js.map +1 -0
- package/lib/module/MarketMaker/components/Contest.js +68 -0
- package/lib/module/MarketMaker/components/Contest.js.map +1 -0
- package/lib/module/MarketMaker/components/ContestMarkets.js +12 -0
- package/lib/module/MarketMaker/components/ContestMarkets.js.map +1 -0
- package/lib/module/MarketMaker/components/ContestSelector.js +102 -0
- package/lib/module/MarketMaker/components/ContestSelector.js.map +1 -0
- package/lib/module/MarketMaker/components/Dashboard.js +98 -0
- package/lib/module/MarketMaker/components/Dashboard.js.map +1 -0
- package/lib/module/MarketMaker/components/MarketSelector.js +74 -0
- package/lib/module/MarketMaker/components/MarketSelector.js.map +1 -0
- package/lib/module/MarketMaker/index.js +182 -0
- package/lib/module/MarketMaker/index.js.map +1 -0
- package/lib/module/SocialComponents/api/index.js +0 -1
- package/lib/module/SocialComponents/api/index.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.d.js +1 -1
- package/lib/typescript/src/LocationTracker/LocationStatus.d.ts.map +1 -1
- package/lib/typescript/src/LocationTracker/api/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/api/index.d.ts +28 -0
- package/lib/typescript/src/MarketMaker/api/index.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/components/Contest.d.ts +16 -0
- package/lib/typescript/src/MarketMaker/components/Contest.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts +13 -0
- package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/components/ContestSelector.d.ts +19 -0
- package/lib/typescript/src/MarketMaker/components/ContestSelector.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts +16 -0
- package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/components/MarketSelector.d.ts +12 -0
- package/lib/typescript/src/MarketMaker/components/MarketSelector.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/index.d.ts +7 -0
- package/lib/typescript/src/MarketMaker/index.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/LocationTracker/LocationStatus.tsx +0 -1
- package/src/LocationTracker/api/index.tsx +16 -0
- package/src/MarketMaker/api/index.ts +178 -0
- package/src/MarketMaker/components/Contest.tsx +70 -0
- package/src/MarketMaker/components/ContestMarkets.tsx +24 -0
- package/src/MarketMaker/components/ContestSelector.tsx +84 -0
- package/src/MarketMaker/components/Dashboard.tsx +72 -0
- package/src/MarketMaker/components/MarketSelector.tsx +50 -0
- package/src/MarketMaker/index.tsx +175 -0
- package/src/SocialComponents/api/index.ts +0 -1
- package/src/index.tsx +2 -1
- package/src/types.d.ts +12 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { MarketMakerApi, MarketMaketHelpers } from './api';
|
|
4
|
+
import type { BestAvailableResponseProps, EventProps, ExternalPriceProps, LeagueProps, MarketProps, MatchProps, OrderProps, TournamentProps, TradeProps } from '../types';
|
|
5
|
+
import { view_styles } from '../constants/styles';
|
|
6
|
+
import Colors from '../constants/colors';
|
|
7
|
+
import ContestSelector from './components/ContestSelector';
|
|
8
|
+
import Dashboard from './components/Dashboard';
|
|
9
|
+
import MarketSelector from './components/MarketSelector';
|
|
10
|
+
|
|
11
|
+
type MarketMakerProps = {
|
|
12
|
+
player_id:string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const MarketMaker = ({}:MarketMakerProps) => {
|
|
16
|
+
const [ module_data, setModuleData ] = useState<{
|
|
17
|
+
loaded:boolean,
|
|
18
|
+
loading:boolean,
|
|
19
|
+
markets:MarketProps[],
|
|
20
|
+
leagues:LeagueProps[],
|
|
21
|
+
events:EventProps[],
|
|
22
|
+
tournaments:TournamentProps[],
|
|
23
|
+
matches:MatchProps[],
|
|
24
|
+
}>({
|
|
25
|
+
loaded: false,
|
|
26
|
+
loading:false,
|
|
27
|
+
leagues:[],
|
|
28
|
+
markets:[],
|
|
29
|
+
events:[],
|
|
30
|
+
tournaments:[],
|
|
31
|
+
matches:[]
|
|
32
|
+
});
|
|
33
|
+
const { leagues, events, markets } = module_data;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const [ dash_data, setDashData ] = useState<{
|
|
37
|
+
loaded:boolean,
|
|
38
|
+
loading:boolean,
|
|
39
|
+
best_available:BestAvailableResponseProps,
|
|
40
|
+
selected_markets:MarketProps[],
|
|
41
|
+
orders:OrderProps[],
|
|
42
|
+
selected_events:EventProps[],
|
|
43
|
+
trades:TradeProps[],
|
|
44
|
+
external_prices:ExternalPriceProps[],
|
|
45
|
+
selected_tournaments:TournamentProps[],
|
|
46
|
+
selected_matches:MatchProps[]
|
|
47
|
+
}>({
|
|
48
|
+
loaded:false,
|
|
49
|
+
loading:false,
|
|
50
|
+
selected_markets:[],
|
|
51
|
+
best_available: { events: [], tournaments: [], matches: [] },
|
|
52
|
+
orders:[],
|
|
53
|
+
trades:[],
|
|
54
|
+
external_prices: [],
|
|
55
|
+
selected_events:[],
|
|
56
|
+
selected_matches:[],
|
|
57
|
+
selected_tournaments:[]
|
|
58
|
+
});
|
|
59
|
+
const { selected_events, selected_matches, selected_tournaments, selected_markets, trades, external_prices, best_available, orders } = dash_data;
|
|
60
|
+
const { available_orders } = MarketMaketHelpers.getMarketDataFromBestAvailable(best_available);
|
|
61
|
+
const selectable_markets = MarketMaketHelpers.getSelectableMarkets(selected_events, selected_tournaments, selected_matches, markets);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
MarketMakerApi.setEnvironment();
|
|
65
|
+
loadModule();
|
|
66
|
+
},[]);
|
|
67
|
+
|
|
68
|
+
const loadModule = async() => {
|
|
69
|
+
setModuleData({ ...module_data, loading:true });
|
|
70
|
+
setDashData({ ...dash_data, loading:true });
|
|
71
|
+
|
|
72
|
+
const evs = await MarketMakerApi.getActiveEvents();
|
|
73
|
+
const mks = await MarketMakerApi.getMarkets();
|
|
74
|
+
const ls = await MarketMakerApi.getLeagues();
|
|
75
|
+
setModuleData({
|
|
76
|
+
...module_data,
|
|
77
|
+
events:evs,
|
|
78
|
+
loaded:true,
|
|
79
|
+
loading:false,
|
|
80
|
+
markets:mks,
|
|
81
|
+
leagues:ls,
|
|
82
|
+
});
|
|
83
|
+
//Now load Dash data
|
|
84
|
+
const ba = await MarketMakerApi.getBestAvailableOrders();
|
|
85
|
+
const my_action = await MarketMakerApi.getMyAction();
|
|
86
|
+
const my_action_data = await getDataForMyAction(my_action, mks);
|
|
87
|
+
//Based on my action -- lets auto select events and grab all that data!!
|
|
88
|
+
|
|
89
|
+
setDashData({
|
|
90
|
+
...dash_data,
|
|
91
|
+
loaded:true,
|
|
92
|
+
loading:false,
|
|
93
|
+
best_available: ba,
|
|
94
|
+
orders:my_action,
|
|
95
|
+
selected_events: my_action_data.events,
|
|
96
|
+
trades: my_action_data.trades,
|
|
97
|
+
selected_markets: my_action_data.markets
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const getDataForMyAction = async(orders:OrderProps[], markets:MarketProps[]) => {
|
|
102
|
+
const ev_ids = orders.filter(o => o.event_type == 'team').map(o => o.event_id);
|
|
103
|
+
const mks = markets.filter(m => orders.map(o => o.market_id.toString()).includes(m.market_id.toString()))
|
|
104
|
+
const evs = await MarketMakerApi.getEventsByEventIds(ev_ids);
|
|
105
|
+
const ts = await MarketMakerApi.getLatestTradesByEvents('team', ev_ids)
|
|
106
|
+
return { events:evs, trades:ts, markets:mks }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const handleSelectEvent = async(e:EventProps) => {
|
|
110
|
+
if(dash_data.loading){ return }//No mashy
|
|
111
|
+
setDashData({ ...dash_data, loading: true });
|
|
112
|
+
const prices = await MarketMakerApi.getPricesByEvent(e.event_id, 'team');
|
|
113
|
+
const tds = await MarketMakerApi.getLatestTradesByEvents('team', [e.event_id]);
|
|
114
|
+
setDashData({
|
|
115
|
+
...dash_data,
|
|
116
|
+
loading:false,
|
|
117
|
+
selected_events: selected_events.concat(e),
|
|
118
|
+
trades: trades.filter(t => t.event_id != e.event_id).concat(tds),
|
|
119
|
+
external_prices: external_prices.filter(p => p.event_id != e.event_id).concat(prices)
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const handleDeselectEvent = (e:EventProps) => {
|
|
124
|
+
if(dash_data.loading){ return }//No mashy
|
|
125
|
+
setDashData({
|
|
126
|
+
...dash_data,
|
|
127
|
+
loading:false,
|
|
128
|
+
selected_events: selected_events.filter(se => se.event_id != e.event_id),
|
|
129
|
+
trades: trades.filter(t => t.event_id != e.event_id)
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<View style={{ flex:1, backgroundColor:Colors.shades.white }}>
|
|
135
|
+
<View style={{ ...view_styles.wrapper }}>
|
|
136
|
+
<View>
|
|
137
|
+
<ContestSelector
|
|
138
|
+
maxHeight={300}
|
|
139
|
+
leagues={leagues.filter(l => l.status == 'active')}
|
|
140
|
+
events={events}
|
|
141
|
+
onSelectEvent={(e) => handleSelectEvent(e)}
|
|
142
|
+
onDeselectEvent={(e) => handleDeselectEvent(e)}
|
|
143
|
+
onSelectMatch={(m) => console.log(m)}
|
|
144
|
+
onSelectTournament={(t) => console.log(t)}
|
|
145
|
+
tournaments={[]}
|
|
146
|
+
matches={[]}
|
|
147
|
+
selected_events={selected_events.map(e => e.event_id)}
|
|
148
|
+
selected_matches={[]}
|
|
149
|
+
selected_tournaments={[]}
|
|
150
|
+
/>
|
|
151
|
+
<MarketSelector
|
|
152
|
+
maxHeight={300}
|
|
153
|
+
markets={selectable_markets.sort((a,b) => parseInt(a.market_id) - parseInt(b.market_id))}
|
|
154
|
+
onSelectMarket={(m) => setDashData({ ...dash_data, selected_markets: dash_data.selected_markets.concat(m) })}
|
|
155
|
+
onDeselectMarket={(m) => setDashData({ ...dash_data, selected_markets: dash_data.selected_markets.filter(se => se.market_id != m.market_id) })}
|
|
156
|
+
selected_markets={selected_markets.map(m => m.market_id)}
|
|
157
|
+
/>
|
|
158
|
+
</View>
|
|
159
|
+
<Dashboard
|
|
160
|
+
loaded={dash_data.loaded}
|
|
161
|
+
leagues={leagues}
|
|
162
|
+
events={selected_events}
|
|
163
|
+
tournaments={selected_tournaments}
|
|
164
|
+
matches={selected_matches}
|
|
165
|
+
markets={selected_markets}
|
|
166
|
+
best_available_orders={available_orders}
|
|
167
|
+
trades={trades}
|
|
168
|
+
orders={orders}
|
|
169
|
+
/>
|
|
170
|
+
</View>
|
|
171
|
+
</View>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export default MarketMaker
|
|
@@ -134,7 +134,6 @@ const SocialComponentApi = {
|
|
|
134
134
|
startPodcastEpisode: async(podcast_episode_id:string):Promise<undefined | { player_podcast:PlayerPodcastProps, player_podcast_episode:PlayerPodcastEpisodeProps }> => {
|
|
135
135
|
try {
|
|
136
136
|
const resp = await axios.post(`${SOCIAL_SVC_API}/v1/podcasts/episode/start`, { podcast_episode_id });
|
|
137
|
-
console.log(resp.data)
|
|
138
137
|
return resp.data
|
|
139
138
|
} catch (e) {
|
|
140
139
|
console.log(e)
|
package/src/index.tsx
CHANGED
|
@@ -29,7 +29,7 @@ import MarketComponents from './MarketComponents';
|
|
|
29
29
|
import EventComponents from './EventComponents';
|
|
30
30
|
import Share from './Share';
|
|
31
31
|
import LocationTracker from "./LocationTracker";
|
|
32
|
-
|
|
32
|
+
import MarketMaker from "./MarketMaker";
|
|
33
33
|
|
|
34
34
|
export {
|
|
35
35
|
Authenticator,
|
|
@@ -54,6 +54,7 @@ export {
|
|
|
54
54
|
PollCampaign,
|
|
55
55
|
PollCampaignApi,
|
|
56
56
|
PollApi,
|
|
57
|
+
MarketMaker,
|
|
57
58
|
CompetitionModule,
|
|
58
59
|
SeasonManager,
|
|
59
60
|
CreateCompetitionForm,
|
package/src/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Moment } from "moment-mini";
|
|
2
|
+
|
|
1
3
|
export interface PublicPlayerProps {
|
|
2
4
|
player_id:string,
|
|
3
5
|
username:string,
|
|
@@ -163,6 +165,16 @@ export interface PlayerPodcastProps {
|
|
|
163
165
|
last_update_datetime:any
|
|
164
166
|
}
|
|
165
167
|
|
|
168
|
+
export interface SortedContestProps {
|
|
169
|
+
league_id?:string,
|
|
170
|
+
contest_type: 'team'|'tournament'|'match',
|
|
171
|
+
id:string,
|
|
172
|
+
title:string,
|
|
173
|
+
markets:MarketProps[],
|
|
174
|
+
time_detail:string,
|
|
175
|
+
scheduled_datetime:Moment
|
|
176
|
+
}
|
|
177
|
+
|
|
166
178
|
export interface PlayerPodcastEpisodeProps {
|
|
167
179
|
player_podcast_episode_id:string,
|
|
168
180
|
player_id:string,
|