be-components 5.4.2 → 5.4.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/Bracket/components/BracketCompetitionActions.js +3 -3
- package/lib/commonjs/Bracket/components/BracketCompetitionActions.js.map +1 -1
- package/lib/commonjs/Bracket/components/CompetitionLeaderboard.js +1 -0
- package/lib/commonjs/Bracket/components/CompetitionLeaderboard.js.map +1 -1
- package/lib/commonjs/Bracket/index.js +3 -2
- package/lib/commonjs/Bracket/index.js.map +1 -1
- package/lib/commonjs/Components/Jerseys.js +118 -114
- package/lib/commonjs/Components/Jerseys.js.map +1 -1
- package/lib/commonjs/GolfScoreboard/api/index.js +69 -0
- package/lib/commonjs/GolfScoreboard/api/index.js.map +1 -0
- package/lib/commonjs/GolfScoreboard/index.js +189 -0
- package/lib/commonjs/GolfScoreboard/index.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Bracket/components/BracketCompetitionActions.js +3 -3
- package/lib/module/Bracket/components/BracketCompetitionActions.js.map +1 -1
- package/lib/module/Bracket/components/CompetitionLeaderboard.js +1 -0
- package/lib/module/Bracket/components/CompetitionLeaderboard.js.map +1 -1
- package/lib/module/Bracket/index.js +3 -2
- package/lib/module/Bracket/index.js.map +1 -1
- package/lib/module/Components/Jerseys.js +118 -114
- package/lib/module/Components/Jerseys.js.map +1 -1
- package/lib/module/GolfScoreboard/api/index.js +62 -0
- package/lib/module/GolfScoreboard/api/index.js.map +1 -0
- package/lib/module/GolfScoreboard/index.js +180 -0
- package/lib/module/GolfScoreboard/index.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Bracket/components/CompetitionLeaderboard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Bracket/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/Jerseys.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts +11 -0
- package/lib/typescript/lib/commonjs/GolfScoreboard/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts +6 -0
- package/lib/typescript/lib/commonjs/GolfScoreboard/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Bracket/components/CompetitionLeaderboard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Bracket/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/Jerseys.d.ts.map +1 -1
- package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts +10 -0
- package/lib/typescript/lib/module/GolfScoreboard/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/GolfScoreboard/index.d.ts +6 -0
- package/lib/typescript/lib/module/GolfScoreboard/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
- package/lib/typescript/src/Bracket/components/CompetitionLeaderboard.d.ts.map +1 -1
- package/lib/typescript/src/Bracket/index.d.ts.map +1 -1
- package/lib/typescript/src/Components/Jerseys.d.ts.map +1 -1
- package/lib/typescript/src/GolfScoreboard/api/index.d.ts +15 -0
- package/lib/typescript/src/GolfScoreboard/api/index.d.ts.map +1 -0
- package/lib/typescript/src/GolfScoreboard/index.d.ts +7 -0
- package/lib/typescript/src/GolfScoreboard/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Bracket/components/BracketCompetitionActions.tsx +3 -4
- package/src/Bracket/components/CompetitionLeaderboard.tsx +1 -0
- package/src/Bracket/index.tsx +3 -2
- package/src/Components/Jerseys.tsx +88 -83
- package/src/GolfScoreboard/api/index.tsx +66 -0
- package/src/GolfScoreboard/index.tsx +142 -0
- package/src/index.tsx +2 -0
- package/src/types.d.ts +91 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Text, View } from "../Components/Themed"
|
|
3
|
+
import type { AthleteProps, GolfCourseProps, GolfLeaderProps, LeagueProps, TournamentProps } from '../types';
|
|
4
|
+
import { GolfApi, GolfHelpers } from './api';
|
|
5
|
+
import { FlatList, Image } from 'react-native';
|
|
6
|
+
import { useColors } from '../constants/useColors';
|
|
7
|
+
import moment from 'moment-mini';
|
|
8
|
+
import { AthleteImage } from '../Components/Jerseys';
|
|
9
|
+
|
|
10
|
+
type GolfScoreboardProps = {
|
|
11
|
+
tournament_id:string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const scorecard_sections = ['course','leaderboard'];
|
|
15
|
+
const GolfScoreboard = ({ tournament_id }:GolfScoreboardProps) => {
|
|
16
|
+
const Colors = useColors();
|
|
17
|
+
|
|
18
|
+
const [ scorecard_state, setScorecard ] = useState<{
|
|
19
|
+
loading:boolean,
|
|
20
|
+
tournament?:TournamentProps,
|
|
21
|
+
league?:LeagueProps,
|
|
22
|
+
athletes:AthleteProps[],
|
|
23
|
+
golf_leaders:GolfLeaderProps[],
|
|
24
|
+
golf_course?:GolfCourseProps
|
|
25
|
+
}>({
|
|
26
|
+
loading:false,
|
|
27
|
+
golf_leaders:[],
|
|
28
|
+
athletes:[]
|
|
29
|
+
});
|
|
30
|
+
const { loading, athletes, golf_leaders, golf_course, league } = scorecard_state;
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
GolfApi.setEnvironment();
|
|
34
|
+
getData(tournament_id)
|
|
35
|
+
},[tournament_id]);
|
|
36
|
+
|
|
37
|
+
const getData = async(tournament_id:string) => {
|
|
38
|
+
setScorecard({ ...scorecard_state, loading:true });
|
|
39
|
+
const golf_data = await GolfApi.getScoreboard(tournament_id);
|
|
40
|
+
const tourney = await GolfApi.getTournamentById(tournament_id);
|
|
41
|
+
const lg = await GolfApi.getLeagueById(tourney?.league_id ?? '9');
|
|
42
|
+
if(!golf_data){ return alert('Unable to process') }
|
|
43
|
+
setScorecard({
|
|
44
|
+
...scorecard_state,
|
|
45
|
+
tournament: tourney,
|
|
46
|
+
league: lg,
|
|
47
|
+
golf_course: golf_data.golf_course,
|
|
48
|
+
golf_leaders: golf_data.golf_leaders,
|
|
49
|
+
athletes:golf_data.athletes,
|
|
50
|
+
loading: false
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const renderLeaders = (data:{ item:GolfLeaderProps, index:number }) => {
|
|
55
|
+
const athlete = athletes.find(a => a.athlete_id == data.item.athlete_id);
|
|
56
|
+
if(!athlete){ return <></> }
|
|
57
|
+
let current_round = data.item.leader_rounds.find(r => r.status == 'inprogress');
|
|
58
|
+
return (
|
|
59
|
+
<View style={{ borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
60
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
61
|
+
{data.item.place != 999 ?
|
|
62
|
+
<View transparent style={{ padding:10 }}>
|
|
63
|
+
<Text theme='h2'>{GolfHelpers.formatPlace(data.item.place)}</Text>
|
|
64
|
+
</View>
|
|
65
|
+
:<></>}
|
|
66
|
+
<View float style={{ borderRadius:100, padding:2, marginLeft:5 }}>
|
|
67
|
+
<AthleteImage
|
|
68
|
+
athlete={athlete}
|
|
69
|
+
league={league}
|
|
70
|
+
size={24}
|
|
71
|
+
/>
|
|
72
|
+
</View>
|
|
73
|
+
<View transparent style={{ flex:1, marginLeft:5 }}>
|
|
74
|
+
<Text theme='h2'>{athlete.first_name} {athlete.last_name}</Text>
|
|
75
|
+
<Text theme='description' style={{ marginTop:3 }}>World Rank: {data.item.rank == 999 ? 'NA' : data.item.rank}</Text>
|
|
76
|
+
</View>
|
|
77
|
+
<View>
|
|
78
|
+
<Text textAlign='right' theme='h2' color={data.item.score < 0 ? Colors.text.error : Colors.text.h1}>{data.item.score_label}</Text>
|
|
79
|
+
{data.item.tee_time && current_round?.thru == 0 ?
|
|
80
|
+
<Text textAlign='right' theme='description' style={{ marginTop:2 }}>{moment(data.item.tee_time).format('HH:mm a')}</Text>
|
|
81
|
+
:<></>}
|
|
82
|
+
</View>
|
|
83
|
+
{current_round ?
|
|
84
|
+
<View style={{ padding:5 }}>
|
|
85
|
+
<Text>{current_round.thru > 0 ? current_round.thru : ''}</Text>
|
|
86
|
+
</View>
|
|
87
|
+
:<></>}
|
|
88
|
+
</View>
|
|
89
|
+
</View>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const renderSections = (data:{ item:string, index:number }) => {
|
|
94
|
+
switch(data.item){
|
|
95
|
+
case 'course':
|
|
96
|
+
if(!golf_course){ return <></> }
|
|
97
|
+
console.log('RENDERING HERE!!!')
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10}}>
|
|
101
|
+
{league ?
|
|
102
|
+
<Image
|
|
103
|
+
source={{ uri: league.league_image }}
|
|
104
|
+
style={{ height:50, width:50 }}
|
|
105
|
+
resizeMode='cover'
|
|
106
|
+
/>
|
|
107
|
+
:<></>}
|
|
108
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
109
|
+
<Text theme='h1'>{golf_course.course_name}</Text>
|
|
110
|
+
<Text theme='description' style={{ marginTop:3 }}>Par {golf_course.par} - {golf_course.yardage} yards</Text>
|
|
111
|
+
</View>
|
|
112
|
+
</View>
|
|
113
|
+
)
|
|
114
|
+
case 'leaderboard':
|
|
115
|
+
return (
|
|
116
|
+
<FlatList
|
|
117
|
+
data={golf_leaders.sort((a,b) => a.place - b.place)}
|
|
118
|
+
keyExtractor={(item) => item.athlete_id.toString()}
|
|
119
|
+
renderItem={renderLeaders}
|
|
120
|
+
key='leader_list'
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
default: return <></>
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return (
|
|
127
|
+
<View style={{ flex:1 }}>
|
|
128
|
+
<View style={{ flex:1 }}>
|
|
129
|
+
<FlatList
|
|
130
|
+
data={scorecard_sections}
|
|
131
|
+
key={'golf_list'}
|
|
132
|
+
refreshing={loading}
|
|
133
|
+
onRefresh={() => getData(tournament_id)}
|
|
134
|
+
keyExtractor={item => item}
|
|
135
|
+
renderItem={renderSections}
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
</View>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default GolfScoreboard
|
package/src/index.tsx
CHANGED
|
@@ -46,6 +46,7 @@ import LeaderboardCard from './Leaders/components/LeaderboardCard';
|
|
|
46
46
|
import PlayerRecommender from './PlayerRecommender';
|
|
47
47
|
import ContactsCard from './PlayerRecommender/components/ContactCard';
|
|
48
48
|
import ContactsSelector from './PlayerRecommender/components/ContactsSelector';
|
|
49
|
+
import GolfScoreboard from './GolfScoreboard';
|
|
49
50
|
|
|
50
51
|
export {
|
|
51
52
|
Authenticator,
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
LocationTracker,
|
|
58
59
|
ContactsCard,
|
|
59
60
|
PlayerRecommender,
|
|
61
|
+
GolfScoreboard,
|
|
60
62
|
ContactsSelector,
|
|
61
63
|
Campaign,
|
|
62
64
|
ManageBracketCompetitionForm,
|
package/src/types.d.ts
CHANGED
|
@@ -27,6 +27,97 @@ export interface PublicPlayerProps {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
export interface GolfLeaderProps {
|
|
31
|
+
tournament_id:string,
|
|
32
|
+
athlete_id:string,
|
|
33
|
+
place:number, //Active place. If the tournament hasnt started, will default to 1
|
|
34
|
+
status: 'active'|'inactive', //Will be active if the player is still playing. Inactive if CUT, WD or the tournament is not inprogress
|
|
35
|
+
cut?:boolean, //Cut indicator
|
|
36
|
+
wd?:boolean, //Withdraw indicator
|
|
37
|
+
tied:boolean,
|
|
38
|
+
money:number,
|
|
39
|
+
tee_time?:any,
|
|
40
|
+
rank:number,
|
|
41
|
+
strokes: number //Total number of strokes. Defaults to 0 if tournament hasn't started
|
|
42
|
+
score: number //Score relative to par (i.e., -3 or +3),
|
|
43
|
+
score_label: string //If score is over par - this will add the + symbol to it
|
|
44
|
+
leader_rounds:LeaderRoundProps[] //This holds the score by round
|
|
45
|
+
create_datetime:any,
|
|
46
|
+
last_update_datetime:any
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface GolfCourseProps {
|
|
50
|
+
tournament_id:string,
|
|
51
|
+
course_id:string,
|
|
52
|
+
course_name: string,
|
|
53
|
+
yardage:number,
|
|
54
|
+
par:number,
|
|
55
|
+
holes: GolfHoleProps[]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface GolfHoleProps {
|
|
59
|
+
course_id:string,
|
|
60
|
+
number:number,
|
|
61
|
+
par:number,
|
|
62
|
+
yardage:number,
|
|
63
|
+
name?:string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface LeaderRoundProps {
|
|
67
|
+
tournament_id:string,
|
|
68
|
+
athlete_id:string,
|
|
69
|
+
tee_time?:string,
|
|
70
|
+
score:number,
|
|
71
|
+
round_number: number,
|
|
72
|
+
thru:number //Holes they are thru on round
|
|
73
|
+
birdies: number,
|
|
74
|
+
eagles:number,
|
|
75
|
+
pars:number,
|
|
76
|
+
status:'closed'|'inprogress'
|
|
77
|
+
bogeys: number,
|
|
78
|
+
double_bogeys: number,
|
|
79
|
+
other_scores:number,
|
|
80
|
+
hole_in_ones:number
|
|
81
|
+
strokes: number
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface GolfScorecardProps {
|
|
85
|
+
tournament_id:string,
|
|
86
|
+
athlete_id:string,
|
|
87
|
+
round_number: number,
|
|
88
|
+
hole_number: number,
|
|
89
|
+
strokes: number
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface GolfTournamentStatisticsProps {
|
|
93
|
+
tournament_id:string,
|
|
94
|
+
round_statistics: GolfRoundStatistics[]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface GolfRoundStatistics {
|
|
98
|
+
tournament_id:string,
|
|
99
|
+
round_number: number,
|
|
100
|
+
hole_statistics: GolfHoleStatistics[]
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface GolfHoleStatistics {
|
|
104
|
+
round_number:number,
|
|
105
|
+
hole_number:number
|
|
106
|
+
par:number,
|
|
107
|
+
strokes: number,
|
|
108
|
+
players:number,
|
|
109
|
+
eagles:number,
|
|
110
|
+
birdies:number,
|
|
111
|
+
pars:number,
|
|
112
|
+
bogeys: number,
|
|
113
|
+
double_bogeys:number,
|
|
114
|
+
holes_in_one: number,
|
|
115
|
+
other_scores:number,
|
|
116
|
+
strokes_avg:number,
|
|
117
|
+
avg_diff:number
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
30
121
|
export interface FocusPositionProps {
|
|
31
122
|
x:number,
|
|
32
123
|
y:number,
|