be-components 6.9.1 → 6.9.3
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/components/CompetitionLeaderboard.js +22 -10
- package/lib/commonjs/Competition/components/CompetitionLeaderboard.js.map +1 -1
- package/lib/commonjs/Competition/components/WagerPickForm.js +2 -2
- package/lib/commonjs/Competition/components/WagerPickForm.js.map +1 -1
- package/lib/commonjs/Competition/index.js +91 -0
- package/lib/commonjs/Competition/index.js.map +1 -1
- package/lib/commonjs/CompetitionManager/api/index.js +19 -11
- package/lib/commonjs/CompetitionManager/api/index.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js +5 -3
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js +50 -4
- package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/ContestSelector.js +19 -4
- package/lib/commonjs/CompetitionManager/components/ContestSelector.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js +28 -2
- package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/MarketSelector.js +1 -3
- package/lib/commonjs/CompetitionManager/components/MarketSelector.js.map +1 -1
- package/lib/commonjs/CompetitionManager/index.js +14 -4
- package/lib/commonjs/CompetitionManager/index.js.map +1 -1
- package/lib/commonjs/CreateEngagement/index.js +1 -1
- package/lib/commonjs/CreateEngagement/index.js.map +1 -1
- package/lib/commonjs/Squares/components/BidForm.js +31 -31
- package/lib/commonjs/Squares/components/BidForm.js.map +1 -1
- package/lib/commonjs/Squares/components/OfferForm.js +53 -60
- package/lib/commonjs/Squares/components/OfferForm.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOfferCard.js +134 -121
- package/lib/commonjs/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOffersCard.js +32 -6
- package/lib/commonjs/Squares/components/SquareOffersCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquaresBoard.js +16 -8
- package/lib/commonjs/Squares/components/SquaresBoard.js.map +1 -1
- package/lib/commonjs/Squares/index.js +65 -18
- package/lib/commonjs/Squares/index.js.map +1 -1
- package/lib/module/Competition/components/CompetitionLeaderboard.js +22 -10
- package/lib/module/Competition/components/CompetitionLeaderboard.js.map +1 -1
- package/lib/module/Competition/components/WagerPickForm.js +2 -2
- package/lib/module/Competition/components/WagerPickForm.js.map +1 -1
- package/lib/module/Competition/index.js +91 -0
- package/lib/module/Competition/index.js.map +1 -1
- package/lib/module/CompetitionManager/api/index.js +19 -11
- package/lib/module/CompetitionManager/api/index.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js +5 -3
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js +50 -4
- package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/ContestSelector.js +20 -5
- package/lib/module/CompetitionManager/components/ContestSelector.js.map +1 -1
- package/lib/module/CompetitionManager/components/ContestSettingsForm.js +28 -2
- package/lib/module/CompetitionManager/components/ContestSettingsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/MarketSelector.js +1 -3
- package/lib/module/CompetitionManager/components/MarketSelector.js.map +1 -1
- package/lib/module/CompetitionManager/index.js +14 -4
- package/lib/module/CompetitionManager/index.js.map +1 -1
- package/lib/module/CreateEngagement/index.js +1 -1
- package/lib/module/CreateEngagement/index.js.map +1 -1
- package/lib/module/Squares/components/BidForm.js +31 -31
- package/lib/module/Squares/components/BidForm.js.map +1 -1
- package/lib/module/Squares/components/OfferForm.js +54 -61
- package/lib/module/Squares/components/OfferForm.js.map +1 -1
- package/lib/module/Squares/components/SquareOfferCard.js +123 -109
- package/lib/module/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/module/Squares/components/SquareOffersCard.js +32 -6
- package/lib/module/Squares/components/SquareOffersCard.js.map +1 -1
- package/lib/module/Squares/components/SquaresBoard.js +16 -8
- package/lib/module/Squares/components/SquaresBoard.js.map +1 -1
- package/lib/module/Squares/index.js +65 -18
- package/lib/module/Squares/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Competition/components/CompetitionLeaderboard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Competition/components/CompetitionLeaderboard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Competition/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/api/index.d.ts +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/components/ContestSelector.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/components/ContestSettingsForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/components/MarketSelector.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CompetitionManager/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts +1 -2
- package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Competition/components/CompetitionLeaderboard.d.ts +2 -1
- package/lib/typescript/lib/module/Competition/components/CompetitionLeaderboard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Competition/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/api/index.d.ts +1 -1
- package/lib/typescript/lib/module/CompetitionManager/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/components/ContestSelector.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/components/ContestSettingsForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/components/MarketSelector.d.ts.map +1 -1
- package/lib/typescript/lib/module/CompetitionManager/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts +1 -2
- package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts +5 -3
- package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts +2 -1
- package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
- package/lib/typescript/src/Competition/components/CompetitionLeaderboard.d.ts +7 -2
- package/lib/typescript/src/Competition/components/CompetitionLeaderboard.d.ts.map +1 -1
- package/lib/typescript/src/Competition/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/api/index.d.ts +2 -2
- package/lib/typescript/src/CompetitionManager/api/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/ContestSelector.d.ts +4 -3
- package/lib/typescript/src/CompetitionManager/components/ContestSelector.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/ContestSettingsForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/MarketSelector.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/index.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/OfferForm.d.ts +1 -1
- package/lib/typescript/src/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts +3 -2
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts +3 -2
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquaresBoard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Competition/components/CompetitionLeaderboard.tsx +23 -7
- package/src/Competition/components/WagerPickForm.tsx +2 -2
- package/src/Competition/index.tsx +81 -2
- package/src/CompetitionManager/api/index.ts +14 -6
- package/src/CompetitionManager/components/CompetitionContestsForm.tsx +4 -4
- package/src/CompetitionManager/components/CompetitionSettingsForm.tsx +34 -1
- package/src/CompetitionManager/components/ContestSelector.tsx +25 -9
- package/src/CompetitionManager/components/ContestSettingsForm.tsx +19 -0
- package/src/CompetitionManager/components/MarketSelector.tsx +5 -7
- package/src/CompetitionManager/index.tsx +15 -7
- package/src/CreateEngagement/index.tsx +1 -1
- package/src/Squares/components/BidForm.tsx +23 -25
- package/src/Squares/components/OfferForm.tsx +40 -36
- package/src/Squares/components/SquareOfferCard.tsx +75 -45
- package/src/Squares/components/SquareOffersCard.tsx +13 -9
- package/src/Squares/components/SquaresBoard.tsx +14 -8
- package/src/Squares/index.tsx +77 -41
|
@@ -12,6 +12,11 @@ type CompetitionLeaderboardProps = {
|
|
|
12
12
|
competition:CompetitionProps,
|
|
13
13
|
competition_type:CompetitionTypeProps,
|
|
14
14
|
hidden?:boolean,
|
|
15
|
+
refresh_leaders:{
|
|
16
|
+
refresh_key:string,
|
|
17
|
+
competition_records:CompetitionRecordProps[],
|
|
18
|
+
competition_results:CompetitionResultProps[]
|
|
19
|
+
},
|
|
15
20
|
disable_collapse?:boolean,
|
|
16
21
|
viewer_id?:string,
|
|
17
22
|
height: number,
|
|
@@ -22,7 +27,7 @@ type CompetitionLeaderboardProps = {
|
|
|
22
27
|
onLeaderSelect:(player:PublicPlayerProps) => void
|
|
23
28
|
}
|
|
24
29
|
const sections = [ 'my_result','header', 'leaders' ]
|
|
25
|
-
const CompetitionLeaderboard = ({ hidden, disable_collapse, competition, competition_type, viewer_id, view_mode, onSeeFull, onClose, onLeaderSelect }:CompetitionLeaderboardProps) => {
|
|
30
|
+
const CompetitionLeaderboard = ({ hidden, refresh_leaders, disable_collapse, competition, competition_type, viewer_id, view_mode, onSeeFull, onClose, onLeaderSelect }:CompetitionLeaderboardProps) => {
|
|
26
31
|
const C = useColors();
|
|
27
32
|
const [ expanded, setExpanded ] = useState(true);
|
|
28
33
|
const [ data, setData ] = useState<{
|
|
@@ -40,20 +45,30 @@ const CompetitionLeaderboard = ({ hidden, disable_collapse, competition, competi
|
|
|
40
45
|
})
|
|
41
46
|
|
|
42
47
|
const { loading, competition_results, competition_records, players, offset } = data
|
|
43
|
-
let results = [ ...competition_results ];
|
|
48
|
+
let results = [ ...competition_results.filter(cr => cr.status != 'deleted') ];
|
|
49
|
+
let records = [ ...competition_records.filter(cr => cr.status != 'deleted') ]
|
|
44
50
|
|
|
45
51
|
if(view_mode == 'short'){ results = results.filter((r,i) => r ? i < 3 : i < 3) }
|
|
46
52
|
|
|
47
53
|
let viewer = players.find(p => p.player_id == viewer_id);
|
|
48
|
-
let viewer_result =
|
|
49
|
-
let viewer_record =
|
|
54
|
+
let viewer_result = results.find(r => r.player_id == viewer_id);
|
|
55
|
+
let viewer_record = records.find(r => r.player_id == viewer_id);
|
|
50
56
|
|
|
51
57
|
const cl = competition?.market_type == 'FOR_MONEY' ? '$' : 'E'
|
|
52
58
|
|
|
53
59
|
useEffect(() => {
|
|
54
60
|
if(!competition){ return }
|
|
55
61
|
getLeaderboardFromServer(competition.competition_id, 0)
|
|
56
|
-
},[competition])
|
|
62
|
+
},[competition?.competition_id]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if(refresh_leaders.competition_records.length == 0){ return }
|
|
66
|
+
setData({
|
|
67
|
+
...data,
|
|
68
|
+
competition_records: competition_records.filter(cr => !refresh_leaders.competition_records.find(newcr => newcr.competition_record_id == cr.competition_record_id)).concat(refresh_leaders.competition_records),
|
|
69
|
+
competition_results: competition_results.filter(cr => !refresh_leaders.competition_results.find(newcr => newcr.competition_result_id == cr.competition_result_id)).concat(refresh_leaders.competition_results)
|
|
70
|
+
})
|
|
71
|
+
},[refresh_leaders?.refresh_key])
|
|
57
72
|
|
|
58
73
|
const getLeaderboardFromServer = async(competition_id:string, offset:number) => {
|
|
59
74
|
setData({ ...data, loading:true })
|
|
@@ -64,6 +79,7 @@ const CompetitionLeaderboard = ({ hidden, disable_collapse, competition, competi
|
|
|
64
79
|
setData({
|
|
65
80
|
...data,
|
|
66
81
|
players,
|
|
82
|
+
loading:false,
|
|
67
83
|
competition_records: result_response.competition_records,
|
|
68
84
|
competition_results: result_response.competition_results,
|
|
69
85
|
offset,
|
|
@@ -163,7 +179,7 @@ const CompetitionLeaderboard = ({ hidden, disable_collapse, competition, competi
|
|
|
163
179
|
|
|
164
180
|
if(view_mode == 'short'){
|
|
165
181
|
return (
|
|
166
|
-
<View
|
|
182
|
+
<View nativeID="leaderboard" style={{ flex:1 }}>
|
|
167
183
|
<Button
|
|
168
184
|
disabled={disable_collapse}
|
|
169
185
|
style={{ flexDirection:'row', alignItems:'center', borderBottomWidth:expanded?1:0, borderColor:C.borders.light }}
|
|
@@ -179,7 +195,7 @@ const CompetitionLeaderboard = ({ hidden, disable_collapse, competition, competi
|
|
|
179
195
|
:<></>}
|
|
180
196
|
</Button>
|
|
181
197
|
{expanded ?
|
|
182
|
-
<View transparent type='body'
|
|
198
|
+
<View transparent type='body'>
|
|
183
199
|
{viewer_record && viewer_result && viewer ?
|
|
184
200
|
<View transparent style={{ padding:10, marginBottom:10, borderTopRightRadius:8, borderTopLeftRadius:8, borderBottomWidth:1, borderColor:C.borders.light }}>
|
|
185
201
|
<Text size={14} theme="h1">MY RESULTS</Text>
|
|
@@ -23,11 +23,11 @@ type WagerPickFormProps = {
|
|
|
23
23
|
const WagerPickForm = ({ player_pick, mode, event_title, balance, event_start, padding_bottom, loading, onCancel, onFocusPosition, onSubmit }:WagerPickFormProps) => {
|
|
24
24
|
const C = useColors();
|
|
25
25
|
const [ reviewed, setReviewed ] = useState(false);
|
|
26
|
-
const [ wager, setWager ] = useState({ stake:0, stake_label: '
|
|
26
|
+
const [ wager, setWager ] = useState({ stake:0, stake_label: '', potential_winnings: 0 });
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
const handleWagerChange = (text:string) => {
|
|
30
|
-
if(text == ''){ return setWager({ stake:0, stake_label:'
|
|
30
|
+
if(text == ''){ return setWager({ stake:0, stake_label:'', potential_winnings:0 }) }
|
|
31
31
|
let wager_amt = parseFloat(text)
|
|
32
32
|
let potential_winnings = CompetitionHelpers.calcPotentialWinnings(wager_amt, player_pick.odds)
|
|
33
33
|
setWager({ stake:wager_amt, stake_label:wager_amt.toString(), potential_winnings })
|
|
@@ -3,7 +3,7 @@ import { CompetitionApi, CompetitionHelpers, CompetitionMatchApi, CompetitionPla
|
|
|
3
3
|
import { Image, ActivityIndicator, Modal, FlatList } from 'react-native';
|
|
4
4
|
import { view_styles } from '../constants/styles';
|
|
5
5
|
import { ConfirmationModal, Icons, Toggle } from '../Components';
|
|
6
|
-
import type { AthleteProps, BEEventProps, CodeRequestProps, CompetitionMatchMarketProps, CompetitionMatchProps, CompetitionPayoutTypeProps, CompetitionPlayerProps, CompetitionProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps, EventProps, FocusPositionProps, LeagueProps, MarketProps, MatchProps, MyPlayerProps, PlayerBalanceProps, PlayerPickProps, PlayerReferralProps, PromoProps, PublicPlayerProps, RewardOptionProps, TeamProps, TournamentProps } from '../types';
|
|
6
|
+
import type { AthleteProps, BEEventProps, CodeRequestProps, CompetitionMatchMarketProps, CompetitionMatchProps, CompetitionPayoutTypeProps, CompetitionPlayerProps, CompetitionProps, CompetitionRecordProps, CompetitionResultProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps, EventProps, FocusPositionProps, LeagueProps, MarketProps, MatchProps, MyPlayerProps, PlayerBalanceProps, PlayerPickProps, PlayerReferralProps, PromoProps, PublicPlayerProps, RewardOptionProps, TeamProps, TournamentProps } from '../types';
|
|
7
7
|
import CompetitionInfoCard from './components/CompetitionInfoCard';
|
|
8
8
|
import CompetitionLeaderboard from './components/CompetitionLeaderboard';
|
|
9
9
|
import WagerPickForm from './components/WagerPickForm';
|
|
@@ -14,6 +14,7 @@ import LeaderPicks from './components/LeaderPicks';
|
|
|
14
14
|
import SeasonCard from './components/SeasonCard';
|
|
15
15
|
import { Button, Text, View } from '../Components/Themed';
|
|
16
16
|
import { useColors } from '../constants/useColors';
|
|
17
|
+
import SocketManager from '../Socket';
|
|
17
18
|
|
|
18
19
|
type CompetitionModuleProps = {
|
|
19
20
|
player_id?:string,
|
|
@@ -36,6 +37,23 @@ const competition_sections = ['header','pending','join','test','details','leader
|
|
|
36
37
|
const CompetitionModule = ({ competition_id, view_mode, insets, player_id, confirm_padding, onManageCompetition, onFocusPosition, onRequestAuthentication, onShareCompetition, onClose, onViewCompetitionSeason }:CompetitionModuleProps) => {
|
|
37
38
|
const C = useColors();
|
|
38
39
|
const [ active_tab, setActiveTab ] = useState('play');
|
|
40
|
+
const [ socket_details, setSocketDetails ] = useState<{
|
|
41
|
+
competition?:CompetitionProps,
|
|
42
|
+
refresh_leaders: {
|
|
43
|
+
refresh_key:string,
|
|
44
|
+
competition_records:CompetitionRecordProps[],
|
|
45
|
+
competition_results:CompetitionResultProps[]
|
|
46
|
+
},
|
|
47
|
+
competition_players:CompetitionPlayerProps[],
|
|
48
|
+
}>({
|
|
49
|
+
competition_players: [],
|
|
50
|
+
refresh_leaders: {
|
|
51
|
+
refresh_key: moment().toString(),
|
|
52
|
+
competition_records: [],
|
|
53
|
+
competition_results: []
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const [ needs_reload, setNeedsReload ] = useState(false);
|
|
39
57
|
const [ viewing_leader, setViewingLeader ] = useState<PublicPlayerProps|undefined>();
|
|
40
58
|
const [ show_full_leaderboard, setShowFullLeaderboard ] = useState(false);
|
|
41
59
|
const [ module_size, setModuleSize ] = useState({ width:0, height:0 });
|
|
@@ -91,7 +109,7 @@ const CompetitionModule = ({ competition_id, view_mode, insets, player_id, confi
|
|
|
91
109
|
competition_matches:[],
|
|
92
110
|
competition_players:[],
|
|
93
111
|
competition_match_markets:[],
|
|
94
|
-
})
|
|
112
|
+
});
|
|
95
113
|
|
|
96
114
|
const [ nav_out, setNavOut ] = useState<{
|
|
97
115
|
visible:boolean,
|
|
@@ -145,6 +163,21 @@ const CompetitionModule = ({ competition_id, view_mode, insets, player_id, confi
|
|
|
145
163
|
if(player_id){ getPlayerData(competition_id, player_id, 0) }
|
|
146
164
|
},[competition_id, player_id])
|
|
147
165
|
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
if(!loaded){ return }
|
|
168
|
+
//Need to update the competition!
|
|
169
|
+
let my_player = socket_details.competition_players.find(cp => cp.player_id == player?.player_id);
|
|
170
|
+
let entered = competition?.entered ?? false
|
|
171
|
+
if(my_player){
|
|
172
|
+
if(my_player.status == 'active'){ entered = true } else { entered = false }
|
|
173
|
+
}
|
|
174
|
+
setCompetitionData({
|
|
175
|
+
...competition_data,
|
|
176
|
+
competition: socket_details.competition ? { ...socket_details.competition, entered } : competition,
|
|
177
|
+
competition_players: competition_players.filter(cp => !socket_details.competition_players.find(newcp => newcp.competition_player_id == cp.competition_player_id)).concat(socket_details.competition_players),
|
|
178
|
+
});
|
|
179
|
+
},[socket_details.refresh_leaders?.refresh_key]);
|
|
180
|
+
|
|
148
181
|
|
|
149
182
|
useEffect(() => {
|
|
150
183
|
if(!competition){ return }
|
|
@@ -477,6 +510,7 @@ const CompetitionModule = ({ competition_id, view_mode, insets, player_id, confi
|
|
|
477
510
|
<CompetitionLeaderboard
|
|
478
511
|
hidden={active_tab == 'leaderboard' ? false : true}
|
|
479
512
|
disable_collapse
|
|
513
|
+
refresh_leaders={socket_details.refresh_leaders}
|
|
480
514
|
competition={competition}
|
|
481
515
|
width={module_size.width}
|
|
482
516
|
competition_type={competition_type}
|
|
@@ -560,15 +594,60 @@ const CompetitionModule = ({ competition_id, view_mode, insets, player_id, confi
|
|
|
560
594
|
}}>
|
|
561
595
|
<FlatList
|
|
562
596
|
key={`competition_sections`}
|
|
597
|
+
onRefresh={() => getCompetitionFromServer(competition_id)}
|
|
598
|
+
refreshing={loading}
|
|
563
599
|
data={competition_sections}
|
|
564
600
|
keyExtractor={(item) => item}
|
|
565
601
|
renderItem={renderSections}
|
|
566
602
|
/>
|
|
603
|
+
<SocketManager
|
|
604
|
+
subscribed_events={['V1_UPDATE_COMPETITION_RECORDS','V1_UPDATE_COMPETITION_PLAYERS', 'ACTIVATE_COMPETITION']}
|
|
605
|
+
onConnect={() => {
|
|
606
|
+
if(needs_reload){ getCompetitionFromServer(competition_id); console.log('RELOADING DATA!!!!') }
|
|
607
|
+
}}
|
|
608
|
+
onDisconnect={() => setNeedsReload(true)}
|
|
609
|
+
onSocketEvent={(event) => {
|
|
610
|
+
switch(event.type){
|
|
611
|
+
case 'ACTIVATE_COMPETITION':
|
|
612
|
+
//competition = message.competition
|
|
613
|
+
let comp:CompetitionProps | undefined = event.competition as CompetitionProps | undefined
|
|
614
|
+
if(!comp){ return }
|
|
615
|
+
if(comp.competition_id != competition_id){ return } //Not our competition!!!
|
|
616
|
+
setSocketDetails({
|
|
617
|
+
...socket_details,
|
|
618
|
+
competition: comp
|
|
619
|
+
});
|
|
620
|
+
break
|
|
621
|
+
case 'V1_UPDATE_COMPETITION_PLAYERS':
|
|
622
|
+
let competition_players = event.data as CompetitionPlayerProps[]
|
|
623
|
+
let competition = event.competition as CompetitionProps
|
|
624
|
+
let competition_records = event.records as CompetitionRecordProps[]
|
|
625
|
+
let competition_results = event.results as CompetitionResultProps[]
|
|
626
|
+
if(!competition || !competition_players || !competition_results || !competition_records){ return } //There is an issue with this data
|
|
627
|
+
if(competition?.competition_id != competition_id){ return }
|
|
628
|
+
console.log(`records = ${competition_records.length}`);
|
|
629
|
+
console.log(`results is ${competition_results.length}`);
|
|
630
|
+
console.log(`players are ${competition_players.length}`)
|
|
631
|
+
setSocketDetails({
|
|
632
|
+
competition: competition,
|
|
633
|
+
competition_players: competition_players,
|
|
634
|
+
refresh_leaders:{
|
|
635
|
+
refresh_key: moment().toString(),
|
|
636
|
+
competition_records,
|
|
637
|
+
competition_results
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
break
|
|
641
|
+
default: return //Do nothing
|
|
642
|
+
}
|
|
643
|
+
}}
|
|
644
|
+
/>
|
|
567
645
|
{show_full_leaderboard ?
|
|
568
646
|
<View type='blur' style={view_mode=='desktop'?{position:'absolute', top:0, left:0, right:0, bottom:0, justifyContent:'center', alignItems:'center'}:{ position:'absolute', bottom:0, left:0, right:0, top:0 }}>
|
|
569
647
|
<View style={view_mode=='desktop'?{ width:500, height:676, borderRadius:22 }:{flex:1}}>
|
|
570
648
|
<CompetitionLeaderboard
|
|
571
649
|
competition={competition}
|
|
650
|
+
refresh_leaders={socket_details.refresh_leaders}
|
|
572
651
|
competition_type={competition_type}
|
|
573
652
|
height={module_size.height}
|
|
574
653
|
width={module_size.width}
|
|
@@ -285,9 +285,13 @@ const ManageCompetitionMatchApi = {
|
|
|
285
285
|
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/match/update`, { competition_match })
|
|
286
286
|
return resp.data.competition_match
|
|
287
287
|
},
|
|
288
|
-
deleteCompetitionMatch: async(competition_match_id:string):Promise<{ competition_match:CompetitionMatchProps, competition_match_markets:CompetitionMatchMarketProps[] }> => {
|
|
289
|
-
|
|
290
|
-
|
|
288
|
+
deleteCompetitionMatch: async(competition_match_id:string):Promise<undefined | { competition_match:CompetitionMatchProps, competition_match_markets:CompetitionMatchMarketProps[] }> => {
|
|
289
|
+
try {
|
|
290
|
+
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/match/delete`, { competition_match_id })
|
|
291
|
+
return { competition_match: resp.data.competition_match, competition_match_markets:resp.data.competition_match_markets }
|
|
292
|
+
} catch (e) {
|
|
293
|
+
return undefined
|
|
294
|
+
}
|
|
291
295
|
},
|
|
292
296
|
createCompetitionMatchMarkets: async(competition_match_markets:CompetitionMatchMarketProps[]):Promise<CompetitionMatchMarketProps[]> => {
|
|
293
297
|
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/market/create`, { competition_match_markets })
|
|
@@ -297,10 +301,14 @@ const ManageCompetitionMatchApi = {
|
|
|
297
301
|
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/market/update`, { competition_match_markets })
|
|
298
302
|
return resp.data.competition_match_markets
|
|
299
303
|
},
|
|
300
|
-
deleteCompetitionMatchMarkets: async(competition_match_market_ids:string[]):Promise<CompetitionMatchMarketProps[]> => {
|
|
304
|
+
deleteCompetitionMatchMarkets: async(competition_match_market_ids:string[]):Promise<undefined | CompetitionMatchMarketProps[]> => {
|
|
301
305
|
if(competition_match_market_ids.length == 0){ return [] }
|
|
302
|
-
|
|
303
|
-
|
|
306
|
+
try {
|
|
307
|
+
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/market/delete`, { competition_match_market_ids })
|
|
308
|
+
return resp.data.competition_match_markets
|
|
309
|
+
} catch (e) {
|
|
310
|
+
return undefined
|
|
311
|
+
}
|
|
304
312
|
}
|
|
305
313
|
}
|
|
306
314
|
|
|
@@ -65,7 +65,7 @@ const CompetitionContestsForm = ({
|
|
|
65
65
|
const [ active_contest_type ] = useState('team');
|
|
66
66
|
const [ expanded_contests, setExpandedContests ] = useState<string[]>([]);
|
|
67
67
|
|
|
68
|
-
const unique_team_events = [ ...new Set(competition_matches.filter(cm => cm.event_type == 'team').map(cm => cm.event_id)) ]
|
|
68
|
+
const unique_team_events = [ ...new Set(competition_matches.filter(cm => cm.status == 'inprogress' && cm.event_type == 'team').map(cm => cm.event_id)) ]
|
|
69
69
|
const append_to_events = competition.linked_event_ids && competition.linked_event_ids.length == unique_team_events.length ? true : false
|
|
70
70
|
|
|
71
71
|
const renderPrimaryMarkets = (data: { item:{ market:MarketProps, included:boolean }, index:number }) => {
|
|
@@ -87,7 +87,7 @@ const CompetitionContestsForm = ({
|
|
|
87
87
|
const show_details = show_match_markets.includes(`${data.event_type}:${data.event_id}:${data.item}`) ? true : false
|
|
88
88
|
const market_matches = competition_matches.filter(cm => cm.market_id_override == data.item && cm.side_id_override);
|
|
89
89
|
return (
|
|
90
|
-
<View style={{
|
|
90
|
+
<View style={{ padding:0, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
91
91
|
<Button transparent style={{ flexDirection:'row', alignItems:'center', padding:10 }} onPress={() => {
|
|
92
92
|
if(show_details){ return setShowMatchMarkets(show_match_markets.filter(smm => smm != `${data.event_type}:${data.event_id}:${data.item}`)) }
|
|
93
93
|
return setShowMatchMarkets(show_match_markets.concat(`${data.event_type}:${data.event_id}:${data.item}`))
|
|
@@ -114,12 +114,12 @@ const CompetitionContestsForm = ({
|
|
|
114
114
|
</View>
|
|
115
115
|
<View transparent style={{ flexDirection:'row', alignItems:'center', padding:0 }}>
|
|
116
116
|
{market.level != 'event' ?
|
|
117
|
-
<View style={{ margin:5, justifyContent:'center', alignItems:'center' }}>
|
|
117
|
+
<View transparent style={{ margin:5, justifyContent:'center', alignItems:'center' }}>
|
|
118
118
|
<Text theme='h2' size={14} color={Colors.text.action}>{market_matches.length}</Text>
|
|
119
119
|
<Text theme='description' color={Colors.text.action} style={{ marginTop:3 }}>{market.level.toUpperCase()}{market_matches.length == 1 ? '':'S'}</Text>
|
|
120
120
|
</View>
|
|
121
121
|
:
|
|
122
|
-
<View>
|
|
122
|
+
<View transparent>
|
|
123
123
|
<Icons.ChevronIcon direction={show_details ? 'up' : 'down'} color={Colors.text.action} size={8} />
|
|
124
124
|
</View>
|
|
125
125
|
}
|
|
@@ -54,6 +54,9 @@ const CompetitionSettingsForm = ({ init_expanded, onFocusPosition, player, compe
|
|
|
54
54
|
|
|
55
55
|
if(!competition || !draft_competition){ return <></> }
|
|
56
56
|
const is_changed = JSON.stringify(competition) != JSON.stringify(draft_competition) ? true : false
|
|
57
|
+
const is_ticket_changed = draft_competition.buy_in.toString() != competition.buy_in.toString() ? true : false
|
|
58
|
+
const is_guar_changed = draft_competition.guaranteed_payout?.toString() != competition.guaranteed_payout?.toString() ? true : false
|
|
59
|
+
const is_max_tickets_changed = draft_competition.available_tickets.toString() != competition.available_tickets.toString() ? true : false
|
|
57
60
|
return (
|
|
58
61
|
<View float style={{ flexGrow:1, borderRadius:0 }}>
|
|
59
62
|
<Button
|
|
@@ -154,7 +157,7 @@ const CompetitionSettingsForm = ({ init_expanded, onFocusPosition, player, compe
|
|
|
154
157
|
</View>
|
|
155
158
|
:<></>}
|
|
156
159
|
</View>
|
|
157
|
-
<View type='row' nativeID="buy_in" style={{ flexWrap:'wrap', padding:20, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
160
|
+
<View type='row' nativeID="buy_in" style={{ flexWrap:'wrap', padding:20, borderBottomWidth:1, borderColor:is_ticket_changed ? Colors.text.warning : Colors.borders.light }}>
|
|
158
161
|
<View style={{ flex:1, minWidth:200 }}>
|
|
159
162
|
<Text theme="h1">Ticket Price</Text>
|
|
160
163
|
<Text style={{ marginTop:3 }} theme="description">Set the amount required to purchase a ticket to participate</Text>
|
|
@@ -163,11 +166,22 @@ const CompetitionSettingsForm = ({ init_expanded, onFocusPosition, player, compe
|
|
|
163
166
|
style={{ flexGrow:1, textAlign:'center', minWidth:100, margin:5, borderColor:competition.buy_in ? Colors.text.success: Colors.text.warning }}
|
|
164
167
|
onChangeText={(text) => setDraftCompetition({ ...draft_competition, buy_in: text })}
|
|
165
168
|
placeholder="0"
|
|
169
|
+
onFocus={() => {
|
|
170
|
+
if(draft_competition.buy_in == 0){ setDraftCompetition({ ...draft_competition, buy_in: '' }) }
|
|
171
|
+
}}
|
|
166
172
|
onFocusPosition={onFocusPosition}
|
|
167
173
|
keyboardType="decimal-pad"
|
|
168
174
|
editable={competition.competition_season_id ? false : true}
|
|
169
175
|
value={draft_competition.buy_in.toString()}
|
|
170
176
|
/>
|
|
177
|
+
{is_ticket_changed ?
|
|
178
|
+
<Button
|
|
179
|
+
title='SAVE'
|
|
180
|
+
type='success'
|
|
181
|
+
style={{ margin:5, padding:15, flexGrow:1 }}
|
|
182
|
+
onPress={() => onCompetitionUpdate(draft_competition)}
|
|
183
|
+
/>
|
|
184
|
+
:<></>}
|
|
171
185
|
</View>
|
|
172
186
|
{player?.role == 'admin' ?
|
|
173
187
|
<View type='row' nativeID="buy_in" style={{ flexWrap:'wrap', padding:20, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
@@ -184,6 +198,14 @@ const CompetitionSettingsForm = ({ init_expanded, onFocusPosition, player, compe
|
|
|
184
198
|
editable={competition.competition_season_id ? false : true}
|
|
185
199
|
value={draft_competition.guaranteed_payout?.toString()}
|
|
186
200
|
/>
|
|
201
|
+
{is_guar_changed ?
|
|
202
|
+
<Button
|
|
203
|
+
title='SAVE'
|
|
204
|
+
type='success'
|
|
205
|
+
style={{ margin:5, padding:15, flexGrow:1 }}
|
|
206
|
+
onPress={() => onCompetitionUpdate(draft_competition)}
|
|
207
|
+
/>
|
|
208
|
+
:<></>}
|
|
187
209
|
</View>
|
|
188
210
|
:<></>}
|
|
189
211
|
|
|
@@ -196,11 +218,22 @@ const CompetitionSettingsForm = ({ init_expanded, onFocusPosition, player, compe
|
|
|
196
218
|
style={{ flexGrow:1, textAlign:'center', minWidth:100, margin:5, borderColor:parseInt(competition.available_tickets as string) > 0 ? Colors.text.success : Colors.text.warning }}
|
|
197
219
|
onChangeText={(text) => setDraftCompetition({ ...draft_competition, available_tickets: text })}
|
|
198
220
|
placeholder="100"
|
|
221
|
+
onFocus={() => {
|
|
222
|
+
if(draft_competition.available_tickets == 0){ setDraftCompetition({ ...draft_competition, available_tickets: '' }) }
|
|
223
|
+
}}
|
|
199
224
|
onFocusPosition={onFocusPosition}
|
|
200
225
|
keyboardType="decimal-pad"
|
|
201
226
|
editable={competition.competition_season_id ? false : true}
|
|
202
227
|
value={draft_competition.available_tickets.toString()}
|
|
203
228
|
/>
|
|
229
|
+
{is_max_tickets_changed ?
|
|
230
|
+
<Button
|
|
231
|
+
title='SAVE'
|
|
232
|
+
type='success'
|
|
233
|
+
style={{ margin:5, padding:15, flexGrow:1 }}
|
|
234
|
+
onPress={() => onCompetitionUpdate(draft_competition)}
|
|
235
|
+
/>
|
|
236
|
+
:<></>}
|
|
204
237
|
</View>
|
|
205
238
|
</View>
|
|
206
239
|
:<></>}
|
|
@@ -2,19 +2,21 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import { FlatList, Image, ActivityIndicator } from "react-native"
|
|
3
3
|
import { Switch } from '../../Components';
|
|
4
4
|
import DropDown from '../../Components/Dropdown';
|
|
5
|
-
import type { EventProps, LeagueProps } from '../../types';
|
|
6
|
-
import { ManageCompetitionMatchApi } from '../api';
|
|
5
|
+
import type { EventProps, LeagueProps, MarketProps, TradeProps } from '../../types';
|
|
6
|
+
import { ManageCompetitionApi, ManageCompetitionMarketApi, ManageCompetitionMatchApi } from '../api';
|
|
7
7
|
import moment from 'moment-mini';
|
|
8
8
|
import SearchBox from '../../Components/SearchBox';
|
|
9
9
|
import { useColors } from '../../constants/useColors';
|
|
10
10
|
import { Button, Text, View } from '../../Components/Themed';
|
|
11
|
+
import { MarketComponentHelpers } from '../../MarketComponents/api';
|
|
11
12
|
|
|
12
13
|
type ContestSelectorProps = {
|
|
13
14
|
action_loading:boolean,
|
|
14
15
|
leagues:LeagueProps[],
|
|
16
|
+
active_markets?:string[],
|
|
15
17
|
selected_team_events:EventProps[],
|
|
16
|
-
onSelectTeamEvent:(event:EventProps) => void,
|
|
17
|
-
onSelectTeamEvents: (events:EventProps[]) => void,
|
|
18
|
+
onSelectTeamEvent:(event:EventProps, trades:TradeProps[]) => void,
|
|
19
|
+
onSelectTeamEvents: (events:EventProps[], trades:TradeProps[]) => void,
|
|
18
20
|
onDeselectTeamEvent: (event:EventProps) => void,
|
|
19
21
|
onClose:() => void
|
|
20
22
|
}
|
|
@@ -30,17 +32,21 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
30
32
|
const [ selector_data, setData ] = useState<{
|
|
31
33
|
loading:boolean,
|
|
32
34
|
events:EventProps[],
|
|
35
|
+
markets:MarketProps[],
|
|
36
|
+
trades:TradeProps[],
|
|
33
37
|
range_dates:string[],
|
|
34
38
|
active_league?:LeagueProps,
|
|
35
39
|
active_date: string
|
|
36
40
|
}>({
|
|
37
41
|
loading:false,
|
|
42
|
+
markets:[],
|
|
38
43
|
events: [],
|
|
44
|
+
trades:[],
|
|
39
45
|
range_dates: [],
|
|
40
46
|
active_date: moment().format('YYYY/MM/DD')
|
|
41
47
|
})
|
|
42
48
|
|
|
43
|
-
const { loading, events, range_dates, active_league, active_date } = selector_data;
|
|
49
|
+
const { loading, events, range_dates, trades, markets, active_league, active_date } = selector_data;
|
|
44
50
|
|
|
45
51
|
let filtered_events = events.filter(e => `${e.event_id} ${e.away?.market_name} ${e.away?.name} ${e.home?.market_name} ${e.home?.name}`.toLowerCase().includes(search_value.toLowerCase()))
|
|
46
52
|
.filter(e => moment(e.scheduled_datetime).format('YYYY/MM/DD') == active_date)
|
|
@@ -69,6 +75,7 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
69
75
|
|
|
70
76
|
const show_add_all = filtered_events.filter(e => !selected_team_events.map(e => e.event_id.toString()).includes(e.event_id)).length > 0 ? true : false
|
|
71
77
|
|
|
78
|
+
const spread_market = markets.find(mk => mk.type == 'Spread');
|
|
72
79
|
|
|
73
80
|
useEffect(() => {
|
|
74
81
|
if(leagues.length == 0){ return }
|
|
@@ -89,7 +96,13 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
89
96
|
if(!best_day){
|
|
90
97
|
best_day = unique_dates[0] ?? moment().format('YYYY/MM/DD')
|
|
91
98
|
}
|
|
92
|
-
|
|
99
|
+
|
|
100
|
+
//Lets grab all the last trades for events that we have
|
|
101
|
+
let ev_markets = await ManageCompetitionApi.getMarkets();
|
|
102
|
+
let event_trades = await ManageCompetitionMarketApi.getLatestTradesByEventIds(resp.events.map(e => e.event_id), 'team');
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
setData({ ...selector_data, loading:false, events: resp.events, range_dates: unique_dates, active_date: best_day, trades: event_trades.filter(t => t.market_type == 'FOR_MONEY'), markets:ev_markets })
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
const renderDivisions = (data: { item:string, index:number }) => {
|
|
@@ -123,6 +136,9 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
123
136
|
const renderEvents = (data: { item:EventProps, index:number }) => {
|
|
124
137
|
const selected = selected_team_events.map(e => e.event_id.toString()).includes(data.item.event_id.toString()) ? true : false
|
|
125
138
|
const is_live = moment(data.item.scheduled_datetime).isBefore(moment()) ? true : false
|
|
139
|
+
const event_trades = trades.filter(t => t.event_type == 'team' && t.event_id == data.item.event_id && t.market_type == 'FOR_MONEY')
|
|
140
|
+
const spread_trades = event_trades.filter(t => t.market_id == spread_market?.market_id);
|
|
141
|
+
const home_trade = spread_trades.find(t => t.side_id == data.item.home_team_id)
|
|
126
142
|
return (
|
|
127
143
|
<View type='row' style={{ padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
128
144
|
<View style={{ flexDirection:'row', alignItems:'center', paddingRight:10, borderRightWidth:1, borderColor:Colors.borders.light }}>
|
|
@@ -139,7 +155,7 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
139
155
|
/>
|
|
140
156
|
</View>
|
|
141
157
|
<View style={{ flex:1, marginLeft: 10 }}>
|
|
142
|
-
<Text theme='h2'>{data.item.event_title}</Text>
|
|
158
|
+
<Text theme='h2'>{data.item.event_title}{home_trade && spread_market?` ${MarketComponentHelpers.getVar1Label(spread_market, home_trade.var_1)}`:''}</Text>
|
|
143
159
|
<Text style={{ marginTop:3 }} theme='description'>{data.item.time_detail == 'scheduled' ? moment(data.item.scheduled_datetime).format('MMM DD hh:mm a'): data.item.time_detail}</Text>
|
|
144
160
|
</View>
|
|
145
161
|
{!is_live ?
|
|
@@ -149,7 +165,7 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
149
165
|
onChange={() => {
|
|
150
166
|
if(action_loading){ return }
|
|
151
167
|
if(selected){ return onDeselectTeamEvent(data.item) }
|
|
152
|
-
return onSelectTeamEvent(data.item)
|
|
168
|
+
return onSelectTeamEvent(data.item, event_trades)
|
|
153
169
|
}}
|
|
154
170
|
/>
|
|
155
171
|
:<></>}
|
|
@@ -246,7 +262,7 @@ const ContestSelector = ({ action_loading, leagues, selected_team_events, onClos
|
|
|
246
262
|
onPress={() => {
|
|
247
263
|
///First remove any event that is already selected
|
|
248
264
|
let add_events = filtered_events.filter(e => !selected_team_events.map(e => e.event_id.toString()).includes(e.event_id))
|
|
249
|
-
onSelectTeamEvents(add_events);
|
|
265
|
+
onSelectTeamEvents(add_events, trades);
|
|
250
266
|
}}
|
|
251
267
|
/>
|
|
252
268
|
:<></>}
|
|
@@ -121,10 +121,21 @@ const ContestSettingsForm = ({ init_expanded, onFocusPosition, competition, comp
|
|
|
121
121
|
style={{ flex:1, minWidth:100, textAlign:'center', margin:5 }}
|
|
122
122
|
onChangeText={(text) => setDraftCompetition({ ...draft_competition, max_pick_count: text })}
|
|
123
123
|
placeholder="0"
|
|
124
|
+
onFocus={() => {
|
|
125
|
+
if(draft_competition.max_pick_count == 0){ setDraftCompetition({ ...draft_competition, max_pick_count: '' }) }
|
|
126
|
+
}}
|
|
124
127
|
onFocusPosition={onFocusPosition}
|
|
125
128
|
keyboardType="decimal-pad"
|
|
126
129
|
value={draft_competition.max_pick_count.toString()}
|
|
127
130
|
/>
|
|
131
|
+
{is_changed ?
|
|
132
|
+
<Button
|
|
133
|
+
title='SAVE'
|
|
134
|
+
type='success'
|
|
135
|
+
style={{ margin:5, padding:15, flexGrow:1 }}
|
|
136
|
+
onPress={() => onCompetitionUpdate(draft_competition)}
|
|
137
|
+
/>
|
|
138
|
+
:<></>}
|
|
128
139
|
</View>
|
|
129
140
|
:<></>}
|
|
130
141
|
{competition_type?.type == 'wager' ?
|
|
@@ -142,6 +153,14 @@ const ContestSettingsForm = ({ init_expanded, onFocusPosition, competition, comp
|
|
|
142
153
|
keyboardType="decimal-pad"
|
|
143
154
|
value={draft_competition.initial_balance.toString()}
|
|
144
155
|
/>
|
|
156
|
+
{is_changed ?
|
|
157
|
+
<Button
|
|
158
|
+
title='SAVE'
|
|
159
|
+
type='success'
|
|
160
|
+
style={{ margin:5, padding:15, flexGrow:1 }}
|
|
161
|
+
onPress={() => onCompetitionUpdate(draft_competition)}
|
|
162
|
+
/>
|
|
163
|
+
:<></>}
|
|
145
164
|
</View>
|
|
146
165
|
:<></>}
|
|
147
166
|
<View style={{ padding:20 }}>
|
|
@@ -55,13 +55,11 @@ const MarketSelector = ({ markets, selected_markets, onSelectMarket, onDeselectM
|
|
|
55
55
|
/>
|
|
56
56
|
</View>
|
|
57
57
|
<View style={{ flex:1 }}>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/>
|
|
64
|
-
</View>
|
|
58
|
+
<FlatList
|
|
59
|
+
data={filtered_markets}
|
|
60
|
+
renderItem={renderMarkets}
|
|
61
|
+
keyExtractor={(item) => item.market_id.toString()}
|
|
62
|
+
/>
|
|
65
63
|
</View>
|
|
66
64
|
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
|
|
67
65
|
<Button
|
|
@@ -249,7 +249,7 @@ const CompetitionManager = ({ float, header_style, footer_style, player_id, onFo
|
|
|
249
249
|
const addEvents = new_events.map(async e => {
|
|
250
250
|
const cm = await ManageCompetitionMatchApi.createCompetitionMatch(competition_id, e.event_id, 'team', 'event', undefined, undefined, undefined);
|
|
251
251
|
added_matches.push(cm)
|
|
252
|
-
})
|
|
252
|
+
});
|
|
253
253
|
await Promise.all(addEvents);
|
|
254
254
|
const e_trades = await ManageCompetitionMarketApi.getLatestTradesByEventIds(new_events.map(e => e.event_id), 'team');
|
|
255
255
|
setCompetitionData({
|
|
@@ -257,7 +257,7 @@ const CompetitionManager = ({ float, header_style, footer_style, player_id, onFo
|
|
|
257
257
|
competition: { ...competition, scheduled_datetime: undefined },
|
|
258
258
|
competition_matches: competition_matches.concat(added_matches),
|
|
259
259
|
events: events.filter(e => !new_events.find(ne => ne.event_id == e.event_id)).concat(new_events),
|
|
260
|
-
trades: trades.filter(t => !
|
|
260
|
+
trades: trades.filter(t => !new_events.map(e => e.event_id.toString()).includes(t.event_id.toString())).concat(e_trades)
|
|
261
261
|
})
|
|
262
262
|
setActionLoading(false)
|
|
263
263
|
}
|
|
@@ -280,18 +280,26 @@ const CompetitionManager = ({ float, header_style, footer_style, player_id, onFo
|
|
|
280
280
|
const handleRemoveCompetitionMatch = async(competition_match_id:string) => {
|
|
281
281
|
if(action_loading){ return }
|
|
282
282
|
setActionLoading(true);
|
|
283
|
-
await ManageCompetitionMatchApi.deleteCompetitionMatch(competition_match_id);
|
|
283
|
+
let result = await ManageCompetitionMatchApi.deleteCompetitionMatch(competition_match_id);
|
|
284
|
+
if(!result){
|
|
285
|
+
setActionLoading(false);
|
|
286
|
+
return alert('Unable to remove this market. It could either be the event has already started or a player has already made a pick on it.')
|
|
287
|
+
}
|
|
284
288
|
setCompetitionData({
|
|
285
289
|
...competition_data,
|
|
286
290
|
competition_matches: competition_matches.filter(cm => cm.competition_match_id != competition_match_id)
|
|
287
|
-
})
|
|
291
|
+
});
|
|
288
292
|
setActionLoading(false)
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
const handleRemoveCompetitionMatchMarkets = async(cmms:CompetitionMatchMarketProps[]) => {
|
|
292
296
|
if(action_loading){ return }
|
|
293
297
|
setActionLoading(true);
|
|
294
|
-
await ManageCompetitionMatchApi.deleteCompetitionMatchMarkets(cmms.map(cmm => cmm.competition_match_market_id));
|
|
298
|
+
let result = await ManageCompetitionMatchApi.deleteCompetitionMatchMarkets(cmms.map(cmm => cmm.competition_match_market_id));
|
|
299
|
+
if(!result){
|
|
300
|
+
setActionLoading(false);
|
|
301
|
+
return alert('Unable to remove this market. It could either be the event has already started or a player has already made a pick on it.')
|
|
302
|
+
}
|
|
295
303
|
setCompetitionData({
|
|
296
304
|
...competition_data,
|
|
297
305
|
competition_match_markets: competition_match_markets.filter(cmm => !cmms.map(rmm => rmm.competition_match_market_id.toString()).includes(cmm.competition_match_market_id))
|
|
@@ -365,6 +373,7 @@ const CompetitionManager = ({ float, header_style, footer_style, player_id, onFo
|
|
|
365
373
|
let markets_removed:string[] = []
|
|
366
374
|
const rem_non_primary = non_primary_matches.map(async cm => {
|
|
367
375
|
const del_response = await ManageCompetitionMatchApi.deleteCompetitionMatch(cm.competition_match_id);
|
|
376
|
+
if(!del_response){ return } //We had an issue tring to remove this
|
|
368
377
|
matches_removed = matches_removed.concat(del_response.competition_match.competition_match_id)
|
|
369
378
|
markets_removed = markets_removed.concat(del_response.competition_match_markets.map(cmm => cmm.competition_match_market_id))
|
|
370
379
|
})
|
|
@@ -427,7 +436,6 @@ const CompetitionManager = ({ float, header_style, footer_style, player_id, onFo
|
|
|
427
436
|
if(market.level == 'event'){
|
|
428
437
|
//If the level is event - we need to create some events
|
|
429
438
|
let market_trades = trades.filter(t => t.market_type == 'FOR_MONEY' && t.event_id == contest_id && t.event_type == contest_type && t.market_id == market.market_id)
|
|
430
|
-
console.log(`market trades are ${market_trades.length}`)
|
|
431
439
|
let event_cmms:CompetitionMatchMarketProps[] = []
|
|
432
440
|
market_trades.map(t => {
|
|
433
441
|
event_cmms.push({ ...ManageCompetitionHelpers.createCompetitionMatchMarketFromTrade(t), competition_match_id: new_cm.competition_match_id })
|
|
@@ -691,7 +699,7 @@ const CompetitionManager = ({ float, header_style, footer_style, player_id, onFo
|
|
|
691
699
|
</View>
|
|
692
700
|
:<></>}
|
|
693
701
|
{show_markets.contest_id && show_markets.contest_type && showing_market_event ?
|
|
694
|
-
<View type='blur' style={{
|
|
702
|
+
<View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, paddingBottom:insets?.bottom, paddingTop:insets?.top }}>
|
|
695
703
|
<MarketSelector
|
|
696
704
|
markets={markets.filter(m => m.event_type == show_markets.contest_type && showing_market_event.supported_markets?.map(m => m.market_id.toString()).includes(m.market_id.toString()))}
|
|
697
705
|
onClose={() => setShowMarkets({})}
|
|
@@ -31,7 +31,7 @@ const steps:CreateEngagementStepProps[] = [
|
|
|
31
31
|
{ step_key: 'intro', num: 1, title: 'BettorEdge Engagements', description: 'Create an engagement and share with friends to play along' },
|
|
32
32
|
{ step_key: 'options', num:2, title: 'Engagement Types', description: 'Select an engagement type below to get started!' },
|
|
33
33
|
{ step_key: 'group', num:3, title: 'Add Group', description: 'Select one of your groups to add this engagement to!' },
|
|
34
|
-
{ step_key: 'company', num:4, title: 'Add Company', description: 'Select one of your
|
|
34
|
+
{ step_key: 'company', num:4, title: 'Add Company', description: 'Select one of your companies to add this engagement to!' },
|
|
35
35
|
{ step_key: 'image', num:5, title:'Add an Image!', description: 'Add an image to your engagement to make it stand out!' },
|
|
36
36
|
{ step_key: 'create', num:6, title: 'Create Engagement', description: 'Complete the step below to create this BettorEdge Engagement!' },
|
|
37
37
|
{ step_key: 'success', num:7, title: 'Engagement Successfully Created!', description: 'Your engagement is in pending status. You can activate it when ready from your dashboard or the engagement screen!' }
|