be-components 6.6.3 → 6.6.5
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/Components/ConfirmAlert.js +34 -0
- package/lib/commonjs/Components/ConfirmAlert.js.map +1 -0
- package/lib/commonjs/Group/api/index.js +108 -9
- package/lib/commonjs/Group/api/index.js.map +1 -1
- package/lib/commonjs/Group/components/GroupCTAButton.js +23 -21
- package/lib/commonjs/Group/components/GroupCTAButton.js.map +1 -1
- package/lib/commonjs/Group/index.js +372 -91
- package/lib/commonjs/Group/index.js.map +1 -1
- package/lib/module/Components/ConfirmAlert.js +29 -0
- package/lib/module/Components/ConfirmAlert.js.map +1 -0
- package/lib/module/Group/api/index.js +108 -9
- package/lib/module/Group/api/index.js.map +1 -1
- package/lib/module/Group/components/GroupCTAButton.js +23 -21
- package/lib/module/Group/components/GroupCTAButton.js.map +1 -1
- package/lib/module/Group/index.js +372 -91
- package/lib/module/Group/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Components/ConfirmAlert.d.ts +6 -0
- package/lib/typescript/lib/commonjs/Components/ConfirmAlert.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Group/api/index.d.ts +9 -1
- package/lib/typescript/lib/commonjs/Group/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Group/components/GroupCTAButton.d.ts +3 -1
- package/lib/typescript/lib/commonjs/Group/components/GroupCTAButton.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Group/index.d.ts +5 -1
- package/lib/typescript/lib/commonjs/Group/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/ConfirmAlert.d.ts +5 -0
- package/lib/typescript/lib/module/Components/ConfirmAlert.d.ts.map +1 -0
- package/lib/typescript/lib/module/Group/api/index.d.ts +9 -1
- package/lib/typescript/lib/module/Group/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Group/components/GroupCTAButton.d.ts +3 -1
- package/lib/typescript/lib/module/Group/components/GroupCTAButton.d.ts.map +1 -1
- package/lib/typescript/lib/module/Group/index.d.ts +5 -1
- package/lib/typescript/lib/module/Group/index.d.ts.map +1 -1
- package/lib/typescript/src/Components/ConfirmAlert.d.ts +5 -0
- package/lib/typescript/src/Components/ConfirmAlert.d.ts.map +1 -0
- package/lib/typescript/src/Group/api/index.d.ts +15 -2
- package/lib/typescript/src/Group/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Group/components/GroupCTAButton.d.ts +4 -1
- package/lib/typescript/src/Group/components/GroupCTAButton.d.ts.map +1 -1
- package/lib/typescript/src/Group/index.d.ts +6 -2
- package/lib/typescript/src/Group/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Components/ConfirmAlert.tsx +39 -0
- package/src/Group/api/index.ts +81 -11
- package/src/Group/components/GroupCTAButton.tsx +12 -10
- package/src/Group/index.tsx +263 -77
package/src/Group/api/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { APIOverrides } from "../../ApiOverrides"
|
|
3
|
-
import type { CompetitionPayoutTypeProps, CompetitionPlayerProps, CompetitionProps, CompetitionRecordProps, CompetitionResultProps, CompetitionResultTypeProps, CompetitionTypeProps, GroupMessageProps, GroupPlayerProps, GroupProps, NewOverallAnalytics, OrderAnalyticsProps, OrderProps, PostProps, PublicPlayerProps } from "../../types";
|
|
3
|
+
import type { BracketCompetitionProps, CompetitionPayoutTypeProps, CompetitionPlayerProps, CompetitionProps, CompetitionRecordProps, CompetitionResultProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps, EventProps, GroupMessageProps, GroupPlayerProps, GroupProps, NewOverallAnalytics, OrderAnalyticsProps, OrderProps, PollCampaignProps, PostProps, PublicPlayerProps, SquaresCompetitionProps } from "../../types";
|
|
4
|
+
import type { Moment } from "moment-mini";
|
|
5
|
+
import moment from "moment-mini";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
//let EVENT_SVC_API = ''
|
|
7
|
+
let EVENT_SVC_API = ''
|
|
7
8
|
let AUTH_SVC_API = ''
|
|
8
9
|
let MK_SVC_API = ''
|
|
9
10
|
let SOCIAL_SVC_API = ''
|
|
@@ -14,7 +15,7 @@ export { GroupApi, GroupHelpers }
|
|
|
14
15
|
const GroupApi = {
|
|
15
16
|
setEnvironment: () => {
|
|
16
17
|
const endpoints = APIOverrides.getEndpoints();
|
|
17
|
-
|
|
18
|
+
EVENT_SVC_API = endpoints['EVENT_SVC_API'] as string;
|
|
18
19
|
MK_SVC_API = endpoints['MK_SVC_API'] as string;
|
|
19
20
|
TP_SVC_API = endpoints['TP_SVC_API'] as string;
|
|
20
21
|
AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
|
|
@@ -37,6 +38,22 @@ const GroupApi = {
|
|
|
37
38
|
return undefined
|
|
38
39
|
}
|
|
39
40
|
},
|
|
41
|
+
uninvitePlayer: async(group_player_id:string):Promise<GroupPlayerProps|undefined> => {
|
|
42
|
+
try {
|
|
43
|
+
const resp = await axios.post(`${SOCIAL_SVC_API}/v2/groups/player/uninvite`, { group_player_id });
|
|
44
|
+
return resp.data.group_player
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return undefined
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
bootPlayer: async(group_player_id:string):Promise<GroupPlayerProps|undefined> => {
|
|
50
|
+
try {
|
|
51
|
+
const resp = await axios.post(`${SOCIAL_SVC_API}/v2/groups/player/boot`, { group_player_id });
|
|
52
|
+
return resp.data.group_player
|
|
53
|
+
} catch (e) {
|
|
54
|
+
return undefined
|
|
55
|
+
}
|
|
56
|
+
},
|
|
40
57
|
declineInvite:async(group_player_id:string):Promise<GroupPlayerProps | undefined> => {
|
|
41
58
|
try {
|
|
42
59
|
const resp = await axios.post(`${SOCIAL_SVC_API}/v2/groups/player/decline`, { group_player_id });
|
|
@@ -82,7 +99,6 @@ const GroupApi = {
|
|
|
82
99
|
getGroupAnalytics: async(group_id:string, to:number, from:number):Promise<OrderAnalyticsProps[]> => {
|
|
83
100
|
try {
|
|
84
101
|
const resp = await axios.get(`${MK_SVC_API}/v1/analytics/group/details/${group_id}?to=${to}&from=${from}`);
|
|
85
|
-
console.log(resp.data)
|
|
86
102
|
return resp.data.analytics
|
|
87
103
|
} catch (e) {
|
|
88
104
|
return []
|
|
@@ -110,6 +126,47 @@ const GroupApi = {
|
|
|
110
126
|
return { competition_players:[], competition_records:[], competition_results:[], competitions:[] }
|
|
111
127
|
}
|
|
112
128
|
},
|
|
129
|
+
getActivePolls: async(group_id:string):Promise<PollCampaignProps[]> => {
|
|
130
|
+
try {
|
|
131
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/group/active/${group_id}`);
|
|
132
|
+
return resp.data.poll_campaigns
|
|
133
|
+
} catch (e) {
|
|
134
|
+
return []
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
getHistoryPolls: async(group_id:string, offset:number):Promise<PollCampaignProps[]> => {
|
|
138
|
+
try {
|
|
139
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/group/history/${group_id}?offset=${offset}`);
|
|
140
|
+
return resp.data.poll_campaigns
|
|
141
|
+
} catch (e) {
|
|
142
|
+
return []
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
getActiveSquares: async(group_id:string):Promise<SquaresCompetitionProps[]> => {
|
|
146
|
+
try {
|
|
147
|
+
const resp = await axios.get(`${TP_SVC_API}/v1/squares/group/active/${group_id}`);
|
|
148
|
+
return resp.data.squares_competitions
|
|
149
|
+
} catch (e) {
|
|
150
|
+
return []
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
getHistorySquares: async(group_id:string, offset:number):Promise<SquaresCompetitionProps[]> => {
|
|
154
|
+
try {
|
|
155
|
+
const resp = await axios.get(`${TP_SVC_API}/v1/squares/group/history/${group_id}?offset=${offset}`);
|
|
156
|
+
return resp.data.squares_competitions
|
|
157
|
+
} catch (e) {
|
|
158
|
+
return []
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
getEventsByIds: async(event_ids:string[]):Promise<EventProps[]> => {
|
|
162
|
+
try {
|
|
163
|
+
if(event_ids.length == 0){ return [] }
|
|
164
|
+
const resp = await axios.post(`${EVENT_SVC_API}/v1/events/bulk/get`, { attribute:'event_id', values: event_ids });
|
|
165
|
+
return resp.data.events
|
|
166
|
+
} catch (e) {
|
|
167
|
+
return []
|
|
168
|
+
}
|
|
169
|
+
},
|
|
113
170
|
getPostsByGroupId: async(group_id:string, offset:number):Promise<PostProps[]> => {
|
|
114
171
|
try {
|
|
115
172
|
const resp = await axios.get(`${SOCIAL_SVC_API}/v1/posts/group/${group_id}?offset=${offset}`);
|
|
@@ -132,19 +189,32 @@ const GroupApi = {
|
|
|
132
189
|
|
|
133
190
|
|
|
134
191
|
const GroupHelpers = {
|
|
135
|
-
sortMembers: (group_players:GroupPlayerProps[], order_analytics:OrderAnalyticsProps[]) => {
|
|
192
|
+
sortMembers: (group_players:GroupPlayerProps[], order_analytics:OrderAnalyticsProps[], active_stat?:string) => {
|
|
136
193
|
let player_analytics: { [key:string]: NewOverallAnalytics } = {}
|
|
137
194
|
group_players.map(p => {
|
|
138
195
|
let my_analytics = order_analytics.filter(oa => oa.player_id == p.player_id);
|
|
139
196
|
player_analytics[p.player_id] = GroupHelpers.aggregateAnalytics(my_analytics);
|
|
140
197
|
});
|
|
141
198
|
|
|
142
|
-
let sorted_players = group_players.filter(gp => gp.status
|
|
143
|
-
let
|
|
144
|
-
let
|
|
145
|
-
|
|
199
|
+
let sorted_players = group_players.filter(gp => gp.status != 'inactive').sort((a,b) => {
|
|
200
|
+
let a_active = a.status == 'active' ? 1 : 0
|
|
201
|
+
let b_active = b.status == 'active' ? 1 : 0
|
|
202
|
+
let a_analytics = player_analytics[a.player_id]
|
|
203
|
+
let b_analytcs = player_analytics[b.player_id]
|
|
204
|
+
let a_analytic = a_analytics ? a_analytics[active_stat as keyof NewOverallAnalytics] ?? 0 : 0
|
|
205
|
+
let b_analytic = b_analytcs ? b_analytcs[active_stat as keyof NewOverallAnalytics] ?? 0 : 0
|
|
206
|
+
return b_active - a_active || parseFloat(b_analytic as string) - parseFloat(a_analytic as string)
|
|
146
207
|
});
|
|
147
208
|
return { sorted_players, player_analytics }
|
|
209
|
+
},
|
|
210
|
+
sortCompetitionAction: ( seasons:CompetitionSeasonProps[], competitions:CompetitionProps[], bracket_competitions:BracketCompetitionProps[], squares_competitions:SquaresCompetitionProps[], poll_campaigns:PollCampaignProps[] ):{ id:string, type:string, scheduled_datetime:Moment }[] => {
|
|
211
|
+
let data:{ id: string, type: string, scheduled_datetime:Moment }[] = []
|
|
212
|
+
seasons.map(s => data.push({ id: s.competition_season_id, type: 'season', scheduled_datetime: moment(s.scheduled_datetime) }));
|
|
213
|
+
competitions.map(c => data.push({ id:c.competition_id, type: 'competition', scheduled_datetime: moment(c.scheduled_datetime) }));
|
|
214
|
+
bracket_competitions.map(bc => data.push({ id: bc.bracket_competition_id, type: 'bracket', scheduled_datetime: moment(bc.scheduled_datetime) }));
|
|
215
|
+
squares_competitions.map(sc => data.push({ id: sc.sq_comp_id, type: 'squares', scheduled_datetime: moment(sc.begin_datetime) }));
|
|
216
|
+
poll_campaigns.map(pc => data.push({ id: pc.poll_campaign_id, type: 'poll_campaign', scheduled_datetime: moment(pc.create_datetime) }));
|
|
217
|
+
return data.sort((a,b) => a.scheduled_datetime.unix() - b.scheduled_datetime.unix())
|
|
148
218
|
},
|
|
149
219
|
aggregateAnalytics: (analytics:OrderAnalyticsProps[]):NewOverallAnalytics => {
|
|
150
220
|
const wins = analytics.reduce((a,b) => a + b.wins, 0);
|
|
@@ -155,7 +225,7 @@ const GroupHelpers = {
|
|
|
155
225
|
const original_stake = analytics.reduce((a,b) => a + b.original_stake, 0);
|
|
156
226
|
const cash_rcvd = analytics.reduce((a,b) => a + b.cash_rcvd, 0);
|
|
157
227
|
|
|
158
|
-
const win_pct = (wins + (draws / 2)) / fulfilled_positions
|
|
228
|
+
const win_pct = fulfilled_positions > 0 ? (wins + (draws / 2)) / fulfilled_positions : 0
|
|
159
229
|
const earnings = (winnings + cash_rcvd) - original_stake
|
|
160
230
|
const roi_pct = original_stake > 0 ? earnings / original_stake : 0
|
|
161
231
|
return {
|
|
@@ -5,10 +5,12 @@ import type { GroupMessageProps, GroupPlayerProps, GroupProps, PublicPlayerProps
|
|
|
5
5
|
import { useColors } from "../../constants/useColors"
|
|
6
6
|
import { Button, Text, View } from "../../Components/Themed"
|
|
7
7
|
import { Icons } from '../../Components';
|
|
8
|
-
import { Image } from 'react-native';
|
|
8
|
+
import { Image, type ViewStyle } from 'react-native';
|
|
9
9
|
|
|
10
10
|
type GroupCTAButtonProps = {
|
|
11
11
|
group:GroupProps,
|
|
12
|
+
style?:ViewStyle,
|
|
13
|
+
hide_from_player?:boolean,
|
|
12
14
|
message_length?:number,
|
|
13
15
|
group_messages:GroupMessageProps[],
|
|
14
16
|
players:PublicPlayerProps[],
|
|
@@ -16,7 +18,7 @@ type GroupCTAButtonProps = {
|
|
|
16
18
|
onSelectChat:(group:GroupProps) => void
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const GroupCTAButton = ({ group, players, message_length, group_messages, onSelectChat }:GroupCTAButtonProps) => {
|
|
21
|
+
const GroupCTAButton = ({ group, style, players, hide_from_player, message_length, group_messages, onSelectChat }:GroupCTAButtonProps) => {
|
|
20
22
|
const Colors = useColors();
|
|
21
23
|
|
|
22
24
|
useEffect(( ) => {
|
|
@@ -30,25 +32,25 @@ const GroupCTAButton = ({ group, players, message_length, group_messages, onSele
|
|
|
30
32
|
if(last_message?.message){ cta_message = `${last_message.message.slice(0, message_length ?? 15)}...` }
|
|
31
33
|
const last_player = players.find(p => p.player_id == last_message?.player_id)
|
|
32
34
|
return (
|
|
33
|
-
<View
|
|
34
|
-
<Button transparent style={{ flexDirection:'row', alignItems:'center'
|
|
35
|
+
<View float style={{ ...style }}>
|
|
36
|
+
<Button transparent style={{ padding:0, flexDirection:'row', alignItems:'center' }} onPress={() => onSelectChat(group)}>
|
|
37
|
+
<View transparent style={{ padding:10, flexDirection:'row', alignItems:'center' }}>
|
|
38
|
+
<Icons.ChatIcon size={16} color={Colors.text.h1}/>
|
|
39
|
+
</View>
|
|
35
40
|
{last_player ?
|
|
36
41
|
<Image
|
|
37
42
|
source={{ uri: last_player.profile_pic }}
|
|
38
|
-
style={{ height:
|
|
43
|
+
style={{ height:22, width:22, borderRadius:100 }}
|
|
39
44
|
resizeMode='contain'
|
|
40
45
|
/>
|
|
41
46
|
:<></>}
|
|
42
47
|
<View transparent style={{ flex:1, marginLeft:10, marginRight:10 }}>
|
|
43
48
|
<Text theme='h2'>{cta_message}</Text>
|
|
44
|
-
{last_player ?
|
|
49
|
+
{last_player && !hide_from_player ?
|
|
45
50
|
<Text theme='description' style={{ marginTop:3 }}>@{last_player.username}</Text>
|
|
46
51
|
:<></>}
|
|
47
52
|
</View>
|
|
48
|
-
|
|
49
|
-
<Icons.ChatIcon size={16} color={Colors.text.h1}/>
|
|
50
|
-
<Text theme='h2' size={12}> Chat</Text>
|
|
51
|
-
</View>
|
|
53
|
+
|
|
52
54
|
</Button>
|
|
53
55
|
</View>
|
|
54
56
|
|