be-components 1.4.8 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/Competition/api/index.js +15 -0
- package/lib/commonjs/Competition/api/index.js.map +1 -1
- package/lib/commonjs/Competition/components/CompetitionSeasonCard.js +1 -1
- package/lib/commonjs/Competition/components/CompetitionSeasonCard.js.map +1 -1
- package/lib/commonjs/Competition/components/SeasonCard.js +61 -0
- package/lib/commonjs/Competition/components/SeasonCard.js.map +1 -0
- package/lib/commonjs/Competition/index.js +23 -3
- package/lib/commonjs/Competition/index.js.map +1 -1
- package/lib/commonjs/CompetitionManager/api/index.js +3 -5
- package/lib/commonjs/CompetitionManager/api/index.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js +1 -61
- package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js +6 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js +4 -0
- package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js.map +1 -1
- package/lib/commonjs/CompetitionManager/components/CreateCompetitionForm.js +37 -3
- package/lib/commonjs/CompetitionManager/components/CreateCompetitionForm.js.map +1 -1
- package/lib/commonjs/CompetitionSeason/api/index.js +134 -0
- package/lib/commonjs/CompetitionSeason/api/index.js.map +1 -0
- package/lib/commonjs/CompetitionSeason/components/CompetitionsSection.js +127 -0
- package/lib/commonjs/CompetitionSeason/components/CompetitionsSection.js.map +1 -0
- package/lib/commonjs/CompetitionSeason/components/EnterSeasonPrompt.js +253 -0
- package/lib/commonjs/CompetitionSeason/components/EnterSeasonPrompt.js.map +1 -0
- package/lib/commonjs/CompetitionSeason/components/SeasonHeader.js +126 -0
- package/lib/commonjs/CompetitionSeason/components/SeasonHeader.js.map +1 -0
- package/lib/commonjs/CompetitionSeason/components/SeasonLeaderboard.js +324 -0
- package/lib/commonjs/CompetitionSeason/components/SeasonLeaderboard.js.map +1 -0
- package/lib/commonjs/CompetitionSeason/components/SeasonSettingsSection.js +175 -0
- package/lib/commonjs/CompetitionSeason/components/SeasonSettingsSection.js.map +1 -0
- package/lib/commonjs/CompetitionSeason/index.js +278 -0
- package/lib/commonjs/CompetitionSeason/index.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/api/index.js +182 -0
- package/lib/commonjs/CompetitionSeasonManager/api/index.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/components/CompetitionSelector.js +2 -0
- package/lib/commonjs/CompetitionSeasonManager/components/CompetitionSelector.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/components/CompetitionsForm.js +153 -0
- package/lib/commonjs/CompetitionSeasonManager/components/CompetitionsForm.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/components/CreateSeasonForm.js +388 -0
- package/lib/commonjs/CompetitionSeasonManager/components/CreateSeasonForm.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/components/SeasonHeader.js +108 -0
- package/lib/commonjs/CompetitionSeasonManager/components/SeasonHeader.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/components/SeasonInfoForm.js +242 -0
- package/lib/commonjs/CompetitionSeasonManager/components/SeasonInfoForm.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/components/SeasonSettingsForm.js +352 -0
- package/lib/commonjs/CompetitionSeasonManager/components/SeasonSettingsForm.js.map +1 -0
- package/lib/commonjs/CompetitionSeasonManager/index.js +190 -0
- package/lib/commonjs/CompetitionSeasonManager/index.js.map +1 -0
- package/lib/commonjs/Components/Switch.js +3 -0
- package/lib/commonjs/Components/Switch.js.map +1 -1
- package/lib/commonjs/Engage/index.js +28 -1
- package/lib/commonjs/Engage/index.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Competition/api/index.js +15 -0
- package/lib/module/Competition/api/index.js.map +1 -1
- package/lib/module/Competition/components/CompetitionSeasonCard.js +1 -1
- package/lib/module/Competition/components/CompetitionSeasonCard.js.map +1 -1
- package/lib/module/Competition/components/SeasonCard.js +54 -0
- package/lib/module/Competition/components/SeasonCard.js.map +1 -0
- package/lib/module/Competition/index.js +23 -3
- package/lib/module/Competition/index.js.map +1 -1
- package/lib/module/CompetitionManager/api/index.js +3 -5
- package/lib/module/CompetitionManager/api/index.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionInfoForm.js +1 -63
- package/lib/module/CompetitionManager/components/CompetitionInfoForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js +6 -1
- package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/ContestSettingsForm.js +4 -0
- package/lib/module/CompetitionManager/components/ContestSettingsForm.js.map +1 -1
- package/lib/module/CompetitionManager/components/CreateCompetitionForm.js +37 -3
- package/lib/module/CompetitionManager/components/CreateCompetitionForm.js.map +1 -1
- package/lib/module/CompetitionSeason/api/index.js +128 -0
- package/lib/module/CompetitionSeason/api/index.js.map +1 -0
- package/lib/module/CompetitionSeason/components/CompetitionsSection.js +118 -0
- package/lib/module/CompetitionSeason/components/CompetitionsSection.js.map +1 -0
- package/lib/module/CompetitionSeason/components/EnterSeasonPrompt.js +244 -0
- package/lib/module/CompetitionSeason/components/EnterSeasonPrompt.js.map +1 -0
- package/lib/module/CompetitionSeason/components/SeasonHeader.js +119 -0
- package/lib/module/CompetitionSeason/components/SeasonHeader.js.map +1 -0
- package/lib/module/CompetitionSeason/components/SeasonLeaderboard.js +315 -0
- package/lib/module/CompetitionSeason/components/SeasonLeaderboard.js.map +1 -0
- package/lib/module/CompetitionSeason/components/SeasonSettingsSection.js +166 -0
- package/lib/module/CompetitionSeason/components/SeasonSettingsSection.js.map +1 -0
- package/lib/module/CompetitionSeason/index.js +269 -0
- package/lib/module/CompetitionSeason/index.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/api/index.js +176 -0
- package/lib/module/CompetitionSeasonManager/api/index.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/components/CompetitionSelector.js +2 -0
- package/lib/module/CompetitionSeasonManager/components/CompetitionSelector.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/components/CompetitionsForm.js +144 -0
- package/lib/module/CompetitionSeasonManager/components/CompetitionsForm.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/components/CreateSeasonForm.js +379 -0
- package/lib/module/CompetitionSeasonManager/components/CreateSeasonForm.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/components/SeasonHeader.js +101 -0
- package/lib/module/CompetitionSeasonManager/components/SeasonHeader.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/components/SeasonInfoForm.js +233 -0
- package/lib/module/CompetitionSeasonManager/components/SeasonInfoForm.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/components/SeasonSettingsForm.js +343 -0
- package/lib/module/CompetitionSeasonManager/components/SeasonSettingsForm.js.map +1 -0
- package/lib/module/CompetitionSeasonManager/index.js +181 -0
- package/lib/module/CompetitionSeasonManager/index.js.map +1 -0
- package/lib/module/Components/Switch.js +3 -0
- package/lib/module/Components/Switch.js.map +1 -1
- package/lib/module/Engage/index.js +28 -1
- package/lib/module/Engage/index.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/Competition/api/index.d.ts +1 -0
- package/lib/typescript/src/Competition/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Competition/components/SeasonCard.d.ts +10 -0
- package/lib/typescript/src/Competition/components/SeasonCard.d.ts.map +1 -0
- package/lib/typescript/src/Competition/index.d.ts +3 -2
- package/lib/typescript/src/Competition/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/api/index.d.ts +1 -1
- package/lib/typescript/src/CompetitionManager/api/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionInfoForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/ContestSettingsForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CreateCompetitionForm.d.ts +3 -2
- package/lib/typescript/src/CompetitionManager/components/CreateCompetitionForm.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionSeason/api/index.d.ts +41 -0
- package/lib/typescript/src/CompetitionSeason/api/index.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeason/components/CompetitionsSection.d.ts +14 -0
- package/lib/typescript/src/CompetitionSeason/components/CompetitionsSection.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeason/components/EnterSeasonPrompt.d.ts +16 -0
- package/lib/typescript/src/CompetitionSeason/components/EnterSeasonPrompt.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeason/components/SeasonHeader.d.ts +15 -0
- package/lib/typescript/src/CompetitionSeason/components/SeasonHeader.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeason/components/SeasonLeaderboard.d.ts +18 -0
- package/lib/typescript/src/CompetitionSeason/components/SeasonLeaderboard.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeason/components/SeasonSettingsSection.d.ts +12 -0
- package/lib/typescript/src/CompetitionSeason/components/SeasonSettingsSection.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeason/index.d.ts +12 -0
- package/lib/typescript/src/CompetitionSeason/index.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/api/index.d.ts +31 -0
- package/lib/typescript/src/CompetitionSeasonManager/api/index.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionSelector.d.ts +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionSelector.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionsForm.d.ts +12 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionsForm.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/CreateSeasonForm.d.ts +11 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/CreateSeasonForm.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/SeasonHeader.d.ts +13 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/SeasonHeader.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/SeasonInfoForm.d.ts +11 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/SeasonInfoForm.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/SeasonSettingsForm.d.ts +12 -0
- package/lib/typescript/src/CompetitionSeasonManager/components/SeasonSettingsForm.d.ts.map +1 -0
- package/lib/typescript/src/CompetitionSeasonManager/index.d.ts +8 -0
- package/lib/typescript/src/CompetitionSeasonManager/index.d.ts.map +1 -0
- package/lib/typescript/src/Components/Switch.d.ts +2 -1
- package/lib/typescript/src/Components/Switch.d.ts.map +1 -1
- package/lib/typescript/src/Engage/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Competition/api/index.ts +15 -0
- package/src/Competition/components/CompetitionSeasonCard.tsx +1 -1
- package/src/Competition/components/SeasonCard.tsx +46 -0
- package/src/Competition/index.tsx +45 -27
- package/src/CompetitionManager/api/index.ts +2 -5
- package/src/CompetitionManager/components/CompetitionInfoForm.tsx +2 -64
- package/src/CompetitionManager/components/CompetitionSettingsForm.tsx +10 -3
- package/src/CompetitionManager/components/ContestSettingsForm.tsx +8 -2
- package/src/CompetitionManager/components/CreateCompetitionForm.tsx +20 -4
- package/src/CompetitionSeason/api/index.ts +111 -0
- package/src/CompetitionSeason/components/CompetitionsSection.tsx +99 -0
- package/src/CompetitionSeason/components/EnterSeasonPrompt.tsx +135 -0
- package/src/CompetitionSeason/components/SeasonHeader.tsx +81 -0
- package/src/CompetitionSeason/components/SeasonLeaderboard.tsx +205 -0
- package/src/CompetitionSeason/components/SeasonSettingsSection.tsx +92 -0
- package/src/CompetitionSeason/index.tsx +244 -0
- package/src/CompetitionSeasonManager/api/index.ts +127 -0
- package/src/CompetitionSeasonManager/components/CompetitionSelector.tsx +2 -0
- package/src/CompetitionSeasonManager/components/CompetitionsForm.tsx +113 -0
- package/src/CompetitionSeasonManager/components/CreateSeasonForm.tsx +238 -0
- package/src/CompetitionSeasonManager/components/SeasonHeader.tsx +75 -0
- package/src/CompetitionSeasonManager/components/SeasonInfoForm.tsx +124 -0
- package/src/CompetitionSeasonManager/components/SeasonSettingsForm.tsx +185 -0
- package/src/CompetitionSeasonManager/index.tsx +151 -0
- package/src/Components/Switch.tsx +8 -3
- package/src/Engage/index.tsx +20 -0
- package/src/index.tsx +4 -1
- package/src/types.d.ts +48 -5
- package/lib/commonjs/Competition/components/ManageSeasonForm.js +0 -605
- package/lib/commonjs/Competition/components/ManageSeasonForm.js.map +0 -1
- package/lib/commonjs/Competition/components/SeasonInfoModal.js +0 -400
- package/lib/commonjs/Competition/components/SeasonInfoModal.js.map +0 -1
- package/lib/module/Competition/components/ManageSeasonForm.js +0 -596
- package/lib/module/Competition/components/ManageSeasonForm.js.map +0 -1
- package/lib/module/Competition/components/SeasonInfoModal.js +0 -391
- package/lib/module/Competition/components/SeasonInfoModal.js.map +0 -1
- package/lib/typescript/src/Competition/components/ManageSeasonForm.d.ts +0 -10
- package/lib/typescript/src/Competition/components/ManageSeasonForm.d.ts.map +0 -1
- package/lib/typescript/src/Competition/components/SeasonInfoModal.d.ts +0 -14
- package/lib/typescript/src/Competition/components/SeasonInfoModal.d.ts.map +0 -1
- package/src/Competition/components/ManageSeasonForm.tsx +0 -271
- package/src/Competition/components/SeasonInfoModal.tsx +0 -212
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react"
|
|
2
|
+
import { FlatList, Image, ScrollView, TouchableOpacity, View, ActivityIndicator } from "react-native"
|
|
3
|
+
import type { CompetitionSeasonPlayerProps, CompetitionSeasonProps, CompetitionSeasonResultProps, CompetitionTypeProps, MyPlayerProps, PublicPlayerProps } from "../../types"
|
|
4
|
+
import { Button, Icons, Text } from "../../Components"
|
|
5
|
+
import Colors from "../../constants/colors"
|
|
6
|
+
import { view_styles } from "../../constants/styles"
|
|
7
|
+
import { SeasonApi, SeasonHelpers } from "../api"
|
|
8
|
+
|
|
9
|
+
type SeasonLeaderboardProps = {
|
|
10
|
+
competition_season:CompetitionSeasonProps,
|
|
11
|
+
competition_type:CompetitionTypeProps,
|
|
12
|
+
height: number,
|
|
13
|
+
authenticated_player?:MyPlayerProps,
|
|
14
|
+
authenticated_season_player?:CompetitionSeasonPlayerProps,
|
|
15
|
+
authenticated_season_result?:CompetitionSeasonResultProps,
|
|
16
|
+
width:number,
|
|
17
|
+
view_mode: 'short'|'full',
|
|
18
|
+
onClose?:() => void,
|
|
19
|
+
onSeeFull: () => void,
|
|
20
|
+
onLeaderSelect:(player:PublicPlayerProps) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const SeasonLeaderboard = ({ competition_season, authenticated_player, authenticated_season_player, authenticated_season_result, competition_type, width, height, view_mode, onSeeFull, onClose, onLeaderSelect }:SeasonLeaderboardProps) => {
|
|
24
|
+
const [ expanded, setExpanded ] = useState(false);
|
|
25
|
+
const [ data, setData ] = useState<{
|
|
26
|
+
loading:boolean,
|
|
27
|
+
competition_season_results:CompetitionSeasonResultProps[],
|
|
28
|
+
competition_season_players:CompetitionSeasonPlayerProps[],
|
|
29
|
+
players:PublicPlayerProps[],
|
|
30
|
+
offset:number
|
|
31
|
+
}>({
|
|
32
|
+
loading:false,
|
|
33
|
+
competition_season_results:[],
|
|
34
|
+
competition_season_players:[],
|
|
35
|
+
players:[],
|
|
36
|
+
offset:0
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const { loading, competition_season_results, competition_season_players, players, offset } = data
|
|
40
|
+
let results = [ ...competition_season_results ];
|
|
41
|
+
|
|
42
|
+
if(view_mode == 'short'){ results = results.filter((r,i) => r ? i < 3 : i < 3) }
|
|
43
|
+
const cl = competition_season?.market_type == 'FOR_MONEY' ? '$' : 'E'
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if(!competition_season){ return }
|
|
47
|
+
getLeaderboardFromServer(competition_season.competition_season_id, 0);
|
|
48
|
+
},[competition_season])
|
|
49
|
+
|
|
50
|
+
const getLeaderboardFromServer = async(season_id:string, offset:number) => {
|
|
51
|
+
setData({ ...data, loading:true })
|
|
52
|
+
const result_response = await SeasonApi.getSeasonPlayersBySeasonId(season_id, offset);
|
|
53
|
+
let player_ids = result_response.competition_season_players.map(cr => cr.player_id)
|
|
54
|
+
let players:PublicPlayerProps[] = []
|
|
55
|
+
if(player_ids.length > 0){ players = await SeasonApi.getPlayersByPlayerIds(player_ids) }
|
|
56
|
+
setData({
|
|
57
|
+
...data,
|
|
58
|
+
players,
|
|
59
|
+
competition_season_players: result_response.competition_season_players,
|
|
60
|
+
competition_season_results: result_response.competition_season_results,
|
|
61
|
+
offset,
|
|
62
|
+
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const renderResults = (data: {item:CompetitionSeasonResultProps, index:number}) => {
|
|
67
|
+
let player:PublicPlayerProps | undefined = players.find(p => p.player_id == data.item.player_id)
|
|
68
|
+
let record = competition_season_players.find(r => r.player_id == data.item.player_id)
|
|
69
|
+
if(!player || !record){ return <></> }
|
|
70
|
+
|
|
71
|
+
const is_pacer = competition_season.pacer_id == data.item.player_id ? true : false
|
|
72
|
+
return (
|
|
73
|
+
<TouchableOpacity
|
|
74
|
+
onPress={() => onLeaderSelect(player)}
|
|
75
|
+
style={{ flexDirection:'row', margin:5, alignItems:'center', borderRadius:22, backgroundColor:is_pacer?Colors.highlights.highlight400Faded:Colors.shades.white, padding:8, paddingLeft:15, paddingRight:15}}>
|
|
76
|
+
{is_pacer ?
|
|
77
|
+
<View nativeID="pacer" style={{}}>
|
|
78
|
+
<Icons.PacerCarIcon size={28}/>
|
|
79
|
+
</View>
|
|
80
|
+
:
|
|
81
|
+
<View nativeID="place" style={{ padding:5 }}>
|
|
82
|
+
<Text size={12} color={Colors.brand.midnight} weight="bold">{SeasonHelpers.formatPlace(data.item.place)}</Text>
|
|
83
|
+
</View>
|
|
84
|
+
}
|
|
85
|
+
<View nativeID="image" style={{ paddingLeft:10, paddingRight:10 }}>
|
|
86
|
+
<Image
|
|
87
|
+
source={{ uri: player.profile_pic }}
|
|
88
|
+
style={{ height:30, width:30, borderRadius:100 }}
|
|
89
|
+
resizeMode="cover"
|
|
90
|
+
/>
|
|
91
|
+
</View>
|
|
92
|
+
<View nativeID="details" style={{ flex:1 }}>
|
|
93
|
+
<Text size={12} color={Colors.brand.midnight} weight='semibold'>{player.username}</Text>
|
|
94
|
+
{competition_type?.type == 'wager' ?
|
|
95
|
+
<Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>{record.earnings.toFixed(2)} Earned</Text>
|
|
96
|
+
:
|
|
97
|
+
<Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>{record.wins} - {record.losses} - {record.draws}</Text>
|
|
98
|
+
}
|
|
99
|
+
</View>
|
|
100
|
+
<View nativeID="winnings">
|
|
101
|
+
<Text size={12} color={Colors.brand.slate} weight='regular'>{cl}{data.item.winnings.toFixed(2)}</Text>
|
|
102
|
+
</View>
|
|
103
|
+
</TouchableOpacity>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<View style={{ ...view_styles.section, margin:view_mode == 'full'?0:10, minWidth:350, height:view_mode == 'full'?height:undefined, width: view_mode == 'full' ? width: undefined }}>
|
|
109
|
+
{view_mode == 'short' ?
|
|
110
|
+
<TouchableOpacity style={view_styles.section_header} onPress={() => setExpanded(!expanded)}>
|
|
111
|
+
<Icons.PodiumIcon size={18} color={Colors.brand.midnight} />
|
|
112
|
+
<View style={{ flex:1, marginLeft:10 }}>
|
|
113
|
+
<Text theme="header">Season Leaderboard</Text>
|
|
114
|
+
<Text style={{ marginTop: 4 }} theme="body_2">Leaderboard showing current standings of this season.</Text>
|
|
115
|
+
</View>
|
|
116
|
+
<Icons.ChevronIcon direction={expanded?'up':'down'} color={Colors.brand.midnight} size={8} />
|
|
117
|
+
</TouchableOpacity>
|
|
118
|
+
:<></>}
|
|
119
|
+
{expanded || view_mode == 'full' ?
|
|
120
|
+
<View style={{ ...view_styles.section_body }}>
|
|
121
|
+
{authenticated_player && authenticated_season_player && authenticated_season_result ?
|
|
122
|
+
<View>
|
|
123
|
+
<View style={{ backgroundColor:Colors.brand.midnight, padding:10, marginBottom:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
124
|
+
<Text size={14} color={Colors.shades.white} weight='regular'>MY RESULTS</Text>
|
|
125
|
+
<TouchableOpacity style={{ flexDirection:'row', marginTop:10, marginBottom:10, alignItems:'center', borderRadius:22, backgroundColor:Colors.shades.white, padding:8, paddingLeft:15, paddingRight:15}}>
|
|
126
|
+
<View nativeID="place" style={{ padding:5 }}>
|
|
127
|
+
<Text size={12} color={Colors.brand.midnight} weight="bold">{SeasonHelpers.formatPlace(authenticated_season_result.place)}</Text>
|
|
128
|
+
</View>
|
|
129
|
+
<View nativeID="image" style={{ paddingLeft:10, paddingRight:10 }}>
|
|
130
|
+
<Image
|
|
131
|
+
source={{ uri: authenticated_player.profile_pic }}
|
|
132
|
+
style={{ height:30, width:30, borderRadius:100 }}
|
|
133
|
+
resizeMode="cover"
|
|
134
|
+
/>
|
|
135
|
+
</View>
|
|
136
|
+
<View nativeID="details" style={{ flex:1 }}>
|
|
137
|
+
<Text size={12} color={Colors.brand.midnight} weight='semibold'>{authenticated_player.username}</Text>
|
|
138
|
+
{competition_type?.type == 'wager' ?
|
|
139
|
+
<Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>{authenticated_season_player.earnings.toFixed(2)}</Text>
|
|
140
|
+
:
|
|
141
|
+
<Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>{authenticated_season_player.wins} - {authenticated_season_player.losses} - {authenticated_season_player.draws}</Text>
|
|
142
|
+
}
|
|
143
|
+
</View>
|
|
144
|
+
<View nativeID="winnings">
|
|
145
|
+
<Text size={12} color={Colors.brand.slate} weight='regular'>{cl}{authenticated_season_result.winnings.toFixed(2)}</Text>
|
|
146
|
+
</View>
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
</View>
|
|
149
|
+
</View>
|
|
150
|
+
:<></>}
|
|
151
|
+
<ScrollView style={{ backgroundColor:Colors.shades.shade100, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
|
|
152
|
+
{loading ?
|
|
153
|
+
<ActivityIndicator style={{ alignSelf:'center', padding:10 }} size='large' color={Colors.brand.midnight} />
|
|
154
|
+
:<></>}
|
|
155
|
+
<FlatList
|
|
156
|
+
data={results}
|
|
157
|
+
renderItem={renderResults}
|
|
158
|
+
keyExtractor={(item) => item.competition_season_result_id.toString()}
|
|
159
|
+
/>
|
|
160
|
+
|
|
161
|
+
</ScrollView>
|
|
162
|
+
{view_mode == 'short' ?
|
|
163
|
+
<Button
|
|
164
|
+
style={{ backgroundColor:undefined }}
|
|
165
|
+
title='View Full Leaderboard'
|
|
166
|
+
title_color={Colors.brand.electric}
|
|
167
|
+
title_size={14}
|
|
168
|
+
onPress={() => onSeeFull()}
|
|
169
|
+
/>
|
|
170
|
+
:<></>}
|
|
171
|
+
{onClose ?
|
|
172
|
+
<View style={{ padding:10, ...view_styles.float }}>
|
|
173
|
+
<View style={{ padding:10, flexDirection:'row', alignItems:'center', justifyContent:'space-between' }}>
|
|
174
|
+
{offset > 0 ?
|
|
175
|
+
<Button
|
|
176
|
+
title='PREV'
|
|
177
|
+
title_color={Colors.brand.electric}
|
|
178
|
+
backgroundColor='transparent'
|
|
179
|
+
onPress={() => getLeaderboardFromServer(competition_season.competition_season_id, offset - 1)}
|
|
180
|
+
/>
|
|
181
|
+
:<View/>}
|
|
182
|
+
<Button
|
|
183
|
+
title='NEXT'
|
|
184
|
+
title_color={Colors.brand.electric}
|
|
185
|
+
backgroundColor='transparent'
|
|
186
|
+
onPress={() => getLeaderboardFromServer(competition_season.competition_season_id, offset + 1)}
|
|
187
|
+
/>
|
|
188
|
+
</View>
|
|
189
|
+
<Button
|
|
190
|
+
title='Close'
|
|
191
|
+
style={{ padding:15 }}
|
|
192
|
+
title_color={Colors.shades.white}
|
|
193
|
+
backgroundColor={Colors.utility.error}
|
|
194
|
+
onPress={() => onClose()}
|
|
195
|
+
/>
|
|
196
|
+
</View>
|
|
197
|
+
:<></>}
|
|
198
|
+
</View>
|
|
199
|
+
:<></>}
|
|
200
|
+
|
|
201
|
+
</View>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default SeasonLeaderboard
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View, TouchableOpacity, FlatList } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { CompetitionPayoutTypeProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps } from "../../types"
|
|
5
|
+
import { view_styles } from '../../constants/styles';
|
|
6
|
+
import { Icons, Text } from '../../Components';
|
|
7
|
+
import { SeasonHelpers } from '../api';
|
|
8
|
+
import Colors from '../../constants/colors';
|
|
9
|
+
|
|
10
|
+
type SeasonSettingsSectionProps = {
|
|
11
|
+
width:number,
|
|
12
|
+
competition_season:CompetitionSeasonProps,
|
|
13
|
+
competition_type:CompetitionTypeProps,
|
|
14
|
+
competition_result_type:CompetitionResultTypeProps,
|
|
15
|
+
competition_payouts:CompetitionPayoutTypeProps[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const SeasonSettingsSection = ({ width, competition_season, competition_type, competition_result_type, competition_payouts }:SeasonSettingsSectionProps) => {
|
|
19
|
+
const [ expanded, setExpanded ] = useState(true);
|
|
20
|
+
|
|
21
|
+
const { season_payout, competition_payout } = SeasonHelpers.getPayoutAmounts(competition_season)
|
|
22
|
+
const cl = competition_season.market_type == 'FOR_MONEY' ? '$' : 'E'
|
|
23
|
+
|
|
24
|
+
const renderPayouts = (data: { item:CompetitionPayoutTypeProps, index:number }) => {
|
|
25
|
+
return (
|
|
26
|
+
<View style={{ ...view_styles.body_row, padding:8, borderBottomWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
27
|
+
<Text style={{ flex:1 }} theme='header_2'>{SeasonHelpers.formatPlace(data.item.tier)}{data.item.tier!= 1 ? ' Or Better': ''}</Text>
|
|
28
|
+
<Text theme='header_2'>Split {data.item.payout}%</Text>
|
|
29
|
+
</View>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View style={{ ...view_styles.section, maxWidth: width }}>
|
|
35
|
+
<TouchableOpacity style={{ ...view_styles.section_header }} onPress={() => setExpanded(!expanded)}>
|
|
36
|
+
<Icons.SettingsIcon size={18} color={Colors.brand.midnight} />
|
|
37
|
+
<View style={{ flex:1, marginLeft:10 }}>
|
|
38
|
+
<Text theme='header'>Season Details</Text>
|
|
39
|
+
<Text style={{ marginTop:3 }} theme='body'>View important details about this season.</Text>
|
|
40
|
+
</View>
|
|
41
|
+
<Icons.ChevronIcon direction={expanded ? 'up' : 'down'} size={8} color={Colors.brand.midnight} />
|
|
42
|
+
</TouchableOpacity>
|
|
43
|
+
{expanded ?
|
|
44
|
+
<View style={{ ...view_styles.section_body }}>
|
|
45
|
+
<View style={view_styles.body_row}>
|
|
46
|
+
<View style={{ flex:1 }}>
|
|
47
|
+
<Text theme='header_2'>Competition Type</Text>
|
|
48
|
+
<Text style={{ marginTop:3 }} theme='body_2'>Each competition within this season will use this type</Text>
|
|
49
|
+
</View>
|
|
50
|
+
<Text theme='header'>{competition_type.type_label.toUpperCase()}</Text>
|
|
51
|
+
</View>
|
|
52
|
+
<View style={view_styles.body_row}>
|
|
53
|
+
<View style={{ flex:1 }}>
|
|
54
|
+
<Text theme='header_2'>Season Winner Allocation</Text>
|
|
55
|
+
<Text style={{ marginTop:3 }} theme='body_2'>How much of the total pot is dedicated to the season winner?</Text>
|
|
56
|
+
</View>
|
|
57
|
+
<View style={{ justifyContent:'center', alignItems:'center' }}>
|
|
58
|
+
<Text theme='header_2'>{cl}{season_payout.toFixed(2)}</Text>
|
|
59
|
+
<Text style={{ marginTop:3 }} theme='body'>{(parseFloat(competition_season.payout_allocation as string) * 100).toFixed(2)}%</Text>
|
|
60
|
+
</View>
|
|
61
|
+
</View>
|
|
62
|
+
<View style={view_styles.body_row}>
|
|
63
|
+
<View style={{ flex:1 }}>
|
|
64
|
+
<Text theme='header_2'>Each Competition Allocation</Text>
|
|
65
|
+
<Text style={{ marginTop:3 }} theme='body_2'>How much of the total pot is dedicated to each competition winner?</Text>
|
|
66
|
+
</View>
|
|
67
|
+
<View style={{ justifyContent:'center', alignItems:'center' }}>
|
|
68
|
+
<Text theme='header_2'>{cl}{competition_payout.toFixed(2)}</Text>
|
|
69
|
+
<Text style={{ marginTop:3 }} theme='body'>{(( 1 - (parseFloat(competition_season.payout_allocation as string))) * 100).toFixed(2)}%</Text>
|
|
70
|
+
</View>
|
|
71
|
+
</View>
|
|
72
|
+
<View style={view_styles.body_row}>
|
|
73
|
+
<Text style={{flex:1}} theme="header_2">Payout Type</Text>
|
|
74
|
+
<Text theme="header_2">{competition_result_type.label.toUpperCase()}</Text>
|
|
75
|
+
</View>
|
|
76
|
+
<View style={{ padding:10, borderRadius:8, backgroundColor:Colors.shades.shade100 }}>
|
|
77
|
+
<Text style={{ padding:5 }} theme="header_2">{competition_result_type.description}</Text>
|
|
78
|
+
<View style={{ padding:10 }}>
|
|
79
|
+
<FlatList
|
|
80
|
+
data={competition_payouts.filter(cp => cp.competition_result_type_id == competition_season.competition_result_type_id).sort((a,b) => b.tier - a.tier)}
|
|
81
|
+
renderItem={renderPayouts}
|
|
82
|
+
keyExtractor={(item) => item.competition_payout_type_id.toString()}
|
|
83
|
+
/>
|
|
84
|
+
</View>
|
|
85
|
+
</View>
|
|
86
|
+
</View>
|
|
87
|
+
:<></>}
|
|
88
|
+
</View>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default SeasonSettingsSection
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View, ActivityIndicator, ScrollView } from 'react-native';
|
|
3
|
+
import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionSeasonPlayerProps, CompetitionSeasonProps, CompetitionSeasonResultProps, CompetitionTypeProps, MyPlayerProps, PlayerBalanceProps, PublicPlayerProps } from '../types';
|
|
4
|
+
import Colors from '../constants/colors';
|
|
5
|
+
import SeasonHeader from './components/SeasonHeader';
|
|
6
|
+
import { SeasonApi } from './api';
|
|
7
|
+
import CompetitionsSection from './components/CompetitionsSection';
|
|
8
|
+
import SeasonSettingsSection from './components/SeasonSettingsSection';
|
|
9
|
+
import EnterSeasonPrompt from './components/EnterSeasonPrompt';
|
|
10
|
+
import SeasonLeaderboard from './components/SeasonLeaderboard';
|
|
11
|
+
|
|
12
|
+
type SeasonModuleProps = {
|
|
13
|
+
competition_season_id:string,
|
|
14
|
+
onShareSeason: (competition_season:CompetitionSeasonProps) => void,
|
|
15
|
+
player_id?:string,
|
|
16
|
+
onRequestAuthenticate: (auth_strategy_id?:string) => void,
|
|
17
|
+
onCompetitionSelect: (c:CompetitionProps) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const SeasonModule = ({ competition_season_id, player_id, onShareSeason, onRequestAuthenticate, onCompetitionSelect }:SeasonModuleProps) => {
|
|
21
|
+
const [ module_size, setModuleSize ] = useState({ width:0, height:0 })
|
|
22
|
+
const [ show_leaderboard, setShowLeaderboard ] = useState(false);
|
|
23
|
+
const [ show_enter, setShowEnter ] = useState(false);
|
|
24
|
+
const [ my_data, setMyData ] = useState<{
|
|
25
|
+
my_loading: boolean,
|
|
26
|
+
player?:MyPlayerProps,
|
|
27
|
+
player_balance?:PlayerBalanceProps
|
|
28
|
+
}>({
|
|
29
|
+
my_loading: false
|
|
30
|
+
});
|
|
31
|
+
const [ module_data, setData ] = useState<{
|
|
32
|
+
loading:boolean,
|
|
33
|
+
action_loading:boolean,
|
|
34
|
+
competition_season?:CompetitionSeasonProps,
|
|
35
|
+
competitions:CompetitionProps[],
|
|
36
|
+
offset:number,
|
|
37
|
+
competition_types:CompetitionTypeProps[],
|
|
38
|
+
company?:CompanyProps,
|
|
39
|
+
admin?:PublicPlayerProps,
|
|
40
|
+
players:PublicPlayerProps[],
|
|
41
|
+
competition_season_players:CompetitionSeasonPlayerProps[],
|
|
42
|
+
competition_season_results:CompetitionSeasonResultProps[],
|
|
43
|
+
competition_result_types:CompetitionResultTypeProps[],
|
|
44
|
+
competition_payout_types:CompetitionPayoutTypeProps[]
|
|
45
|
+
}>({
|
|
46
|
+
loading:false,
|
|
47
|
+
action_loading:false,
|
|
48
|
+
competitions: [],
|
|
49
|
+
offset: 0,
|
|
50
|
+
competition_season_players:[],
|
|
51
|
+
competition_season_results: [],
|
|
52
|
+
competition_types:[],
|
|
53
|
+
players: [],
|
|
54
|
+
competition_result_types:[],
|
|
55
|
+
competition_payout_types:[]
|
|
56
|
+
});
|
|
57
|
+
const { action_loading, competition_season, competitions, competition_season_players, competition_season_results, competition_types, competition_payout_types, competition_result_types } = module_data;
|
|
58
|
+
const { player, player_balance } = my_data;
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if(!competition_season_id){ return }
|
|
61
|
+
SeasonApi.setEnvironment();
|
|
62
|
+
getSeasonData(competition_season_id)
|
|
63
|
+
},[competition_season_id])
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
getMyDetails();
|
|
67
|
+
},[player_id])
|
|
68
|
+
|
|
69
|
+
const getMyDetails = async() => {
|
|
70
|
+
if(!player_id){ return setMyData({ ...my_data, player:undefined, player_balance: undefined }) }
|
|
71
|
+
setMyData({ ...my_data, my_loading: true })
|
|
72
|
+
let me = await SeasonApi.getMyDetails();
|
|
73
|
+
let pb = await SeasonApi.getMyBalance();
|
|
74
|
+
setMyData({
|
|
75
|
+
...my_data,
|
|
76
|
+
my_loading: false,
|
|
77
|
+
player: me,
|
|
78
|
+
player_balance: pb
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const getSeasonData = async(id:string) => {
|
|
83
|
+
setData({ ...module_data, loading:true })
|
|
84
|
+
const season = await SeasonApi.getSeasonById(id);
|
|
85
|
+
const comps = await SeasonApi.getCompetitionsBySeasonId(id)
|
|
86
|
+
const opts = await SeasonApi.getCompetitionOptions();
|
|
87
|
+
const season_player_resp = await SeasonApi.getSeasonPlayersBySeasonId(id, 0);
|
|
88
|
+
const players = await SeasonApi.getPlayersByPlayerIds([season.admin_id])
|
|
89
|
+
let cmpny:CompanyProps | undefined = undefined
|
|
90
|
+
if(season.company_id){
|
|
91
|
+
const companies = await SeasonApi.getCompaniesByIds([season.company_id])
|
|
92
|
+
cmpny = companies[0]
|
|
93
|
+
}
|
|
94
|
+
setData({
|
|
95
|
+
...module_data,
|
|
96
|
+
loading:false,
|
|
97
|
+
competition_season: season,
|
|
98
|
+
competitions:comps,
|
|
99
|
+
admin: players[0],
|
|
100
|
+
company: cmpny,
|
|
101
|
+
competition_payout_types: opts.competition_payout_types,
|
|
102
|
+
competition_result_types: opts.competition_result_types,
|
|
103
|
+
competition_types: opts.competition_types,
|
|
104
|
+
competition_season_players: season_player_resp.competition_season_players,
|
|
105
|
+
competition_season_results: season_player_resp.competition_season_results
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const handleJoin = async() => {
|
|
110
|
+
if(action_loading){ return } //No mashy
|
|
111
|
+
if(!player_id){ return onRequestAuthenticate() }
|
|
112
|
+
setData({ ...module_data, action_loading: true });
|
|
113
|
+
const resp = await SeasonApi.joinSeason(competition_season_id);
|
|
114
|
+
setData({
|
|
115
|
+
...module_data,
|
|
116
|
+
action_loading: false,
|
|
117
|
+
competition_season: resp.competition_season,
|
|
118
|
+
competition_season_players: competition_season_players.filter(cp => cp.competition_season_player_id != resp.competition_season_player.competition_season_player_id).concat(resp.competition_season_player),
|
|
119
|
+
competition_season_results: competition_season_results.filter(cr => cr.competition_season_result_id != resp.competition_season_result.competition_season_result_id).concat(resp.competition_season_result),
|
|
120
|
+
competitions: competitions.filter(c => !resp.competitions.find(nc => nc.competition_id == c.competition_id)).concat(resp.competitions)
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const handleLeave = async(competition_season_player_id:string) => {
|
|
125
|
+
if(action_loading){ return }
|
|
126
|
+
if(!player_id){ return onRequestAuthenticate() }
|
|
127
|
+
setData({ ...module_data, action_loading: true });
|
|
128
|
+
const resp = await SeasonApi.leaveSeason(competition_season_player_id);
|
|
129
|
+
setData({
|
|
130
|
+
...module_data,
|
|
131
|
+
action_loading: false,
|
|
132
|
+
competition_season: resp.competition_season,
|
|
133
|
+
competition_season_players: competition_season_players.filter(cp => cp.competition_season_player_id != resp.competition_season_player.competition_season_player_id),
|
|
134
|
+
competition_season_results: competition_season_results.filter(cr => cr.competition_season_result_id != resp.competition_season_result.competition_season_result_id).concat(resp.competition_season_result),
|
|
135
|
+
competitions: competitions.filter(c => !resp.competitions.find(nc => nc.competition_id == c.competition_id)).concat(resp.competitions)
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if(!competition_season){
|
|
140
|
+
return (
|
|
141
|
+
<View style={{ flex:1 }}>
|
|
142
|
+
<ActivityIndicator
|
|
143
|
+
size='large'
|
|
144
|
+
style={{ padding:20, alignSelf:'center' }}
|
|
145
|
+
color={Colors.brand.midnight}
|
|
146
|
+
/>
|
|
147
|
+
</View>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const selected_season_type = competition_types.find(ct => ct.competition_type_id == competition_season.competition_type_id);
|
|
152
|
+
const selected_season_result_type = competition_result_types.find(crt => crt.competition_result_type_id == competition_season.competition_result_type_id);
|
|
153
|
+
const authenticated_season_player = competition_season_players.find(csp => csp.player_id == player_id);
|
|
154
|
+
const authenticated_season_result = competition_season_results.find(csp => csp.player_id == player_id);
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<View style={{ flex:1 }}>
|
|
158
|
+
<ScrollView style={{ flex:1 }} onLayout={(ev) => {
|
|
159
|
+
const { width, height } = ev.nativeEvent.layout;
|
|
160
|
+
setModuleSize({ width, height });
|
|
161
|
+
}}>
|
|
162
|
+
<SeasonHeader
|
|
163
|
+
competition_season={competition_season}
|
|
164
|
+
competitions={competitions}
|
|
165
|
+
action_loading={action_loading}
|
|
166
|
+
authenticated_season_player={authenticated_season_player}
|
|
167
|
+
onShareSeason={onShareSeason}
|
|
168
|
+
onJoin={() => setShowEnter(true)}
|
|
169
|
+
onLeave={(competition_season_player_id) => handleLeave(competition_season_player_id)}
|
|
170
|
+
/>
|
|
171
|
+
{selected_season_type ?
|
|
172
|
+
<SeasonLeaderboard
|
|
173
|
+
authenticated_player={player}
|
|
174
|
+
authenticated_season_player={authenticated_season_player}
|
|
175
|
+
authenticated_season_result={authenticated_season_result}
|
|
176
|
+
width={module_size.width}
|
|
177
|
+
onLeaderSelect={(p) => console.log(p)}
|
|
178
|
+
view_mode='short'
|
|
179
|
+
height={module_size.height}
|
|
180
|
+
competition_season={competition_season}
|
|
181
|
+
competition_type={selected_season_type}
|
|
182
|
+
onSeeFull={() => setShowLeaderboard(true)}
|
|
183
|
+
/>
|
|
184
|
+
:<></>}
|
|
185
|
+
{selected_season_type && selected_season_result_type ?
|
|
186
|
+
<SeasonSettingsSection
|
|
187
|
+
competition_season={competition_season}
|
|
188
|
+
competition_result_type={selected_season_result_type}
|
|
189
|
+
competition_type={selected_season_type}
|
|
190
|
+
competition_payouts={competition_payout_types}
|
|
191
|
+
width={module_size.width}
|
|
192
|
+
/>
|
|
193
|
+
:<></>}
|
|
194
|
+
{selected_season_type && selected_season_result_type ?
|
|
195
|
+
<CompetitionsSection
|
|
196
|
+
competitions={competitions}
|
|
197
|
+
competition_result_type={selected_season_result_type}
|
|
198
|
+
competition_type={selected_season_type}
|
|
199
|
+
onCompetitionSelect={(c) => onCompetitionSelect(c)}
|
|
200
|
+
width={module_size.width}
|
|
201
|
+
/>
|
|
202
|
+
:<></>}
|
|
203
|
+
</ScrollView>
|
|
204
|
+
{show_enter && selected_season_result_type && selected_season_type ?
|
|
205
|
+
<View style={{ position:'absolute', top:0, left:0, right:0, bottom:0, backgroundColor:Colors.shades.black_faded, justifyContent:'flex-end' }}>
|
|
206
|
+
<EnterSeasonPrompt
|
|
207
|
+
width={module_size.width}
|
|
208
|
+
competition_season={competition_season}
|
|
209
|
+
competition_result_type={selected_season_result_type}
|
|
210
|
+
competition_type={selected_season_type}
|
|
211
|
+
player_balance={player_balance}
|
|
212
|
+
player={player}
|
|
213
|
+
onEnter={(promo) => {
|
|
214
|
+
console.log(promo)
|
|
215
|
+
handleJoin()
|
|
216
|
+
setShowEnter(false);
|
|
217
|
+
}}
|
|
218
|
+
onCancel={() => setShowEnter(false)}
|
|
219
|
+
onVerify={() => console.log('VERIFY!')}
|
|
220
|
+
/>
|
|
221
|
+
</View>
|
|
222
|
+
:<></>}
|
|
223
|
+
{show_leaderboard && selected_season_type ?
|
|
224
|
+
<View style={{ position:'absolute', top:0, left:0, right:0, bottom:0, backgroundColor:Colors.shades.black_faded }}>
|
|
225
|
+
<SeasonLeaderboard
|
|
226
|
+
authenticated_player={player}
|
|
227
|
+
authenticated_season_player={authenticated_season_player}
|
|
228
|
+
authenticated_season_result={authenticated_season_result}
|
|
229
|
+
width={module_size.width}
|
|
230
|
+
onLeaderSelect={(p) => console.log(p)}
|
|
231
|
+
view_mode='full'
|
|
232
|
+
height={module_size.height}
|
|
233
|
+
competition_season={competition_season}
|
|
234
|
+
competition_type={selected_season_type}
|
|
235
|
+
onSeeFull={() => console.log('See full')}
|
|
236
|
+
onClose={() => setShowLeaderboard(false)}
|
|
237
|
+
/>
|
|
238
|
+
</View>
|
|
239
|
+
:<></>}
|
|
240
|
+
</View>
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export default SeasonModule
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { APIOverrides } from "../../ApiOverrides";
|
|
3
|
+
import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps, MyPlayerProps } from "../../types";
|
|
4
|
+
import type { CompanyMemberProps } from "../../Authenticator/api/types";
|
|
5
|
+
import moment from "moment-mini";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let AUTH_SVC_API = ''
|
|
9
|
+
let TP_SVC_API = ''
|
|
10
|
+
//let EVENT_SVC_API = ''
|
|
11
|
+
//let MK_SVC_API = ''
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export { ManageSeasonApi, ManageSeasonHelpers }
|
|
15
|
+
|
|
16
|
+
const ManageSeasonApi = {
|
|
17
|
+
setEnvironment: () => {
|
|
18
|
+
const endpoints = APIOverrides.getEndpoints();
|
|
19
|
+
TP_SVC_API = endpoints['TP_SVC_API'] as string;
|
|
20
|
+
//EVENT_SVC_API = endpoints['EVENT_SVC_API'] as string;
|
|
21
|
+
//MK_SVC_API = endpoints['MK_SVC_API'] as string;
|
|
22
|
+
AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
|
|
23
|
+
},
|
|
24
|
+
getCompetitionOptions: async():Promise<{competition_types:CompetitionTypeProps[], competition_result_types:CompetitionResultTypeProps[], competition_payout_types:CompetitionPayoutTypeProps[]}> => {
|
|
25
|
+
const resp = await axios.get(`${TP_SVC_API}/v1/competitions/options`)
|
|
26
|
+
return resp.data
|
|
27
|
+
},
|
|
28
|
+
getSeasonTemplates: async():Promise<CompetitionSeasonProps[]> => {
|
|
29
|
+
const resp = await axios.get(`${TP_SVC_API}/v2/competitions/seasons/templates`);
|
|
30
|
+
return resp.data.competition_seasons
|
|
31
|
+
},
|
|
32
|
+
getMyDetails: async():Promise<MyPlayerProps> => {
|
|
33
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/players/player/me`)
|
|
34
|
+
return resp.data.player
|
|
35
|
+
},
|
|
36
|
+
getMyCompanies : async():Promise<{companies:CompanyProps[], company_members:CompanyMemberProps[]}> => {
|
|
37
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/companies/me`)
|
|
38
|
+
const { companies, company_members } = resp.data
|
|
39
|
+
return { companies, company_members }
|
|
40
|
+
},
|
|
41
|
+
activateSeason: async(competition_season_id:string):Promise<CompetitionSeasonProps> => {
|
|
42
|
+
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/season/activate`, { competition_season_id });
|
|
43
|
+
return resp.data.competition_season
|
|
44
|
+
},
|
|
45
|
+
deleteSeason: async(competition_season_id:string):Promise<CompetitionSeasonProps> => {
|
|
46
|
+
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/season/delete`, { competition_season_id });
|
|
47
|
+
return resp.data.competition_season
|
|
48
|
+
},
|
|
49
|
+
getSeasonById: async(competition_season_id:string):Promise<CompetitionSeasonProps> => {
|
|
50
|
+
const resp = await axios.get(`${TP_SVC_API}/v2/competitions/seasons/season/${competition_season_id}`);
|
|
51
|
+
return resp.data.competition_season
|
|
52
|
+
},
|
|
53
|
+
getCompetitionsBySeasonId: async(competition_season_id:string):Promise<CompetitionProps[]> => {
|
|
54
|
+
const resp = await axios.get(`${TP_SVC_API}/v2/competitions/season/${competition_season_id}`);
|
|
55
|
+
return resp.data.competitions
|
|
56
|
+
},
|
|
57
|
+
createSeason: async(competition_season:CompetitionSeasonProps):Promise<CompetitionSeasonProps> => {
|
|
58
|
+
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/seasons/season/create`, { competition_season });
|
|
59
|
+
console.log(resp.data)
|
|
60
|
+
return resp.data.competition_season
|
|
61
|
+
},
|
|
62
|
+
updateSeason: async(competition_season:CompetitionSeasonProps):Promise<CompetitionSeasonProps> => {
|
|
63
|
+
const resp = await axios.post(`${TP_SVC_API}/v2/competitions/seasons/season/update`, { competition_season })
|
|
64
|
+
return resp.data.competition_season
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const ManageSeasonHelpers = {
|
|
70
|
+
getPendingSeason: ():CompetitionSeasonProps => {
|
|
71
|
+
return {
|
|
72
|
+
competition_season_id: '',
|
|
73
|
+
admin_id: '',
|
|
74
|
+
season_name:'',
|
|
75
|
+
season_description:'Pending Description',
|
|
76
|
+
invite_only: true,
|
|
77
|
+
ticket_revenue:0,
|
|
78
|
+
tickets_available: 10,
|
|
79
|
+
tickets_sold:0,
|
|
80
|
+
single_buy_in: true,
|
|
81
|
+
expected_competition_count: 1,
|
|
82
|
+
ticket_price:0,
|
|
83
|
+
max_picks: 0,
|
|
84
|
+
initial_balance: 1000,
|
|
85
|
+
balance_rollover: false,
|
|
86
|
+
unallocated_funds: 0,
|
|
87
|
+
competition_type_id: '1',
|
|
88
|
+
allow_late_buy_in: false,
|
|
89
|
+
payout_allocation: 1,
|
|
90
|
+
competition_result_type_id: '1',
|
|
91
|
+
payout_amt: 0,
|
|
92
|
+
scheduled_datetime: moment().add(1, 'week'),
|
|
93
|
+
status: 'pending',
|
|
94
|
+
market_type: 'FOR_MONEY',
|
|
95
|
+
create_datetime: '',
|
|
96
|
+
last_update_datetime:''
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
isSeasonValid: (cs:CompetitionSeasonProps):string[] => {
|
|
100
|
+
let errors:string[] = []
|
|
101
|
+
if(!cs.season_name){ errors.push('Please provide a valid name') }
|
|
102
|
+
if(!cs.competition_result_type_id){ errors.push('Please give a valid competition result type') }
|
|
103
|
+
return errors
|
|
104
|
+
},
|
|
105
|
+
isInfoChanged: (cs:CompetitionSeasonProps, ds:CompetitionSeasonProps) => {
|
|
106
|
+
let init_cs = JSON.stringify({ season_name: cs.season_name, season_description: cs.season_description, invite_only:cs.invite_only })
|
|
107
|
+
let draft_cs = JSON.stringify({ season_name: ds.season_name, season_description: ds.season_description, invite_only:ds.invite_only })
|
|
108
|
+
return draft_cs != init_cs ? true : false
|
|
109
|
+
},
|
|
110
|
+
isSettingsChanged: (cs:CompetitionSeasonProps, ds:CompetitionSeasonProps) => {
|
|
111
|
+
let init_cs = JSON.stringify({ ticket_price:cs.ticket_price, payout_allocation:cs.payout_allocation, competition_type_id:cs.competition_type_id, competition_result_type_id:cs.competition_result_type_id, max_picks: cs.max_picks, initial_balance: cs.initial_balance, allow_late_buy_in:cs.allow_late_buy_in })
|
|
112
|
+
let draft_cs = JSON.stringify({ ticket_price:ds.ticket_price, payout_allocation: ds.payout_allocation, competition_type_id:ds.competition_type_id, competition_result_type_id:ds.competition_result_type_id, max_picks: ds.max_picks, initial_balance: ds.initial_balance, allow_late_buy_in:ds.allow_late_buy_in })
|
|
113
|
+
return draft_cs != init_cs ? true : false
|
|
114
|
+
},
|
|
115
|
+
isSettingsValid: (ds:CompetitionSeasonProps) => {
|
|
116
|
+
if(!ds.competition_type_id){ return false }
|
|
117
|
+
if(!ds.competition_result_type_id){ return false }
|
|
118
|
+
let payout_allocation = parseFloat(ds.payout_allocation as string)
|
|
119
|
+
let ticket_price = parseFloat(ds.ticket_price as string)
|
|
120
|
+
if(isNaN(payout_allocation)){ return false }
|
|
121
|
+
if(isNaN(ticket_price)){ return false }
|
|
122
|
+
if(ticket_price < 0){ return false }
|
|
123
|
+
if(payout_allocation <= 0){ return false }
|
|
124
|
+
if(payout_allocation > 1){ return false }
|
|
125
|
+
return true
|
|
126
|
+
}
|
|
127
|
+
}
|