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
|
@@ -112,13 +112,29 @@ const LocationHelpers = {
|
|
|
112
112
|
let region = '';
|
|
113
113
|
let location:LocationProps | undefined
|
|
114
114
|
let administrative = addresses.find(r => r.types.includes('administrative_area_level_1'))?.address_components;
|
|
115
|
+
let street_address_components = addresses.find(r => r.types.includes('street_address'))?.address_components;
|
|
116
|
+
let route_address_component = addresses.find(r => r.types.includes('route'))?.address_components;
|
|
117
|
+
|
|
115
118
|
if(administrative){
|
|
116
119
|
let region_component = administrative.find((a:any) => a.types.includes('administrative_area_level_1'));
|
|
117
120
|
if(region_component){
|
|
118
121
|
region = region_component.long_name
|
|
119
122
|
location = locations.find(l => l.label.toLowerCase() == region?.toLowerCase())
|
|
120
123
|
}
|
|
124
|
+
} else if (!street_address_components){
|
|
125
|
+
let region_component = street_address_components.find((a:any) => a.types.includes('administrative_area_level_1'));
|
|
126
|
+
if(region_component){
|
|
127
|
+
region = region_component.long_name
|
|
128
|
+
location = locations.find(l => l.label.toLowerCase() == region?.toLowerCase())
|
|
129
|
+
}
|
|
130
|
+
} else if (route_address_component){
|
|
131
|
+
let region_component = route_address_component.find((a:any) => a.types.includes('administrative_area_level_1'));
|
|
132
|
+
if(region_component){
|
|
133
|
+
region = region_component.long_name
|
|
134
|
+
location = locations.find(l => l.label.toLowerCase() == region?.toLowerCase())
|
|
135
|
+
}
|
|
121
136
|
}
|
|
137
|
+
|
|
122
138
|
let street_address = addresses.find(r => r.types.includes('premise'))?.address_components
|
|
123
139
|
if(!street_address){ return { region, location } }
|
|
124
140
|
street_address = addresses.find(r => r.types.includes('street_address'))?.address_components
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { APIOverrides } from "../../ApiOverrides";
|
|
3
|
+
import type { BestAvailableOrderProps, BestAvailableResponseProps, EventOrderStatProps, EventProps, ExternalPriceProps, LeagueProps, MarketProps, MatchProps, OrderProps, SortedContestProps, TournamentProps, TradeProps } from "../../types";
|
|
4
|
+
import moment from "moment-mini";
|
|
5
|
+
|
|
6
|
+
let EVENT_SVC_API = '';
|
|
7
|
+
let MK_SVC_API = '';
|
|
8
|
+
//let AUTH_SVC_API = '';
|
|
9
|
+
|
|
10
|
+
export { MarketMakerApi, MarketMaketHelpers }
|
|
11
|
+
|
|
12
|
+
const MarketMakerApi = {
|
|
13
|
+
setEnvironment: () => {
|
|
14
|
+
const endpoints = APIOverrides.getEndpoints();
|
|
15
|
+
EVENT_SVC_API = endpoints['EVENT_SVC_API'] as string;
|
|
16
|
+
MK_SVC_API = endpoints['MK_SVC_API'] as string;
|
|
17
|
+
//AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
|
|
18
|
+
},
|
|
19
|
+
getLeagues: async():Promise<LeagueProps[]> => {
|
|
20
|
+
try {
|
|
21
|
+
const resp = await axios.get(`${EVENT_SVC_API}/v1/leagues`);
|
|
22
|
+
return resp.data.leagues
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return []
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
getMarkets: async():Promise<MarketProps[]> => {
|
|
28
|
+
try {
|
|
29
|
+
const resp = await axios.get(`${MK_SVC_API}/v1/markets/all`);
|
|
30
|
+
return resp.data.markets
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return []
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
getMyAction: async():Promise<OrderProps[]> => {
|
|
36
|
+
try {
|
|
37
|
+
const resp = await axios.get(`${MK_SVC_API}/v1/orders/action/me`);
|
|
38
|
+
return resp.data.orders
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return []
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
getActiveEvents: async():Promise<EventProps[]> => {
|
|
44
|
+
try {
|
|
45
|
+
const resp = await axios.get(`${EVENT_SVC_API}/v1/events/active?expanded=true`);
|
|
46
|
+
return resp.data.events
|
|
47
|
+
} catch (e) {
|
|
48
|
+
return []
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
getEventsByEventIds: async(event_ids:string[]):Promise<EventProps[]> => {
|
|
52
|
+
if(event_ids.length == 0){ return [] }
|
|
53
|
+
try {
|
|
54
|
+
const resp = await axios.post(`${EVENT_SVC_API}/v1/events/bulk/get`, { attribute:'event_id', values: event_ids })
|
|
55
|
+
return resp.data.events
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return []
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
getBestAvailableOrders: async():Promise<BestAvailableResponseProps> => {
|
|
61
|
+
try {
|
|
62
|
+
const resp = await axios.get(`${MK_SVC_API}/v1/orders/available`)
|
|
63
|
+
return resp.data
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return { events: [], tournaments: [], matches:[] }
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
getPricesByEvent: async(event_id:string, event_type:string):Promise<ExternalPriceProps[]> => {
|
|
69
|
+
try {
|
|
70
|
+
const resp = await axios.get(`${EVENT_SVC_API}/v1/prices/latest/${event_id}/${event_type}`);
|
|
71
|
+
console.log(resp.data)
|
|
72
|
+
return resp.data.prices
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.log(e);
|
|
75
|
+
return []
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
getLatestTradesByEvents: async(event_type: string, event_ids:string[]) => {
|
|
79
|
+
try {
|
|
80
|
+
if(event_ids.length == 0){ return [] }
|
|
81
|
+
const resp = await axios.post(`${MK_SVC_API}/v1/trades/event/latest/bulk/get`, { event_type, event_ids })
|
|
82
|
+
return resp.data.trades
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.log(e)
|
|
85
|
+
return []
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const MarketMaketHelpers = {
|
|
91
|
+
getOrderStats:(orders:OrderProps[]) => {
|
|
92
|
+
const open_amt = orders.reduce((a,b) => a + b.open_amt, 0);
|
|
93
|
+
const called_amt = orders.reduce((a,b) => a + b.called_amt, 0);
|
|
94
|
+
return { open_amt, called_amt }
|
|
95
|
+
},
|
|
96
|
+
sortContests: (events:EventProps[], tournaments:TournamentProps[], matches:MatchProps[], markets:MarketProps[]):SortedContestProps[] => {
|
|
97
|
+
let contests:SortedContestProps[] = []
|
|
98
|
+
events.map(e => {
|
|
99
|
+
let e_markets = e.supported_markets ? markets.filter(m => e.supported_markets?.map(sm => sm.market_id.toString()).includes(m.market_id.toString())) : []
|
|
100
|
+
contests.push({
|
|
101
|
+
league_id: e.league_id,
|
|
102
|
+
id: e.event_id,
|
|
103
|
+
title: e.event_title,
|
|
104
|
+
contest_type: 'team',
|
|
105
|
+
time_detail: e.time_detail == 'scheduled' ? moment(e.scheduled_datetime).format('MMM DD : hh:mm a'): e.time_detail ?? '',
|
|
106
|
+
scheduled_datetime: moment(e.scheduled_datetime),
|
|
107
|
+
markets: e_markets
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
tournaments.map(t => {
|
|
111
|
+
let t_markets = t.supported_markets ? markets.filter(m => t.supported_markets?.map(sm => sm.market_id.toString()).includes(m.market_id.toString())) : []
|
|
112
|
+
|
|
113
|
+
contests.push({ markets: t_markets, league_id: t.league_id, id: t.tournament_id, title: t.tournament_name, contest_type: 'tournament', time_detail: moment(t.scheduled_datetime).format('MMM DD : hh:mm a'), scheduled_datetime: moment(t.scheduled_datetime) })
|
|
114
|
+
})
|
|
115
|
+
matches.map(m => {
|
|
116
|
+
const tourney = tournaments.find(t => t.tournament_id == m.tournament_id);
|
|
117
|
+
let m_markets = m.supported_markets ? markets.filter(mk => m.supported_markets?.map(sm => sm.market_id.toString()).includes(mk.market_id.toString())) : []
|
|
118
|
+
contests.push({ markets:m_markets, league_id:tourney?.league_id, id: m.match_id, title: m.match_title, contest_type: 'match', time_detail: moment(m.scheduled_datetime).format('MMM DD : hh:mm a'), scheduled_datetime: moment(m.scheduled_datetime) })
|
|
119
|
+
})
|
|
120
|
+
return contests
|
|
121
|
+
},
|
|
122
|
+
getSelectableMarkets: (events:EventProps[], tournaments:TournamentProps[], matches:MatchProps[], markets:MarketProps[]):MarketProps[] => {
|
|
123
|
+
let market_ids:string[] = []
|
|
124
|
+
events.map(e => {
|
|
125
|
+
if(e.supported_markets){
|
|
126
|
+
market_ids = market_ids.concat(e.supported_markets.map(sm => sm.market_id))
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
tournaments.map(e => {
|
|
130
|
+
if(e.supported_markets){
|
|
131
|
+
market_ids = market_ids.concat(e.supported_markets.map(sm => sm.market_id))
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
matches.map(e => {
|
|
135
|
+
if(e.supported_markets){
|
|
136
|
+
market_ids = market_ids.concat(e.supported_markets.map(sm => sm.market_id))
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
market_ids = [ ...new Set(market_ids.map(id => id.toString())) ]
|
|
140
|
+
return markets.filter(m => market_ids.includes(m.market_id.toString()))
|
|
141
|
+
},
|
|
142
|
+
getMarketDataFromBestAvailable: (ba:BestAvailableResponseProps):{ updated:boolean, latest_trades:TradeProps[], event_order_stats:EventOrderStatProps[], available_orders:BestAvailableOrderProps[] } => {
|
|
143
|
+
let updated = false;
|
|
144
|
+
let event_order_stats:EventOrderStatProps[] = []
|
|
145
|
+
let available_orders:BestAvailableOrderProps[] = []
|
|
146
|
+
let latest_trades:TradeProps[] = []
|
|
147
|
+
ba.events.map(ba_event => {
|
|
148
|
+
if(!ba_event.supported_markets){ return }
|
|
149
|
+
updated = true
|
|
150
|
+
ba_event.supported_markets.map(sm => {
|
|
151
|
+
if(sm.available_orders){ available_orders = available_orders.concat(sm.available_orders) }
|
|
152
|
+
if(sm.order_stats){ event_order_stats = event_order_stats.concat(sm.order_stats) }
|
|
153
|
+
if(sm.latest_trades){ latest_trades = latest_trades.concat(sm.latest_trades) }
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
ba.tournaments.map(ba_event => {
|
|
158
|
+
if(!ba_event.supported_markets){ return }
|
|
159
|
+
updated = true
|
|
160
|
+
ba_event.supported_markets.map(sm => {
|
|
161
|
+
if(sm.available_orders){ available_orders = available_orders.concat(sm.available_orders) }
|
|
162
|
+
if(sm.order_stats){ event_order_stats = event_order_stats.concat(sm.order_stats) }
|
|
163
|
+
if(sm.latest_trades){ latest_trades = latest_trades.concat(sm.latest_trades) }
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
ba.matches.map(ba_event => {
|
|
168
|
+
if(!ba_event.supported_markets){ return }
|
|
169
|
+
updated = true
|
|
170
|
+
ba_event.supported_markets.map(sm => {
|
|
171
|
+
if(sm.available_orders){ available_orders = available_orders.concat(sm.available_orders) }
|
|
172
|
+
if(sm.order_stats){ event_order_stats = event_order_stats.concat(sm.order_stats) }
|
|
173
|
+
if(sm.latest_trades){ latest_trades = latest_trades.concat(sm.latest_trades) }
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
return { updated, event_order_stats, available_orders, latest_trades }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Image, FlatList } from 'react-native';
|
|
3
|
+
import type { BestAvailableOrderProps, ExternalPriceProps, LeagueProps, MarketProps, OrderProps, TradeProps } from '../../types';
|
|
4
|
+
import { view_styles } from '../../constants/styles';
|
|
5
|
+
import { Text } from '../../Components';
|
|
6
|
+
import ContestMarket from './ContestMarkets';
|
|
7
|
+
import { MarketMaketHelpers } from '../api';
|
|
8
|
+
import Colors from '../../constants/colors';
|
|
9
|
+
|
|
10
|
+
type ContestProps = {
|
|
11
|
+
league?:LeagueProps,
|
|
12
|
+
contest_id:string,
|
|
13
|
+
contest_type:string,
|
|
14
|
+
contest_title:string,
|
|
15
|
+
best_available_orders:BestAvailableOrderProps[],
|
|
16
|
+
latest_trades:TradeProps[],
|
|
17
|
+
external_prices:ExternalPriceProps[],
|
|
18
|
+
orders:OrderProps[],
|
|
19
|
+
markets:MarketProps[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Contest = ({ contest_id, contest_type, league, contest_title, best_available_orders, latest_trades, orders, markets }:ContestProps) => {
|
|
23
|
+
|
|
24
|
+
const { open_amt, called_amt } = MarketMaketHelpers.getOrderStats(orders);
|
|
25
|
+
|
|
26
|
+
const renderMarkets = (data:{ item:MarketProps, index:number }) => {
|
|
27
|
+
const market_orders = orders.filter(o => o.market_id == data.item.market_id);
|
|
28
|
+
const market_trades = latest_trades.filter(t => t.market_id == data.item.market_id);
|
|
29
|
+
const market_available_orders = best_available_orders.filter(o => o.market_id == data.item.market_id);
|
|
30
|
+
return (
|
|
31
|
+
<ContestMarket
|
|
32
|
+
contest_id={contest_id}
|
|
33
|
+
contest_type={contest_type}
|
|
34
|
+
market={data.item}
|
|
35
|
+
orders={market_orders}
|
|
36
|
+
latest_trades={market_trades}
|
|
37
|
+
best_available_orders={market_available_orders}
|
|
38
|
+
/>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View style={{ ...view_styles.section, }}>
|
|
44
|
+
<View style={{ ...view_styles.section_header }}>
|
|
45
|
+
{league ?
|
|
46
|
+
<Image
|
|
47
|
+
source={{ uri: league.league_image }}
|
|
48
|
+
style={{ height:20, width:20 }}
|
|
49
|
+
resizeMode='cover'
|
|
50
|
+
/>
|
|
51
|
+
:<></>}
|
|
52
|
+
<View style={{ flex:1 }}>
|
|
53
|
+
<Text theme='header'>{contest_title}</Text>
|
|
54
|
+
</View>
|
|
55
|
+
<View>
|
|
56
|
+
<Text size={12} color={Colors.brand.midnight}>${open_amt.toFixed(2)} Open (${called_amt.toFixed(2)} Filled)</Text>
|
|
57
|
+
</View>
|
|
58
|
+
</View>
|
|
59
|
+
<View>
|
|
60
|
+
<FlatList
|
|
61
|
+
data={markets}
|
|
62
|
+
renderItem={renderMarkets}
|
|
63
|
+
keyExtractor={(item) => item.market_id.toString()}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default Contest
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import type { BestAvailableOrderProps, MarketProps, OrderProps, TradeProps } from '../../types';
|
|
4
|
+
import { Text } from '../../Components';
|
|
5
|
+
|
|
6
|
+
type ContestMarketProps = {
|
|
7
|
+
contest_id:string,
|
|
8
|
+
contest_type:string,
|
|
9
|
+
market:MarketProps,
|
|
10
|
+
best_available_orders:BestAvailableOrderProps[],
|
|
11
|
+
latest_trades:TradeProps[],
|
|
12
|
+
orders:OrderProps[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const ContestMarket = ({ market, orders }:ContestMarketProps) => {
|
|
16
|
+
console.log(orders)
|
|
17
|
+
return (
|
|
18
|
+
<View>
|
|
19
|
+
<Text>{market.description}</Text>
|
|
20
|
+
</View>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default ContestMarket
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View, FlatList, TouchableOpacity } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { EventProps, LeagueProps, MatchProps, TournamentProps } from "../../types"
|
|
5
|
+
import { view_styles } from '../../constants/styles';
|
|
6
|
+
import { Checkbox, Text } from '../../Components';
|
|
7
|
+
import DropDown from '../../Components/Dropdown';
|
|
8
|
+
import moment from 'moment-mini';
|
|
9
|
+
import Colors from '../../constants/colors';
|
|
10
|
+
|
|
11
|
+
type ContestSelectorProps = {
|
|
12
|
+
leagues:LeagueProps[],
|
|
13
|
+
maxHeight?:number,
|
|
14
|
+
events:EventProps[],
|
|
15
|
+
tournaments:TournamentProps[],
|
|
16
|
+
matches:MatchProps[],
|
|
17
|
+
selected_events:string[],
|
|
18
|
+
onSelectEvent:(e:EventProps) => void,
|
|
19
|
+
onDeselectEvent:(e:EventProps) => void,
|
|
20
|
+
selected_tournaments:string[],
|
|
21
|
+
onSelectTournament:(t:TournamentProps) => void
|
|
22
|
+
selected_matches:string[],
|
|
23
|
+
onSelectMatch:(m:MatchProps) => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ContestSelector = ({ maxHeight, leagues, events, onSelectEvent, selected_events, onDeselectEvent }:ContestSelectorProps) => {
|
|
27
|
+
const [ selector_data, setSelectorData ] = useState<{
|
|
28
|
+
selected_league?:LeagueProps
|
|
29
|
+
}>({
|
|
30
|
+
|
|
31
|
+
});
|
|
32
|
+
const { selected_league } = selector_data;
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if(!selected_league){ setSelectorData({ ...selector_data, selected_league: leagues.find(l => l.priority == 1) }) }
|
|
36
|
+
},[leagues.length]);
|
|
37
|
+
|
|
38
|
+
const filtered_events = events.filter(e => e.league_id == selected_league?.league_id).sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix());
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const renderEvents = (data:{ item:EventProps, index:number }) => {
|
|
42
|
+
const selected = selected_events.find(se => se == data.item.event_id) ? true : false;
|
|
43
|
+
return (
|
|
44
|
+
<TouchableOpacity style={{ ...view_styles.body_row, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }} onPress={() => selected ? onDeselectEvent(data.item) : onSelectEvent(data.item)}>
|
|
45
|
+
<Checkbox checked={selected} disabled onSelect={() => console.log('')}/>
|
|
46
|
+
<View style={{ flex:1, marginLeft:10 }}>
|
|
47
|
+
<Text size={12} weight='bold' color={Colors.brand.midnight}>{data.item.event_title}</Text>
|
|
48
|
+
<Text style={{ marginTop:3 }} theme='body_2'>{data.item.time_detail == 'scheduled' ? moment(data.item.scheduled_datetime).format('MMM DD : hh:mm a') : data.item.time_detail}</Text>
|
|
49
|
+
</View>
|
|
50
|
+
</TouchableOpacity>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<View style={{ ...view_styles.section, maxHeight }}>
|
|
57
|
+
<View style={{ ...view_styles.section_header }}>
|
|
58
|
+
<View style={{ flex:1 }}>
|
|
59
|
+
<Text theme='header'>Select Contest</Text>
|
|
60
|
+
<Text theme='body' style={{ marginTop:3 }}>Use league dropdown to filter</Text>
|
|
61
|
+
</View>
|
|
62
|
+
<DropDown
|
|
63
|
+
selected_value={selected_league?.league_name ?? ''}
|
|
64
|
+
dropdown_options={[
|
|
65
|
+
{ value: 'league', eligible_options: leagues.sort((a,b) => a.priority - b.priority).map(l => l.league_name) }
|
|
66
|
+
]}
|
|
67
|
+
onOptionSelect={(option) => {
|
|
68
|
+
let league = leagues.find(l => l.league_name == option);
|
|
69
|
+
setSelectorData({ ...selector_data, selected_league: league })
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
</View>
|
|
73
|
+
<View style={{ ...view_styles.section_body }}>
|
|
74
|
+
<FlatList
|
|
75
|
+
data={filtered_events}
|
|
76
|
+
renderItem={renderEvents}
|
|
77
|
+
keyExtractor={(item) => item.event_id.toString()}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
</View>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default ContestSelector
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, FlatList, ActivityIndicator } from 'react-native';
|
|
3
|
+
import { view_styles } from "../../constants/styles"
|
|
4
|
+
import type { BestAvailableOrderProps, EventProps, LeagueProps, MarketProps, MatchProps, OrderProps, SortedContestProps, TournamentProps, TradeProps } from "../../types"
|
|
5
|
+
import { Text } from '../../Components';
|
|
6
|
+
import Contest from './Contest';
|
|
7
|
+
import { MarketMaketHelpers } from '../api';
|
|
8
|
+
import Colors from '../../constants/colors';
|
|
9
|
+
|
|
10
|
+
type DashboardProps = {
|
|
11
|
+
loaded:boolean,
|
|
12
|
+
leagues:LeagueProps[],
|
|
13
|
+
events:EventProps[],
|
|
14
|
+
markets:MarketProps[],
|
|
15
|
+
tournaments:TournamentProps[],
|
|
16
|
+
matches:MatchProps[],
|
|
17
|
+
best_available_orders:BestAvailableOrderProps[],
|
|
18
|
+
trades:TradeProps[],
|
|
19
|
+
orders:OrderProps[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Dashboard = ({ loaded, leagues, events, tournaments, matches, markets, orders, best_available_orders, trades }:DashboardProps) => {
|
|
23
|
+
const contests = MarketMaketHelpers.sortContests(events, tournaments, matches, markets)
|
|
24
|
+
const renderContests = (data:{item:SortedContestProps, index:number}) => {
|
|
25
|
+
const league = leagues.find(l => l.league_id == data.item.league_id)
|
|
26
|
+
const contest_orders = orders.filter(o => o.event_type == data.item.contest_type && o.event_id == data.item.id);
|
|
27
|
+
const contest_trades = trades.filter(t => t.event_type == data.item.contest_type && t.event_id == data.item.id);
|
|
28
|
+
const contest_ba = best_available_orders.filter(o => o.event_type == data.item.contest_type && o.event_id == data.item.id);
|
|
29
|
+
return (
|
|
30
|
+
<Contest
|
|
31
|
+
contest_id={data.item.id}
|
|
32
|
+
contest_type={data.item.contest_type}
|
|
33
|
+
league={league}
|
|
34
|
+
contest_title={data.item.title}
|
|
35
|
+
latest_trades={contest_trades}
|
|
36
|
+
best_available_orders={contest_ba}
|
|
37
|
+
external_prices={[]}
|
|
38
|
+
orders={contest_orders}
|
|
39
|
+
markets={data.item.markets}
|
|
40
|
+
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<View style={{ ...view_styles.section, flexGrow:1 }}>
|
|
47
|
+
<View style={{ ...view_styles.section_header }}>
|
|
48
|
+
<View style={{ flex:1 }}>
|
|
49
|
+
<Text theme='header'>Dashboard</Text>
|
|
50
|
+
<Text style={{ marginTop:3 }} theme='body'>Select contests and markets to see activity and market options</Text>
|
|
51
|
+
</View>
|
|
52
|
+
</View>
|
|
53
|
+
<View style={{ ...view_styles.section_body }}>
|
|
54
|
+
<FlatList
|
|
55
|
+
data={contests}
|
|
56
|
+
renderItem={renderContests}
|
|
57
|
+
keyExtractor={(item) => `${item.contest_type}${item.id}`}
|
|
58
|
+
/>
|
|
59
|
+
</View>
|
|
60
|
+
{!loaded ?
|
|
61
|
+
<View style={{ position:'absolute', top:0, left:0, right:0, bottom:0, backgroundColor:Colors.shades.black_faded, justifyContent:'center', alignItems:'center' }}>
|
|
62
|
+
<View style={{ ...view_styles.section, minWidth:200, minHeight:200, justifyContent:'center', alignItems:'center' }}>
|
|
63
|
+
<ActivityIndicator style={{ alignSelf:'center'}} size='large' color={Colors.brand.midnight} />
|
|
64
|
+
<Text style={{ marginTop:10 }} theme='header_2'>Loading Your Data...</Text>
|
|
65
|
+
</View>
|
|
66
|
+
</View>
|
|
67
|
+
:<></>}
|
|
68
|
+
</View>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default Dashboard
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, FlatList, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { view_styles } from "../../constants/styles"
|
|
4
|
+
import type { MarketProps } from '../../types';
|
|
5
|
+
import { Checkbox, Text } from '../../Components';
|
|
6
|
+
import Colors from '../../constants/colors';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
type MarketSelectorProps = {
|
|
10
|
+
maxHeight?:number,
|
|
11
|
+
markets:MarketProps[],
|
|
12
|
+
selected_markets:string[],
|
|
13
|
+
onSelectMarket:(m:MarketProps) => void,
|
|
14
|
+
onDeselectMarket:(m:MarketProps) => void
|
|
15
|
+
}
|
|
16
|
+
const MarketSelector = ({ maxHeight, markets, selected_markets, onSelectMarket, onDeselectMarket }:MarketSelectorProps) => {
|
|
17
|
+
|
|
18
|
+
const renderMarkets = (data:{item:MarketProps, index:number}) => {
|
|
19
|
+
const selected = selected_markets.find(se => se == data.item.market_id) ? true : false;
|
|
20
|
+
return (
|
|
21
|
+
<TouchableOpacity style={{ ...view_styles.body_row, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }} onPress={() => selected ? onDeselectMarket(data.item) : onSelectMarket(data.item)}>
|
|
22
|
+
<Checkbox checked={selected} disabled onSelect={() => console.log('')}/>
|
|
23
|
+
<View style={{ flex:1, marginLeft:10 }}>
|
|
24
|
+
<Text size={12} weight='bold' color={Colors.brand.midnight}>{data.item.type == 'Stat' ? data.item.stat_label : data.item.type}</Text>
|
|
25
|
+
<Text style={{ marginTop:3 }} theme='body_2'>{data.item.description}</Text>
|
|
26
|
+
</View>
|
|
27
|
+
</TouchableOpacity>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
return (
|
|
31
|
+
<View style={{ ...view_styles.section, maxHeight }}>
|
|
32
|
+
<View style={{ ...view_styles.section_header }}>
|
|
33
|
+
<View style={{ flex:1 }}>
|
|
34
|
+
<Text theme='header'>Select Market</Text>
|
|
35
|
+
<Text style={{ marginTop:3 }} theme='body_2'>Manage the markets that are shown on the dashboard</Text>
|
|
36
|
+
</View>
|
|
37
|
+
</View>
|
|
38
|
+
<View style={{ ...view_styles.section_body }}>
|
|
39
|
+
<FlatList
|
|
40
|
+
key={'market_selector'}
|
|
41
|
+
data={markets}
|
|
42
|
+
renderItem={renderMarkets}
|
|
43
|
+
keyExtractor={(item) => item.market_id.toString()}
|
|
44
|
+
/>
|
|
45
|
+
</View>
|
|
46
|
+
</View>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default MarketSelector
|