be-components 2.4.9 → 2.5.0
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/Components/Jerseys.js +14 -4
- package/lib/commonjs/Components/Jerseys.js.map +1 -1
- package/lib/commonjs/LocationTracker/LocationStatus.js +1 -0
- package/lib/commonjs/LocationTracker/LocationStatus.js.map +1 -1
- package/lib/commonjs/MarketComponents/api/index.js +40 -0
- package/lib/commonjs/MarketComponents/api/index.js.map +1 -1
- package/lib/commonjs/MarketComponents/components/AthleteTournamentMarket/index.js.map +1 -1
- package/lib/commonjs/MarketComponents/components/MatchMarket/index.js +231 -0
- package/lib/commonjs/MarketComponents/components/MatchMarket/index.js.map +1 -0
- package/lib/commonjs/MarketComponents/components/TeamTournamentMarket/index.js +202 -0
- package/lib/commonjs/MarketComponents/components/TeamTournamentMarket/index.js.map +1 -0
- package/lib/commonjs/MarketComponents/components/TournamentMarket/api/index.js +109 -0
- package/lib/commonjs/MarketComponents/components/TournamentMarket/api/index.js.map +1 -0
- package/lib/commonjs/MarketComponents/components/TournamentMarket/index.js +380 -0
- package/lib/commonjs/MarketComponents/components/TournamentMarket/index.js.map +1 -0
- package/lib/commonjs/MarketComponents/index.js +3 -1
- package/lib/commonjs/MarketComponents/index.js.map +1 -1
- package/lib/commonjs/MarketMaker/api/index.js +80 -9
- package/lib/commonjs/MarketMaker/api/index.js.map +1 -1
- package/lib/commonjs/MarketMaker/components/Contest.js +111 -40
- package/lib/commonjs/MarketMaker/components/Contest.js.map +1 -1
- package/lib/commonjs/MarketMaker/components/ContestMarkets.js +538 -161
- package/lib/commonjs/MarketMaker/components/ContestMarkets.js.map +1 -1
- package/lib/commonjs/MarketMaker/components/Dashboard.js +8 -2
- package/lib/commonjs/MarketMaker/components/Dashboard.js.map +1 -1
- package/lib/commonjs/MarketMaker/components/OrderForm.js +186 -0
- package/lib/commonjs/MarketMaker/components/OrderForm.js.map +1 -0
- package/lib/commonjs/MarketMaker/components/SetMarketForm.js +221 -77
- package/lib/commonjs/MarketMaker/components/SetMarketForm.js.map +1 -1
- package/lib/commonjs/MarketMaker/components/WeightProgress.js +19 -8
- package/lib/commonjs/MarketMaker/components/WeightProgress.js.map +1 -1
- package/lib/commonjs/MarketMaker/index.js +138 -21
- package/lib/commonjs/MarketMaker/index.js.map +1 -1
- package/lib/commonjs/Socket/index.js +1 -1
- package/lib/commonjs/Socket/index.js.map +1 -1
- package/lib/module/Components/Jerseys.js +14 -4
- package/lib/module/Components/Jerseys.js.map +1 -1
- package/lib/module/LocationTracker/LocationStatus.js +1 -0
- package/lib/module/LocationTracker/LocationStatus.js.map +1 -1
- package/lib/module/MarketComponents/api/index.js +40 -0
- package/lib/module/MarketComponents/api/index.js.map +1 -1
- package/lib/module/MarketComponents/components/AthleteTournamentMarket/index.js.map +1 -1
- package/lib/module/MarketComponents/components/MatchMarket/index.js +222 -0
- package/lib/module/MarketComponents/components/MatchMarket/index.js.map +1 -0
- package/lib/module/MarketComponents/components/TeamTournamentMarket/index.js +193 -0
- package/lib/module/MarketComponents/components/TeamTournamentMarket/index.js.map +1 -0
- package/lib/module/MarketComponents/components/TournamentMarket/api/index.js +103 -0
- package/lib/module/MarketComponents/components/TournamentMarket/api/index.js.map +1 -0
- package/lib/module/MarketComponents/components/TournamentMarket/index.js +371 -0
- package/lib/module/MarketComponents/components/TournamentMarket/index.js.map +1 -0
- package/lib/module/MarketComponents/index.js +3 -1
- package/lib/module/MarketComponents/index.js.map +1 -1
- package/lib/module/MarketMaker/api/index.js +80 -9
- package/lib/module/MarketMaker/api/index.js.map +1 -1
- package/lib/module/MarketMaker/components/Contest.js +110 -41
- package/lib/module/MarketMaker/components/Contest.js.map +1 -1
- package/lib/module/MarketMaker/components/ContestMarkets.js +541 -162
- package/lib/module/MarketMaker/components/ContestMarkets.js.map +1 -1
- package/lib/module/MarketMaker/components/Dashboard.js +8 -2
- package/lib/module/MarketMaker/components/Dashboard.js.map +1 -1
- package/lib/module/MarketMaker/components/OrderForm.js +177 -0
- package/lib/module/MarketMaker/components/OrderForm.js.map +1 -0
- package/lib/module/MarketMaker/components/SetMarketForm.js +221 -77
- package/lib/module/MarketMaker/components/SetMarketForm.js.map +1 -1
- package/lib/module/MarketMaker/components/WeightProgress.js +17 -8
- package/lib/module/MarketMaker/components/WeightProgress.js.map +1 -1
- package/lib/module/MarketMaker/index.js +138 -21
- package/lib/module/MarketMaker/index.js.map +1 -1
- package/lib/module/Socket/index.js +1 -1
- package/lib/module/Socket/index.js.map +1 -1
- package/lib/typescript/src/Components/Jerseys.d.ts +2 -1
- package/lib/typescript/src/Components/Jerseys.d.ts.map +1 -1
- package/lib/typescript/src/LocationTracker/LocationStatus.d.ts.map +1 -1
- package/lib/typescript/src/MarketComponents/api/index.d.ts +6 -0
- package/lib/typescript/src/MarketComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketComponents/components/AthleteTournamentMarket/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketComponents/components/MatchMarket/index.d.ts +33 -0
- package/lib/typescript/src/MarketComponents/components/MatchMarket/index.d.ts.map +1 -0
- package/lib/typescript/src/MarketComponents/components/TeamTournamentMarket/index.d.ts +29 -0
- package/lib/typescript/src/MarketComponents/components/TeamTournamentMarket/index.d.ts.map +1 -0
- package/lib/typescript/src/MarketComponents/components/TournamentMarket/api/index.d.ts +13 -0
- package/lib/typescript/src/MarketComponents/components/TournamentMarket/api/index.d.ts.map +1 -0
- package/lib/typescript/src/MarketComponents/components/TournamentMarket/index.d.ts +27 -0
- package/lib/typescript/src/MarketComponents/components/TournamentMarket/index.d.ts.map +1 -0
- package/lib/typescript/src/MarketComponents/index.d.ts +22 -0
- package/lib/typescript/src/MarketComponents/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/api/index.d.ts +18 -4
- package/lib/typescript/src/MarketMaker/api/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/components/Contest.d.ts +5 -2
- package/lib/typescript/src/MarketMaker/components/Contest.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts +4 -1
- package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts +4 -2
- package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/components/OrderForm.d.ts +12 -0
- package/lib/typescript/src/MarketMaker/components/OrderForm.d.ts.map +1 -0
- package/lib/typescript/src/MarketMaker/components/SetMarketForm.d.ts +1 -1
- package/lib/typescript/src/MarketMaker/components/SetMarketForm.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/components/WeightProgress.d.ts +2 -2
- package/lib/typescript/src/MarketMaker/components/WeightProgress.d.ts.map +1 -1
- package/lib/typescript/src/MarketMaker/index.d.ts +3 -1
- package/lib/typescript/src/MarketMaker/index.d.ts.map +1 -1
- package/lib/typescript/src/Socket/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Components/Jerseys.tsx +9 -4
- package/src/LocationTracker/LocationStatus.tsx +1 -0
- package/src/MarketComponents/api/index.ts +27 -0
- package/src/MarketComponents/components/AthleteTournamentMarket/index.tsx +0 -1
- package/src/MarketComponents/components/MatchMarket/index.tsx +149 -0
- package/src/MarketComponents/components/TeamTournamentMarket/index.tsx +123 -0
- package/src/MarketComponents/components/TournamentMarket/api/index.ts +74 -0
- package/src/MarketComponents/components/TournamentMarket/index.tsx +289 -0
- package/src/MarketComponents/index.tsx +3 -1
- package/src/MarketMaker/api/index.ts +61 -13
- package/src/MarketMaker/components/Contest.tsx +79 -29
- package/src/MarketMaker/components/ContestMarkets.tsx +400 -98
- package/src/MarketMaker/components/Dashboard.tsx +11 -5
- package/src/MarketMaker/components/OrderForm.tsx +134 -0
- package/src/MarketMaker/components/SetMarketForm.tsx +128 -77
- package/src/MarketMaker/components/WeightProgress.tsx +9 -5
- package/src/MarketMaker/index.tsx +122 -22
- package/src/Socket/index.tsx +5 -2
- package/src/types.d.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { MarketMakerApi, MarketMaketHelpers } from './api';
|
|
4
|
-
import type { BestAvailableResponseProps, EventProps, ExternalPriceProps, FundingRequestProps, FundOrderProps, FundOwnershipProps, FundProps, LeagueProps, MarketProps, MatchProps, OrderProps, PublicPlayerProps, TournamentProps, TradeProps } from '../types';
|
|
4
|
+
import type { AthleteProps, BestAvailableResponseProps, EventProps, ExternalPriceProps, FundingRequestProps, FundOrderProps, FundOwnershipProps, FundProps, LeagueProps, MarketProps, MatchProps, OrderProps, PublicPlayerProps, TournamentProps, TradeProps } from '../types';
|
|
5
5
|
//import { view_styles } from '../constants/styles';
|
|
6
6
|
import Colors from '../constants/colors';
|
|
7
7
|
import ContestSelector from './components/ContestSelector';
|
|
@@ -13,12 +13,18 @@ import { usePlayerLocation } from '../LocationTracker/LocationStatus';
|
|
|
13
13
|
import ManageFundForm from './components/ManageFundForm';
|
|
14
14
|
import FundingRequestList from './components/FundingRequestList';
|
|
15
15
|
import FundOwnershipList from './components/FundOwnershipList';
|
|
16
|
+
import SocketManager from '../Socket';
|
|
17
|
+
import OrderForm from './components/OrderForm';
|
|
16
18
|
|
|
17
19
|
type MarketMakerProps = {
|
|
18
|
-
player_id:string
|
|
20
|
+
player_id:string,
|
|
21
|
+
access_token:string,
|
|
22
|
+
distinct_id:string
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
25
|
+
const MarketMaker = ({ player_id, access_token, distinct_id }:MarketMakerProps) => {
|
|
26
|
+
const [ ba_socket_data, setBASocketData ] = useState<BestAvailableResponseProps | undefined>(undefined);
|
|
27
|
+
const [ socket_fund, setSocketFund ] = useState<{ fund:FundProps, orders:OrderProps[] } | undefined>(undefined);
|
|
22
28
|
const [ module_data, setModuleData ] = useState<{
|
|
23
29
|
loaded:boolean,
|
|
24
30
|
loading:boolean,
|
|
@@ -41,7 +47,13 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
41
47
|
const { loaded, leagues, events, markets, funds } = module_data;
|
|
42
48
|
|
|
43
49
|
const [ editing_fund, setEditingFund ] = useState<FundProps | undefined>(undefined);
|
|
44
|
-
|
|
50
|
+
const [ draft_order, setDraftOrder ] = useState<{
|
|
51
|
+
visible:boolean,
|
|
52
|
+
order?:OrderProps,
|
|
53
|
+
available?:number
|
|
54
|
+
}>({
|
|
55
|
+
visible:false
|
|
56
|
+
})
|
|
45
57
|
const [ set_market_form_data, setMarketFormData ] = useState<{
|
|
46
58
|
set_market_form_key:string,
|
|
47
59
|
set_market_orders:OrderProps[],
|
|
@@ -55,14 +67,19 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
55
67
|
set_market_prices:[]
|
|
56
68
|
});
|
|
57
69
|
const { set_market_form_key, set_market_orders, set_market_form_visible, set_market_market, set_market_prices } = set_market_form_data;
|
|
58
|
-
|
|
70
|
+
const [ market_data, setMarketData ] = useState<{
|
|
71
|
+
best_available:BestAvailableResponseProps
|
|
72
|
+
}>({
|
|
73
|
+
best_available: { events: [], tournaments: [], matches: [] }
|
|
74
|
+
});
|
|
75
|
+
const { best_available } = market_data;
|
|
59
76
|
const [ dash_data, setDashData ] = useState<{
|
|
60
77
|
fund?:FundProps,
|
|
61
78
|
loaded:boolean,
|
|
62
79
|
loading:boolean,
|
|
63
80
|
external_name?:string,
|
|
64
81
|
players:PublicPlayerProps[],
|
|
65
|
-
|
|
82
|
+
athletes:AthleteProps[],
|
|
66
83
|
funding_requests:FundingRequestProps[],
|
|
67
84
|
fund_ownerships:FundOwnershipProps[],
|
|
68
85
|
selected_markets:MarketProps[],
|
|
@@ -79,10 +96,10 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
79
96
|
external_name: 'Consensus',
|
|
80
97
|
players:[],
|
|
81
98
|
funding_requests:[],
|
|
99
|
+
athletes:[],
|
|
82
100
|
fund_ownerships:[],
|
|
83
101
|
fund_orders:[],
|
|
84
102
|
selected_markets:[],
|
|
85
|
-
best_available: { events: [], tournaments: [], matches: [] },
|
|
86
103
|
orders:[],
|
|
87
104
|
trades:[],
|
|
88
105
|
external_prices: [],
|
|
@@ -90,7 +107,7 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
90
107
|
selected_matches:[],
|
|
91
108
|
selected_tournaments:[]
|
|
92
109
|
});
|
|
93
|
-
const { fund, selected_events, players, fund_orders, fund_ownerships, funding_requests, external_name, selected_matches, selected_tournaments, selected_markets, trades, external_prices,
|
|
110
|
+
const { fund, selected_events, athletes, players, fund_orders, fund_ownerships, funding_requests, external_name, selected_matches, selected_tournaments, selected_markets, trades, external_prices, orders } = dash_data;
|
|
94
111
|
const { available_orders } = MarketMaketHelpers.getMarketDataFromBestAvailable(best_available);
|
|
95
112
|
const selectable_markets = MarketMaketHelpers.getSelectableMarkets(selected_events, selected_tournaments, selected_matches, markets);
|
|
96
113
|
|
|
@@ -107,6 +124,25 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
107
124
|
getDashData(fund.fund_id);
|
|
108
125
|
},[fund]);
|
|
109
126
|
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if(!ba_socket_data){ return }
|
|
129
|
+
//Reconcile and update ba_socket data!
|
|
130
|
+
setMarketData({
|
|
131
|
+
...market_data,
|
|
132
|
+
best_available: MarketMaketHelpers.updateBestAvailable(best_available, ba_socket_data)
|
|
133
|
+
})
|
|
134
|
+
},[ba_socket_data]);
|
|
135
|
+
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if(!socket_fund){ return }
|
|
138
|
+
if(socket_fund.fund.fund_id != fund?.fund_id){ return }
|
|
139
|
+
setDashData({
|
|
140
|
+
...dash_data,
|
|
141
|
+
orders: orders.filter(o => socket_fund.orders.find(no => no.order_id == o.order_id)).concat(socket_fund.orders),
|
|
142
|
+
fund: socket_fund.fund
|
|
143
|
+
})
|
|
144
|
+
},[socket_fund])
|
|
145
|
+
|
|
110
146
|
const loadModule = async() => {
|
|
111
147
|
setModuleData({ ...module_data, loading:true });
|
|
112
148
|
setDashData({ ...dash_data, loading:true });
|
|
@@ -128,24 +164,36 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
128
164
|
|
|
129
165
|
const getDashData = async(fund_id:string) => {
|
|
130
166
|
//Now load Dash data
|
|
167
|
+
console.log('1')
|
|
131
168
|
const ba = await MarketMakerApi.getBestAvailableOrders();
|
|
169
|
+
console.log('2')
|
|
170
|
+
|
|
132
171
|
const fund_response = await MarketMakerApi.getFundById(fund_id);
|
|
172
|
+
console.log('3')
|
|
173
|
+
|
|
133
174
|
if(!fund_response){
|
|
134
175
|
alert('Failed to get details for selected fund');
|
|
135
176
|
return setDashData({ ...dash_data, loading:false });
|
|
136
177
|
}
|
|
137
178
|
const fr_requests = await MarketMakerApi.getFundingRequestsByFundId(fund_id);
|
|
179
|
+
console.log('4')
|
|
180
|
+
|
|
138
181
|
const my_action_data = await getDataForMyAction(fund_response.orders, markets);
|
|
182
|
+
console.log('5')
|
|
183
|
+
|
|
139
184
|
//Based on my action -- lets auto select events and grab all that data!!
|
|
140
|
-
let ep = await MarketMakerApi.getPricesByEvents('team', my_action_data.events.map(e => e.event_id))
|
|
141
185
|
let player_ids = [ ...new Set(fr_requests.map(r => r.player_id).concat(fund_response.fund_ownerships.map(o => o.player_id)).map(id => id))]
|
|
142
186
|
let plays = await MarketMakerApi.getPlayersByIds(player_ids)
|
|
187
|
+
console.log('6')
|
|
143
188
|
|
|
189
|
+
setMarketData({
|
|
190
|
+
...market_data,
|
|
191
|
+
best_available: ba
|
|
192
|
+
});
|
|
144
193
|
setDashData({
|
|
145
194
|
...dash_data,
|
|
146
195
|
loaded:true,
|
|
147
196
|
loading:false,
|
|
148
|
-
best_available: ba,
|
|
149
197
|
funding_requests:fr_requests,
|
|
150
198
|
players:plays,
|
|
151
199
|
fund_ownerships: fund_response.fund_ownerships,
|
|
@@ -153,27 +201,32 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
153
201
|
fund_orders: fund_response.fund_orders,
|
|
154
202
|
selected_events: my_action_data.events,
|
|
155
203
|
trades: my_action_data.trades,
|
|
156
|
-
external_prices:
|
|
204
|
+
external_prices: my_action_data.prices,
|
|
157
205
|
selected_markets: my_action_data.markets
|
|
158
206
|
})
|
|
159
207
|
}
|
|
160
208
|
|
|
209
|
+
|
|
161
210
|
const getDataForMyAction = async(orders:OrderProps[], markets:MarketProps[]) => {
|
|
162
211
|
const ev_ids = orders.filter(o => o.event_type == 'team').map(o => o.event_id);
|
|
163
212
|
const mks = markets.filter(m => orders.map(o => o.market_id.toString()).includes(m.market_id.toString()))
|
|
164
213
|
const evs = await MarketMakerApi.getEventsByEventIds(ev_ids);
|
|
165
|
-
const ts = await MarketMakerApi.getLatestTradesByEvents('team', ev_ids)
|
|
166
|
-
|
|
214
|
+
const ts = await MarketMakerApi.getLatestTradesByEvents('team', ev_ids);
|
|
215
|
+
const ps = await MarketMakerApi.getPricesByEvents('team', ev_ids);
|
|
216
|
+
return { events:evs, trades:ts, markets:mks, prices: ps }
|
|
167
217
|
}
|
|
168
218
|
|
|
169
219
|
const handleSelectEvent = async(e:EventProps) => {
|
|
170
220
|
if(dash_data.loading){ return }//No mashy
|
|
171
221
|
setDashData({ ...dash_data, loading: true });
|
|
172
222
|
const prices = await MarketMakerApi.getPricesByEvent(e.event_id, 'team');
|
|
223
|
+
let athlete_ids = [ ...new Set(prices.filter(p => p.participant_type == 'athlete').map(p => p.participant_id)) ]
|
|
224
|
+
let aths = await MarketMakerApi.getAthletesByIds(athlete_ids)
|
|
173
225
|
const tds = await MarketMakerApi.getLatestTradesByEvents('team', [e.event_id]);
|
|
174
226
|
setDashData({
|
|
175
227
|
...dash_data,
|
|
176
228
|
loading:false,
|
|
229
|
+
athletes:aths,
|
|
177
230
|
selected_events: selected_events.concat(e),
|
|
178
231
|
trades: trades.filter(t => t.event_id != e.event_id).concat(tds),
|
|
179
232
|
external_prices: external_prices.filter(p => p.event_id != e.event_id).concat(prices)
|
|
@@ -243,7 +296,7 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
243
296
|
...dash_data,
|
|
244
297
|
funding_requests: funding_requests.filter(fr => fr.funding_request_id != fr_id)
|
|
245
298
|
})
|
|
246
|
-
}}
|
|
299
|
+
}}
|
|
247
300
|
/>
|
|
248
301
|
:<></>}
|
|
249
302
|
<ContestSelector
|
|
@@ -268,11 +321,12 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
268
321
|
selected_markets={selected_markets.map(m => m.market_id)}
|
|
269
322
|
/>
|
|
270
323
|
</View>
|
|
271
|
-
<View style={{ flexGrow:1 }}>
|
|
324
|
+
<View style={{ flexGrow:1, flexShrink:1}}>
|
|
272
325
|
<Dashboard
|
|
273
326
|
loaded={dash_data.loaded}
|
|
274
327
|
leagues={leagues}
|
|
275
328
|
fund={fund}
|
|
329
|
+
athletes={athletes}
|
|
276
330
|
events={selected_events}
|
|
277
331
|
tournaments={selected_tournaments}
|
|
278
332
|
matches={selected_matches}
|
|
@@ -283,6 +337,14 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
283
337
|
external_name={external_name}
|
|
284
338
|
orders={orders}
|
|
285
339
|
fund_orders={fund_orders}
|
|
340
|
+
onOrder={async(o, avail) => {
|
|
341
|
+
console.log(o)
|
|
342
|
+
setDraftOrder({
|
|
343
|
+
visible:true,
|
|
344
|
+
order: o,
|
|
345
|
+
available:avail
|
|
346
|
+
})
|
|
347
|
+
}}
|
|
286
348
|
onDepositFund={async(amount) => {
|
|
287
349
|
if(!fund){ return alert('Unable to process') }
|
|
288
350
|
const dep_resp = await MarketMakerApi.depositRequest(fund.fund_id, amount);
|
|
@@ -295,7 +357,7 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
295
357
|
setDashData({
|
|
296
358
|
...dash_data,
|
|
297
359
|
fund: layoff_resp.fund,
|
|
298
|
-
orders: layoff_resp.orders
|
|
360
|
+
orders: orders.filter(o => !layoff_resp.orders.find(newo => newo.order_id == o.order_id)).concat(layoff_resp.orders)
|
|
299
361
|
})
|
|
300
362
|
}}
|
|
301
363
|
onWorkCapital={async(amount) => {
|
|
@@ -312,7 +374,7 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
312
374
|
const new_orders = await MarketMakerApi.cancelOrders(order_ids)
|
|
313
375
|
setDashData({
|
|
314
376
|
...dash_data,
|
|
315
|
-
orders: orders.filter(o => !new_orders.find(no => no.order_id == o.order_id))
|
|
377
|
+
orders: orders.filter(o => !new_orders.find(no => no.order_id == o.order_id)).concat(new_orders)
|
|
316
378
|
})
|
|
317
379
|
}}
|
|
318
380
|
onSetMarket={(orders, market, prices) => {
|
|
@@ -330,6 +392,28 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
330
392
|
})
|
|
331
393
|
}}
|
|
332
394
|
/>
|
|
395
|
+
{fund && draft_order.order && draft_order.visible ?
|
|
396
|
+
<View style={{ position:'absolute', bottom:0, left:0, right:0, top:0, backgroundColor:Colors.shades.black_faded, justifyContent:'center', alignItems:'center' }}>
|
|
397
|
+
<OrderForm
|
|
398
|
+
fund={fund}
|
|
399
|
+
order={draft_order.order}
|
|
400
|
+
available={draft_order.available}
|
|
401
|
+
onClose={() => setDraftOrder({ visible:false })}
|
|
402
|
+
onSubmit={async(order) => {
|
|
403
|
+
if(!fund){ return alert('Unable to process') }
|
|
404
|
+
if(!location.region || !location.coordinates){ return alert('Location could not be verified to process orders') }
|
|
405
|
+
const new_orders = await MarketMakerApi.addOrdersToFund(fund.fund_id, [{ ...order, location: location.coordinates, region: location.region }]);
|
|
406
|
+
setDashData({
|
|
407
|
+
...dash_data,
|
|
408
|
+
fund_orders: fund_orders.concat(new_orders.fund_orders),
|
|
409
|
+
orders:orders.concat(new_orders.orders)
|
|
410
|
+
})
|
|
411
|
+
setDraftOrder({ visible:false });
|
|
412
|
+
}}
|
|
413
|
+
|
|
414
|
+
/>
|
|
415
|
+
</View>
|
|
416
|
+
:<></>}
|
|
333
417
|
{fund && set_market_form_visible && set_market_market ?
|
|
334
418
|
<View style={{ position:'absolute', bottom:0, left:0, right:0, top:0, backgroundColor:Colors.shades.black_faded, justifyContent:'center', alignItems:'center' }}>
|
|
335
419
|
<SetMarketForm
|
|
@@ -339,14 +423,14 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
339
423
|
orders={set_market_orders}
|
|
340
424
|
prices={set_market_prices}
|
|
341
425
|
spread_pct='5'
|
|
342
|
-
onSetMarket={async(
|
|
426
|
+
onSetMarket={async(fo) => {
|
|
343
427
|
if(!fund){ return alert('Unable to process') }
|
|
344
|
-
const new_os = await MarketMakerApi.addOrdersToFund(fund.fund_id,
|
|
345
|
-
|
|
346
|
-
if(new_os.length == 0){ return alert('Unable to process') }
|
|
428
|
+
const new_os = await MarketMakerApi.addOrdersToFund(fund.fund_id, fo)
|
|
429
|
+
if(new_os.orders.length == 0){ return alert('Unable to process') }
|
|
347
430
|
setDashData({
|
|
348
431
|
...dash_data,
|
|
349
|
-
orders: orders.concat(new_os)
|
|
432
|
+
orders: orders.concat(new_os.orders),
|
|
433
|
+
fund_orders: fund_orders.concat(new_os.fund_orders)
|
|
350
434
|
})
|
|
351
435
|
setMarketFormData({ set_market_form_visible: false, set_market_orders:[], set_market_form_key:'', set_market_prices:[] })
|
|
352
436
|
}}
|
|
@@ -371,6 +455,22 @@ const MarketMaker = ({ player_id }:MarketMakerProps) => {
|
|
|
371
455
|
:<></>}
|
|
372
456
|
</View>
|
|
373
457
|
</View>
|
|
458
|
+
<SocketManager
|
|
459
|
+
subscribed_events={['V1_LOAD_BEST_AVAILABLE', 'V1_UPDATE_FUND']}
|
|
460
|
+
access_token={access_token}
|
|
461
|
+
distinct_id={distinct_id}
|
|
462
|
+
onConnect={() => console.log('connected!')}
|
|
463
|
+
onDisconnect={() => console.log('Disconnected')}
|
|
464
|
+
onSocketEvent={(ev) => {
|
|
465
|
+
switch(ev.type){
|
|
466
|
+
case 'V1_LOAD_BEST_AVAILABLE':
|
|
467
|
+
return setBASocketData(ev.data);
|
|
468
|
+
case 'V1_UPDATE_FUND':
|
|
469
|
+
return setSocketFund(ev.data)
|
|
470
|
+
default: return
|
|
471
|
+
}
|
|
472
|
+
}}
|
|
473
|
+
/>
|
|
374
474
|
</View>
|
|
375
475
|
)
|
|
376
476
|
}
|
package/src/Socket/index.tsx
CHANGED
|
@@ -26,10 +26,13 @@ const SocketManager = ({ access_token, distinct_id, onSocketEvent, subscribed_ev
|
|
|
26
26
|
},[])
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
|
+
|
|
29
30
|
if(visible){
|
|
30
|
-
console.log(ws?.readyState)
|
|
31
31
|
if(!ws || ws.readyState != 1) { return connectSocket(access_token, distinct_id) }
|
|
32
|
-
if(access_token && distinct_id){
|
|
32
|
+
if(access_token && distinct_id){
|
|
33
|
+
console.log('authningn')
|
|
34
|
+
socketAuthenticate(access_token, distinct_id)
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
else {
|
|
35
38
|
if(ws){ ws.close() }
|
package/src/types.d.ts
CHANGED
|
@@ -1903,6 +1903,7 @@ export interface OrderProps {
|
|
|
1903
1903
|
side_type: 'athlete' | 'team' | 'side';
|
|
1904
1904
|
reversed?:boolean,
|
|
1905
1905
|
draft_liquidity?:number,
|
|
1906
|
+
fund_id?:string,
|
|
1906
1907
|
reference_order_id?:string,
|
|
1907
1908
|
be_type: 'market' | 'prop' | 'ind'; //The old be-type of order so we can compare to historical orders
|
|
1908
1909
|
buy_sell_ind: 'buy' | 'sell'; //Indicates whether this order is selling a position or attempting to buy one
|