be-components 1.3.0 → 1.3.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/Competition/api/index.js +1 -1
- package/lib/commonjs/Competition/api/index.js.map +1 -1
- package/lib/commonjs/Competition/components/CompetitionPlay.js +1 -1
- package/lib/commonjs/Competition/components/CompetitionPlay.js.map +1 -1
- package/lib/commonjs/Competition/components/MarketsCard.js.map +1 -1
- package/lib/commonjs/Competition/index.js +1 -1
- package/lib/commonjs/Competition/index.js.map +1 -1
- package/lib/commonjs/CompetitionManager/api/index.js +153 -35
- package/lib/commonjs/CompetitionManager/api/index.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/AthleteSelector.js +170 -0
- package/lib/commonjs/CompetitionManager/components/AthleteSelector.js.map +1 -0
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js +495 -423
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionHeader.js +134 -0
- package/lib/commonjs/CompetitionManager/components/CompetitionHeader.js.map +1 -0
- package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js +96 -73
- package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionMatchMarketCard.js +147 -127
- package/lib/commonjs/CompetitionManager/components/CompetitionMatchMarketCard.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js +38 -127
- package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/ContestSelector.js +388 -0
- package/lib/commonjs/CompetitionManager/components/ContestSelector.js.map +1 -0
- package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js +436 -0
- package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js.map +1 -0
- package/lib/commonjs/CompetitionManager/components/MarketSelector.js +36 -26
- package/lib/commonjs/CompetitionManager/components/MarketSelector.js.map +1 -1
- package/lib/commonjs/CompetitionManager/index.js +477 -18
- package/lib/commonjs/CompetitionManager/index.js.map +1 -1
- package/lib/commonjs/Components/SearchBox.js +82 -0
- package/lib/commonjs/Components/SearchBox.js.map +1 -0
- package/lib/module/Competition/api/index.js +1 -1
- package/lib/module/Competition/api/index.js.map +1 -1
- package/lib/module/Competition/components/CompetitionPlay.js +1 -1
- package/lib/module/Competition/components/CompetitionPlay.js.map +1 -1
- package/lib/module/Competition/components/MarketsCard.js.map +1 -1
- package/lib/module/Competition/index.js +1 -1
- package/lib/module/Competition/index.js.map +1 -1
- package/lib/module/CompetitionManager/api/index.js +153 -35
- package/lib/module/CompetitionManager/api/index.js.map +1 -1
- package/lib/module/CompetitionManager/components/AthleteSelector.js +161 -0
- package/lib/module/CompetitionManager/components/AthleteSelector.js.map +1 -0
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js +493 -425
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionHeader.js +127 -0
- package/lib/module/CompetitionManager/components/CompetitionHeader.js.map +1 -0
- package/lib/module/CompetitionManager/components/CompetitionInfoForm.js +99 -76
- package/lib/module/CompetitionManager/components/CompetitionInfoForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionMatchMarketCard.js +145 -127
- package/lib/module/CompetitionManager/components/CompetitionMatchMarketCard.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js +39 -131
- package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/ContestSelector.js +379 -0
- package/lib/module/CompetitionManager/components/ContestSelector.js.map +1 -0
- package/lib/module/CompetitionManager/components/ContestSettingsForm.js +428 -0
- package/lib/module/CompetitionManager/components/ContestSettingsForm.js.map +1 -0
- package/lib/module/CompetitionManager/components/MarketSelector.js +34 -26
- package/lib/module/CompetitionManager/components/MarketSelector.js.map +1 -1
- package/lib/module/CompetitionManager/index.js +478 -19
- package/lib/module/CompetitionManager/index.js.map +1 -1
- package/lib/module/Components/SearchBox.js +73 -0
- package/lib/module/Components/SearchBox.js.map +1 -0
- package/lib/typescript/src/CompetitionManager/api/index.d.ts +32 -3
- package/lib/typescript/src/CompetitionManager/api/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/AthleteSelector.d.ts +18 -0
- package/lib/typescript/src/CompetitionManager/components/AthleteSelector.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts +13 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionHeader.d.ts +20 -0
- package/lib/typescript/src/CompetitionManager/components/CompetitionHeader.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionManager/components/CompetitionInfoForm.d.ts +2 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionInfoForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionMatchMarketCard.d.ts +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionMatchMarketCard.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts +3 -3
- package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/ContestSelector.d.ts +16 -0
- package/lib/typescript/src/CompetitionManager/components/ContestSelector.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionManager/components/ContestSettingsForm.d.ts +15 -0
- package/lib/typescript/src/CompetitionManager/components/ContestSettingsForm.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionManager/components/MarketSelector.d.ts +3 -2
- package/lib/typescript/src/CompetitionManager/components/MarketSelector.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/index.d.ts +1 -1
- package/lib/typescript/src/CompetitionManager/index.d.ts.map +1 -1
- package/lib/typescript/src/Components/SearchBox.d.ts +10 -0
- package/lib/typescript/src/Components/SearchBox.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/Competition/api/index.ts +3 -3
- package/src/Competition/components/CompetitionPlay.tsx +1 -1
- package/src/Competition/components/MarketsCard.tsx +2 -2
- package/src/Competition/index.tsx +1 -1
- package/src/CompetitionManager/api/index.ts +71 -13
- package/src/CompetitionManager/components/AthleteSelector.tsx +127 -0
- package/src/CompetitionManager/components/CompetitionContestsForm.tsx +156 -261
- package/src/CompetitionManager/components/CompetitionHeader.tsx +101 -0
- package/src/CompetitionManager/components/CompetitionInfoForm.tsx +57 -45
- package/src/CompetitionManager/components/CompetitionMatchMarketCard.tsx +29 -70
- package/src/CompetitionManager/components/CompetitionSettingsForm.tsx +36 -103
- package/src/CompetitionManager/components/ContestSelector.tsx +269 -0
- package/src/CompetitionManager/components/ContestSettingsForm.tsx +281 -0
- package/src/CompetitionManager/components/MarketSelector.tsx +34 -23
- package/src/CompetitionManager/index.tsx +399 -15
- package/src/Components/SearchBox.tsx +54 -0
- package/src/types.d.ts +38 -4
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import React, { } from 'react';
|
|
2
|
-
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { FlatList, Image, TouchableOpacity, View } from "react-native"
|
|
3
3
|
import type { AthleteProps, CompetitionMatchMarketProps, CompetitionMatchProps, CompetitionProps, EventProps, LeagueProps, MarketProps, MatchProps, TeamProps, TournamentProps } from '../../types';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//import { view_styles } from '../../constants/styles';
|
|
10
|
-
//import MarketSelector from './MarketSelector';
|
|
4
|
+
import Colors from '../../constants/colors';
|
|
5
|
+
import { Button, Icons, Switch, Text } from '../../Components';
|
|
6
|
+
import CompetitionMatchMarketCard from './CompetitionMatchMarketCard';
|
|
7
|
+
import moment from 'moment-mini';
|
|
8
|
+
import { view_styles } from '../../constants/styles';
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
|
|
14
12
|
type CompetitionContestsFormProps = {
|
|
15
13
|
width:number,
|
|
14
|
+
action_loading:boolean,
|
|
15
|
+
is_valid?:boolean,
|
|
16
16
|
competition:CompetitionProps,
|
|
17
17
|
markets:MarketProps[],
|
|
18
18
|
leagues:LeagueProps[],
|
|
19
|
+
primary_markets:{ market:MarketProps, included:boolean}[],
|
|
19
20
|
events:EventProps[],
|
|
20
21
|
tournaments:TournamentProps[],
|
|
21
22
|
matches:MatchProps[],
|
|
@@ -23,6 +24,12 @@ type CompetitionContestsFormProps = {
|
|
|
23
24
|
teams:TeamProps[],
|
|
24
25
|
competition_matches: CompetitionMatchProps[],
|
|
25
26
|
competition_match_markets:CompetitionMatchMarketProps[],
|
|
27
|
+
onShowContests:() => void,
|
|
28
|
+
onAddPrimaryMarket:(market:MarketProps) => void,
|
|
29
|
+
onRemovePrimaryMarket:(market:MarketProps) => void,
|
|
30
|
+
onShowAthletes:(contest_id:string, contest_type:string, market_id:string) => void,
|
|
31
|
+
onShowMarkets:(contest_id:string, contest_type:string) => void,
|
|
32
|
+
onDeleteMarket:(contest_id:string, contest_type:string, market:MarketProps) => void,
|
|
26
33
|
onSaveCompetitionMatch:(competition_id:string, event_id:string, event_type:string, match_type:string, event:EventProps, market_id_override?:string, side_type_override?:string, side_id_override?:string) => void,
|
|
27
34
|
onUpdateCompetitionMatch:(cm:CompetitionMatchProps) => void,
|
|
28
35
|
onSaveCompetitionMatchMarkets: (cmms:CompetitionMatchMarketProps[]) => void,
|
|
@@ -31,176 +38,82 @@ type CompetitionContestsFormProps = {
|
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
|
|
34
|
-
const CompetitionContestsForm = ({
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const CompetitionContestsForm = ({
|
|
42
|
+
is_valid,
|
|
43
|
+
competition,
|
|
44
|
+
width,
|
|
45
|
+
primary_markets,
|
|
46
|
+
events,
|
|
47
|
+
athletes,
|
|
48
|
+
markets,
|
|
49
|
+
leagues,
|
|
50
|
+
competition_matches,
|
|
51
|
+
competition_match_markets,
|
|
52
|
+
onDeleteMarket,
|
|
53
|
+
onRemovePrimaryMarket,
|
|
54
|
+
onDeleteCompetitionMatch,
|
|
55
|
+
onDeleteCompetitionMatchMarkets,
|
|
56
|
+
onShowAthletes,
|
|
57
|
+
onShowContests,
|
|
58
|
+
onShowMarkets,
|
|
59
|
+
onAddPrimaryMarket,
|
|
60
|
+
}:CompetitionContestsFormProps) => {
|
|
37
61
|
const [ expanded, setExpanded ] = useState(true);
|
|
38
|
-
const [ contests_visible, setContestsVisible ] = useState(false);
|
|
39
62
|
const [ show_match_markets, setShowMatchMarkets ] = useState<string[]>([]);
|
|
40
|
-
const [
|
|
41
|
-
const [
|
|
42
|
-
const [ competition_summaries, setCompetitionSummaries ] = useState<any[]>([]);
|
|
43
|
-
const [ show_athletes, setShowAthletes ] = useState<{
|
|
44
|
-
visible:boolean,
|
|
45
|
-
event_id?:string,
|
|
46
|
-
event_type?:string,
|
|
47
|
-
market_id?:string,
|
|
48
|
-
team_ids:string[],
|
|
49
|
-
restricted_ids?:string[],
|
|
50
|
-
top:number,
|
|
51
|
-
right:number,
|
|
52
|
-
positions:string[],
|
|
53
|
-
selected_athletes:string[],
|
|
63
|
+
const [ active_contest_type ] = useState('team');
|
|
64
|
+
const [ expanded_contests, setExpandedContests ] = useState<string[]>([]);
|
|
54
65
|
|
|
55
|
-
}>({
|
|
56
|
-
visible:false,
|
|
57
|
-
positions:[],
|
|
58
|
-
top:0,
|
|
59
|
-
right:0,
|
|
60
|
-
selected_athletes:[],
|
|
61
|
-
team_ids:[]
|
|
62
|
-
})
|
|
63
|
-
const [ show_markets, setShowMarkets ] = useState<{
|
|
64
|
-
visible:boolean,
|
|
65
|
-
event_id?:string,
|
|
66
|
-
event_type?: string,
|
|
67
|
-
selected_markets:string[],
|
|
68
|
-
supported_markets:MarketProps[],
|
|
69
|
-
}>({
|
|
70
|
-
visible:false,
|
|
71
|
-
supported_markets: [],
|
|
72
|
-
selected_markets: [],
|
|
73
|
-
});
|
|
74
66
|
const unique_team_events = [ ...new Set(competition_matches.filter(cm => cm.event_type == 'team').map(cm => cm.event_id)) ]
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if(!show_athletes?.event_id){ return alert('Unable to process') }
|
|
88
|
-
setAthletes(athletes.concat(athlete))
|
|
89
|
-
let latest_trades = await MarketApi.getLatestTradesByEventIds([show_athletes.event_id], show_athletes.event_type);
|
|
90
|
-
latest_trades = latest_trades.filter(lt => lt.market_id == show_athletes.market_id && lt.market_type == 'FOR_MONEY' && lt.side_type == 'athlete' && lt.side_id == athlete.athlete_id);
|
|
91
|
-
if(latest_trades.length !== 2){ return alert('We do not have data for this athlete') }
|
|
92
|
-
//First we need to check if we have an empty competition match (match with no side_id_override)
|
|
93
|
-
const existing_cm = competition_matches.find(cm => cm.event_id == show_athletes.event_id && cm.event_type == show_athletes.event_type && cm.market_id_override == show_athletes.market_id && !cm.side_id_override);
|
|
94
|
-
if(existing_cm){
|
|
95
|
-
//Then we just need to add the side_id override to the cm and then create the cmms
|
|
96
|
-
onUpdateCompetitionMatch({ ...existing_cm, side_id_override: athlete.athlete_id })
|
|
97
|
-
//Create the cmms
|
|
98
|
-
const cmms:CompetitionMatchMarketProps[] = []
|
|
99
|
-
latest_trades.map(t => cmms.push({ ...createCompetitionMatchMarketFromTrade(t), competition_match_id: existing_cm.competition_match_id }))
|
|
100
|
-
if(cmms.length != 2){ return alert('Unable to process') }
|
|
101
|
-
onSaveCompetitionMatchMarkets(cmms)
|
|
102
|
-
} else {
|
|
103
|
-
//There was not an existing placeholder - we now need to auto create a match
|
|
104
|
-
switch(show_athletes.event_type){
|
|
105
|
-
case 'team':
|
|
106
|
-
const event = team_events.find(e => e.event_id == show_athletes.event_id)
|
|
107
|
-
if(!event){ return alert('Unable to process') }
|
|
108
|
-
const new_cm = await onSaveCompetitionMatch(competition.competition_id, show_athletes.event_id, show_athletes.event_type, 'athlete', event, show_athletes.market_id, 'athlete', athlete.athlete_id);
|
|
109
|
-
const cmms:CompetitionMatchMarketProps[] = []
|
|
110
|
-
latest_trades.map(t => cmms.push({ ...createCompetitionMatchMarketFromTrade(t), competition_match_id: new_cm.competition_match_id }))
|
|
111
|
-
if(cmms.length != 2){ return alert('Unable to process') }
|
|
112
|
-
onSaveCompetitionMatchMarkets(cmms)
|
|
113
|
-
break
|
|
114
|
-
default: return alert('Not handled for this!')
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
setShowAthletes({
|
|
118
|
-
...show_athletes,
|
|
119
|
-
selected_athletes: show_athletes.selected_athletes.concat(athlete.athlete_id)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
|
-
/*
|
|
126
|
-
|
|
127
|
-
const handleSelectMarket = async(market:MarketProps) => {
|
|
128
|
-
|
|
129
|
-
if(!show_markets){ return alert('Unable to process') }
|
|
130
|
-
if(market.level == 'event' && market.primary_market){
|
|
131
|
-
let competition_match = competition_matches.find(cm => cm.event_id == show_markets.event_id && cm.event_type == show_markets.event_type && !cm.market_id_override)
|
|
132
|
-
if(!competition_match){ return alert('Unable to process this primary market!') }
|
|
133
|
-
//HERE IS HWERE WE WILL CREATE THE EMPTY MATCH MARKET!
|
|
134
|
-
let latest_trades = await MarketApi.getLatestTradesByEventIds([show_markets.event_id], show_markets.event_type);
|
|
135
|
-
latest_trades = latest_trades.filter(lt => lt.market_id == market.market_id && lt.market_type == 'FOR_MONEY');
|
|
136
|
-
if(latest_trades.length != 2){ return alert('Unable to add this market') }
|
|
137
|
-
const cmms:CompetitionMatchMarketProps[] = []
|
|
138
|
-
latest_trades.map(t => cmms.push({ ...createCompetitionMatchMarketFromTrade(t), competition_match_id: competition_match.competition_match_id }))
|
|
139
|
-
if(cmms.length != 2){ return alert('Unable to process') }
|
|
140
|
-
onSaveCompetitionMatchMarkets(cmms)
|
|
141
|
-
setShowMarkets({ ...show_markets, selected_markets: show_markets.selected_markets.concat(market.market_id)})
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
//Okay! This was a non-primary market
|
|
145
|
-
//There will not be an existing competition match so we need to create a new one!
|
|
146
|
-
if(market.event_type == 'team'){
|
|
147
|
-
let event = team_events.find(e => e.event_id == show_markets.event_id);
|
|
148
|
-
if(!event){ return alert('Unable to process this') }
|
|
149
|
-
onSaveCompetitionMatch(competition.competition_id, show_markets.event_id, show_markets.event_type, market.level, event, market.market_id, market.level, undefined);
|
|
150
|
-
setShowMarkets({ ...show_markets, selected_markets: show_markets.selected_markets.concat(market.market_id)})
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
|
|
68
|
+
const renderPrimaryMarkets = (data: { item:{ market:MarketProps, included:boolean }, index:number }) => {
|
|
69
|
+
return (
|
|
70
|
+
<View style={{ padding:10, width:100, borderRadius:8, backgroundColor:Colors.shades.white, margin:5, ...view_styles.float }}>
|
|
71
|
+
<Text style={{ marginBottom:10 }} theme='header'>{data.item.market.type}</Text>
|
|
72
|
+
<Switch
|
|
73
|
+
switch_type='on_off'
|
|
74
|
+
value={data.item.included}
|
|
75
|
+
onChange={(val) => val ? onAddPrimaryMarket(data.item.market) : onRemovePrimaryMarket(data.item.market)}
|
|
76
|
+
/>
|
|
77
|
+
</View>
|
|
78
|
+
)
|
|
154
79
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/*
|
|
158
|
-
|
|
80
|
+
|
|
159
81
|
const renderMarkets = (data: { item:string, index:number, event_id:string, event_type:string }) => {
|
|
160
82
|
const market = markets.find(m => m.market_id == data.item);
|
|
161
83
|
if(!market){ return <></> }
|
|
162
84
|
const show_details = show_match_markets.includes(`${data.event_type}:${data.event_id}:${data.item}`) ? true : false
|
|
163
85
|
|
|
164
86
|
return (
|
|
165
|
-
<TouchableOpacity style={{ flex:1,borderRadius:8, borderWidth:1, borderColor:Colors.shades.shade600, padding:10, margin:3,
|
|
87
|
+
<TouchableOpacity style={{ flex:1, borderRadius:8, borderWidth:1, borderColor:Colors.shades.shade600, padding:10, margin:3, minWidth:125, backgroundColor:show_details ? Colors.brand.midnight : Colors.shades.white }}
|
|
166
88
|
onPress={() => {
|
|
167
89
|
if(show_details){ return setShowMatchMarkets(show_match_markets.filter(smm => smm != `${data.event_type}:${data.event_id}:${data.item}`)) }
|
|
168
90
|
return setShowMatchMarkets(show_match_markets.concat(`${data.event_type}:${data.event_id}:${data.item}`))
|
|
169
91
|
}}>
|
|
170
|
-
<
|
|
171
|
-
|
|
92
|
+
<View style={{ flexDirection:'row' }}>
|
|
93
|
+
<Button
|
|
94
|
+
title='X'
|
|
95
|
+
title_color={Colors.shades.white}
|
|
96
|
+
backgroundColor={Colors.utility.error}
|
|
97
|
+
onPress={async() => {
|
|
98
|
+
const confirmed = await confirm('Are you sure you want to delete this market?')
|
|
99
|
+
if(!confirmed){ return }
|
|
100
|
+
onDeleteMarket(data.event_id, data.event_type, market);
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
<View style={{ flex:1 }}>
|
|
104
|
+
<Text size={14} color={show_details?Colors.shades.white:Colors.brand.midnight} weight="bold" textAlign="center">{market.stat_label ?? market.type}</Text>
|
|
105
|
+
<Text style={{ marginTop:3 }} size={12} color={show_details?Colors.shades.white:Colors.brand.midnight} textAlign="center">{market.description}</Text>
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
172
108
|
{market.level == 'athlete' && show_details ?
|
|
173
109
|
<Button
|
|
174
|
-
title="
|
|
175
|
-
title_size={10}
|
|
110
|
+
title="ADD ATHLETE"
|
|
176
111
|
style={{ marginTop:5 }}
|
|
112
|
+
padding={10}
|
|
177
113
|
title_color={Colors.brand.electric}
|
|
178
114
|
backgroundColor={Colors.shades.white}
|
|
179
|
-
onPress={
|
|
180
|
-
|
|
181
|
-
if(data.event_type != 'team'){ return alert('Only supported for team based events currently') }
|
|
182
|
-
|
|
183
|
-
let latest_trades = await MarketApi.getLatestTradesByEventIds([data.event_id], data.event_type);
|
|
184
|
-
latest_trades = latest_trades.filter(lt => lt.market_id == data.item && lt.market_type == 'FOR_MONEY' && lt.side_type == 'athlete');
|
|
185
|
-
let restricted_ids = [ ...new Set(latest_trades.map(t => t.side_id)) ]
|
|
186
|
-
const event = team_events.find(e => e.event_id == data.event_id)
|
|
187
|
-
let team_ids = [event.away_team_id, event.home_team_id]
|
|
188
|
-
|
|
189
|
-
const selected_athletes = competition_matches.filter(cm => cm.event_id == data.event_id && cm.event_type == data.event_type && cm.market_id_override == data.item && cm.side_type_override=='athlete').map(cm => cm.side_id_override);
|
|
190
|
-
|
|
191
|
-
setShowAthletes({
|
|
192
|
-
visible: true,
|
|
193
|
-
selected_athletes,
|
|
194
|
-
team_ids,
|
|
195
|
-
market_id:data.item,
|
|
196
|
-
restricted_ids,
|
|
197
|
-
positions:market.supported_positions ?? [],
|
|
198
|
-
event_id:data.event_id,
|
|
199
|
-
event_type: data.event_type,
|
|
200
|
-
top:evt.nativeEvent.offsetX,
|
|
201
|
-
right:evt.nativeEvent.offsetY
|
|
202
|
-
})
|
|
203
|
-
|
|
115
|
+
onPress={() => {
|
|
116
|
+
onShowAthletes(data.event_id, data.event_type, data.item);
|
|
204
117
|
}}
|
|
205
118
|
/>
|
|
206
119
|
:<></>}
|
|
@@ -208,9 +121,8 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
208
121
|
|
|
209
122
|
)
|
|
210
123
|
}
|
|
211
|
-
*/
|
|
212
124
|
|
|
213
|
-
|
|
125
|
+
|
|
214
126
|
const showDetails = (show_event_id:string, show_event_type:string) => {
|
|
215
127
|
|
|
216
128
|
let show_cms:CompetitionMatchProps[] = []
|
|
@@ -222,8 +134,10 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
222
134
|
if(event_id != show_event_id){ return }
|
|
223
135
|
if(show_event_type != event_type){ return }
|
|
224
136
|
const market = markets.find(m => m.market_id == market_id);
|
|
137
|
+
if(!market){ return }
|
|
225
138
|
if(market.level == 'event' && market.primary_market){
|
|
226
139
|
const primary_cm = competition_matches.find(cm => cm.event_id == event_id && cm.event_type == event_type && !cm.market_id_override);
|
|
140
|
+
if(!primary_cm){ return }
|
|
227
141
|
const primary_cmms = competition_match_markets.filter(cmm => cmm.competition_match_id == primary_cm?.competition_match_id && cmm.market_id == market_id);
|
|
228
142
|
show_cms.push({ ...primary_cm, competition_match_markets:primary_cmms })
|
|
229
143
|
}
|
|
@@ -231,27 +145,23 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
231
145
|
const cms = competition_matches.filter(cm => cm.event_id == event_id && cm.event_type == event_type && cm.market_id_override == market_id)
|
|
232
146
|
cms.map(cm => {
|
|
233
147
|
let cmm = competition_match_markets.filter(cmm => cmm.competition_match_id == cm.competition_match_id);
|
|
234
|
-
if(cmm.length == 2){
|
|
148
|
+
//if(cmm.length == 2){
|
|
235
149
|
show_cms.push({ ...cm, competition_match_markets: cmm })
|
|
236
|
-
}
|
|
150
|
+
//}
|
|
237
151
|
})
|
|
238
152
|
}
|
|
239
|
-
|
|
240
153
|
})
|
|
154
|
+
|
|
241
155
|
return show_cms
|
|
242
|
-
|
|
243
|
-
return []
|
|
244
156
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
/*
|
|
157
|
+
|
|
248
158
|
|
|
249
159
|
const getMatchTitle = (cm:CompetitionMatchProps, market:MarketProps):{image_url?:string, header:string, description:string} => {
|
|
250
160
|
|
|
251
161
|
let error = { header: 'Market', description:market.description }
|
|
252
162
|
switch(cm.event_type){
|
|
253
163
|
case 'team':
|
|
254
|
-
const event =
|
|
164
|
+
const event = events.find(e => e.event_id == cm.event_id)
|
|
255
165
|
if(!event){ return error }
|
|
256
166
|
if(!cm.market_id_override){
|
|
257
167
|
//This is a primary one that we can just do the market name and event title
|
|
@@ -268,20 +178,14 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
268
178
|
}
|
|
269
179
|
|
|
270
180
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
/*
|
|
181
|
+
|
|
274
182
|
|
|
275
183
|
const renderCompetitionMatches = (data: { item:CompetitionMatchProps, index:number }) => {
|
|
276
|
-
if(!data.item.competition_match_markets){ return }
|
|
184
|
+
if(!data.item.competition_match_markets){ return <></> }
|
|
277
185
|
const market = markets.find(m => data.item.competition_match_markets && m.market_id == data.item.competition_match_markets[0]?.market_id)
|
|
278
186
|
if(!market){ return <></> }
|
|
279
187
|
|
|
280
188
|
const { image_url, header, description } = getMatchTitle(data.item, market)
|
|
281
|
-
let match_summaries = competition_summaries.filter(cs => cs.competition_match_id == data.item.competition_match_id && cs.market_id == market.market_id)
|
|
282
|
-
if(data.item.side_id_override){
|
|
283
|
-
match_summaries = match_summaries.filter(ms => ms.side_id == data.item.side_id_override);
|
|
284
|
-
}
|
|
285
189
|
return (
|
|
286
190
|
<View style={{ padding:10, flexDirection:'row', alignItems:'center', borderBottomWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
287
191
|
<Button
|
|
@@ -292,9 +196,9 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
292
196
|
title_color={Colors.utility.error}
|
|
293
197
|
onPress={() => {
|
|
294
198
|
if(data.item.market_id_override){
|
|
295
|
-
|
|
199
|
+
return onDeleteCompetitionMatch(data.item.competition_match_id)
|
|
296
200
|
}
|
|
297
|
-
|
|
201
|
+
return onDeleteCompetitionMatchMarkets(data.item.competition_match_markets ?? [])
|
|
298
202
|
}}
|
|
299
203
|
/>
|
|
300
204
|
{image_url ?
|
|
@@ -315,7 +219,7 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
315
219
|
event_type={data.item.event_type}
|
|
316
220
|
competition_match_id={data.item.competition_match_id}
|
|
317
221
|
competition_match_markets={data.item.competition_match_markets}
|
|
318
|
-
competition_summaries={
|
|
222
|
+
competition_summaries={[]}
|
|
319
223
|
market={market}
|
|
320
224
|
onSaveMarkets={(cmms) => console.log(cmms)}
|
|
321
225
|
onUpdateMarkets={(cmms) => console.log(cmms)}
|
|
@@ -329,16 +233,18 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
329
233
|
const event = events.find(e => e.event_id == data.item);
|
|
330
234
|
if(!event){ return <></> }
|
|
331
235
|
if(!event.supported_markets){ return <></> }
|
|
332
|
-
const supported_markets = markets.filter(m => event.supported_markets?.map(sm => sm.market_id.toString()).includes(m.market_id.toString()));
|
|
333
236
|
const cms = competition_matches.filter(cm => cm.event_id == data.item && cm.event_type == 'team');
|
|
334
237
|
const cmms = competition_match_markets.filter(cmm => cms.map(cm => cm.competition_match_id.toString()).includes(cmm.competition_match_id));
|
|
335
|
-
const unique_market_ids = [ ...new Set(cmms.map(cmm => cmm.market_id).concat(cms.filter(cm => cm.market_id_override).map(cm => cm.market_id_override))) ]
|
|
238
|
+
const unique_market_ids = [ ...new Set(cmms.map(cmm => cmm.market_id).concat(cms.filter(cm => cm.market_id_override).map(cm => cm.market_id_override ?? '0'))) ]
|
|
336
239
|
const league = leagues.find(l => l.league_id == event.league_id);
|
|
337
240
|
const visible_matches = showDetails(data.item, 'team')
|
|
338
|
-
|
|
241
|
+
const expanded = expanded_contests.includes(`${event.event_id}:team`) ? true : false
|
|
339
242
|
return (
|
|
340
|
-
<View style={{
|
|
341
|
-
<
|
|
243
|
+
<View style={{ margin:5, backgroundColor:Colors.shades.white, zIndex: data.index * -1, maxWidth:width }}>
|
|
244
|
+
<TouchableOpacity style={{ flexDirection:'row', alignItems:'center', padding:15, zIndex:1}} onPress={() => {
|
|
245
|
+
if(expanded){ return setExpandedContests(expanded_contests.filter(c => c != `${event.event_id}:team`)) }
|
|
246
|
+
else { return setExpandedContests(expanded_contests.concat(`${event.event_id}:team`)) }
|
|
247
|
+
}}>
|
|
342
248
|
{['pending','paused'].includes(competition.status) && cms.length == 1 && cmms.length == 0 ?
|
|
343
249
|
<Button
|
|
344
250
|
title="X"
|
|
@@ -346,10 +252,10 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
346
252
|
borderRadius={8}
|
|
347
253
|
borderWidth={1}
|
|
348
254
|
borderColor={Colors.utility.error}
|
|
349
|
-
onPress={() => onDeleteCompetitionMatch(cms[0]?.competition_match_id)}
|
|
255
|
+
onPress={() => onDeleteCompetitionMatch(cms[0]?.competition_match_id ?? '')}
|
|
350
256
|
/>
|
|
351
257
|
:<></>}
|
|
352
|
-
<View style={{ flex:1, flexDirection:'row', alignItems:'center' }}>
|
|
258
|
+
<View style={{ flex:1, marginLeft:5, flexDirection:'row', alignItems:'center' }}>
|
|
353
259
|
{league?.league_image ?
|
|
354
260
|
<Image
|
|
355
261
|
source={{ uri: league.league_image }}
|
|
@@ -357,39 +263,29 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
357
263
|
resizeMode="cover"
|
|
358
264
|
/>
|
|
359
265
|
:<></>}
|
|
360
|
-
<View>
|
|
361
|
-
<Text size={14} color={Colors.brand.midnight} weight='bold'>{event.away
|
|
266
|
+
<View style={{ flex:1 }}>
|
|
267
|
+
<Text size={14} color={Colors.brand.midnight} weight='bold'>{event.away?.market_name} {event.away?.name} vs {event.home?.market_name} {event.home?.name}</Text>
|
|
362
268
|
<Text style={{ marginTop:4 }} size={12} color={Colors.brand.midnight}>{moment(event.scheduled_datetime).format('MMMM DD hh:mm a')}</Text>
|
|
363
269
|
</View>
|
|
364
270
|
</View>
|
|
365
|
-
<
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
visible={show_markets.event_id == data.item ? true : false}
|
|
382
|
-
markets={show_markets.supported_markets}
|
|
383
|
-
selected_markets={show_markets.selected_markets}
|
|
384
|
-
onSelectMarket={(market) => handleSelectMarket(market)}
|
|
385
|
-
onDeselectMarket={(market) => console.log(market)}
|
|
386
|
-
onClose={() => setShowMarkets({ visible: false, supported_markets:[], selected_markets:[] })}
|
|
271
|
+
<View style={{ marginLeft:5, marginRight:5, height:25, width:25, justifyContent:'center', alignItems:'center', borderRadius:100, backgroundColor:Colors.brand.electric }}>
|
|
272
|
+
<Text size={10} color={Colors.shades.white} weight='bold'>{unique_market_ids.length}</Text>
|
|
273
|
+
</View>
|
|
274
|
+
<Icons.ChevronIcon direction={expanded ? 'up' : 'down'} size={8} color={Colors.brand.midnight} />
|
|
275
|
+
</TouchableOpacity>
|
|
276
|
+
{expanded ?
|
|
277
|
+
<View style={{ padding:10 }}>
|
|
278
|
+
<View style={{ flexDirection:'row', marginBottom:5 }}>
|
|
279
|
+
<Text style={{ flex:1 }} size={16} weight='bold'>Selected Markets</Text>
|
|
280
|
+
<Button
|
|
281
|
+
title="Add Markets"
|
|
282
|
+
title_color={Colors.shades.white}
|
|
283
|
+
backgroundColor={Colors.brand.midnight}
|
|
284
|
+
onPress={() => {
|
|
285
|
+
onShowMarkets(data.item, 'team');
|
|
286
|
+
}}
|
|
387
287
|
/>
|
|
388
288
|
</View>
|
|
389
|
-
</View>
|
|
390
|
-
{unique_market_ids.length > 0 ?
|
|
391
|
-
<View style={{ padding:10, backgroundColor:Colors.shades.shade100 }}>
|
|
392
|
-
<Text style={{ marginBottom:5 }} size={16} weight='bold'>Selected Markets</Text>
|
|
393
289
|
<View style={{ flexDirection:'row', flexWrap: 'wrap', padding:10 }}>
|
|
394
290
|
{unique_market_ids.map((market_id, index) => {
|
|
395
291
|
return (
|
|
@@ -410,64 +306,63 @@ const CompetitionContestsForm = ({ }:CompetitionContestsFormProps) => {
|
|
|
410
306
|
)
|
|
411
307
|
}
|
|
412
308
|
|
|
413
|
-
*/
|
|
414
309
|
|
|
415
|
-
|
|
416
|
-
|
|
310
|
+
|
|
311
|
+
|
|
417
312
|
return (
|
|
418
313
|
<View style={{ ...view_styles.section, minWidth:350, flexGrow:1, maxWidth:width }}>
|
|
419
|
-
<TouchableOpacity style={{ ...view_styles.section_header }} onPress={() => setExpanded(!expanded)}>
|
|
420
|
-
|
|
314
|
+
<TouchableOpacity style={{ ...view_styles.section_header, maxWidth:width }} onPress={() => setExpanded(!expanded)}>
|
|
315
|
+
{is_valid ?
|
|
316
|
+
<Icons.CheckCirlceIcon size={16} color={Colors.utility.success} />
|
|
317
|
+
:
|
|
318
|
+
<Icons.AlertIcon size={16} color={Colors.utility.warning} />
|
|
319
|
+
}
|
|
320
|
+
<View style={{ flex:1, marginRight:10, marginLeft:10 }}>
|
|
421
321
|
<Text theme='header'>Competition Contests</Text>
|
|
422
322
|
<Text style={{ marginTop:3 }} theme='body'>Competitions require contests for users to make picks / wagers. Select 'Add Contests' to get started.</Text>
|
|
423
323
|
</View>
|
|
424
324
|
<Icons.ChevronIcon direction={expanded ? 'up' : 'down'} size={8} color={Colors.brand.midnight} />
|
|
425
325
|
</TouchableOpacity>
|
|
426
326
|
{expanded ?
|
|
427
|
-
<View style={{ ...view_styles.section_body }}>
|
|
428
|
-
{
|
|
429
|
-
|
|
430
|
-
|
|
327
|
+
<View style={{ ...view_styles.section_body, padding:0, backgroundColor:Colors.shades.shade100 }}>
|
|
328
|
+
<View style={{ ...view_styles.section_header }}>
|
|
329
|
+
<TouchableOpacity style={{ flex:1 }}>
|
|
330
|
+
<Text theme='header'>Team Events</Text>
|
|
331
|
+
<Text style={{ marginTop:3 }} theme='body'>Select team based events to include in this competition</Text>
|
|
332
|
+
</TouchableOpacity>
|
|
333
|
+
<Button
|
|
334
|
+
title='ADD'
|
|
335
|
+
padding={10}
|
|
336
|
+
title_color={Colors.shades.white}
|
|
337
|
+
backgroundColor={Colors.utility.success}
|
|
338
|
+
onPress={() => onShowContests()}
|
|
339
|
+
/>
|
|
340
|
+
</View>
|
|
341
|
+
<View style={{ padding:10 }}>
|
|
342
|
+
<Text style={{ padding:10 }} theme='header_2'>The following markets can be added to all events</Text>
|
|
343
|
+
<View style={{ padding:5 }}>
|
|
344
|
+
<FlatList
|
|
345
|
+
data={primary_markets}
|
|
346
|
+
renderItem={renderPrimaryMarkets}
|
|
347
|
+
horizontal
|
|
348
|
+
keyExtractor={(item) => item.market.market_id.toString()}
|
|
349
|
+
/>
|
|
350
|
+
</View>
|
|
351
|
+
</View>
|
|
352
|
+
<View style={{ ...view_styles.section_body, padding:0 }}>
|
|
353
|
+
{active_contest_type == 'team' ?
|
|
354
|
+
<View>
|
|
355
|
+
{unique_team_events.map((id, index) => {
|
|
356
|
+
return renderTeamEvents({ item:id, index })
|
|
357
|
+
})}
|
|
358
|
+
</View>
|
|
359
|
+
:<></>}
|
|
360
|
+
</View>
|
|
431
361
|
</View>
|
|
432
362
|
:<></>}
|
|
433
363
|
</View>
|
|
434
364
|
)
|
|
435
|
-
|
|
365
|
+
|
|
436
366
|
}
|
|
437
367
|
|
|
438
|
-
export default CompetitionContestsForm
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
/*
|
|
443
|
-
<View style={{ position:'absolute', top:show_athletes.top, right:show_athletes.right }}>
|
|
444
|
-
<AthleteSelector
|
|
445
|
-
onClose={() => setShowAthletes({ visible:false, positions:[], selected_athletes: [], top:0, right:0, team_ids:[] })}
|
|
446
|
-
onDeselectAthlete={(athlete) => console.log(athlete)}
|
|
447
|
-
onSelectAthlete={(athlete) => handleSelectAthlete(athlete)}
|
|
448
|
-
team_ids={show_athletes.team_ids}
|
|
449
|
-
restricted_ids={show_athletes.restricted_ids}
|
|
450
|
-
selected_athletes={show_athletes.selected_athletes}
|
|
451
|
-
visible={show_athletes.visible}
|
|
452
|
-
/>
|
|
453
|
-
</View>
|
|
454
|
-
*/
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
/*
|
|
458
|
-
<Button
|
|
459
|
-
title="Add Contests"
|
|
460
|
-
backgroundColor={Colors.brand.electric}
|
|
461
|
-
title_color={Colors.shades.white}
|
|
462
|
-
onPress={() => setContestsVisible(true)}
|
|
463
|
-
/>
|
|
464
|
-
<View style={{ position:'absolute', top:0, right:0 }}>
|
|
465
|
-
<ContestSelector
|
|
466
|
-
visible={contests_visible}
|
|
467
|
-
selected_events={unique_team_events}
|
|
468
|
-
onSelectEvent={(event) => handleSelectEvent(event)}
|
|
469
|
-
onDeselectEvent={(event) => console.log(event)}
|
|
470
|
-
onClose={() => setContestsVisible(false)}
|
|
471
|
-
/>
|
|
472
|
-
</View>
|
|
473
|
-
*/
|
|
368
|
+
export default CompetitionContestsForm
|