be-components 6.6.2 → 6.6.4
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 -8
- 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 +365 -89
- package/lib/commonjs/Group/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/Contacts/useContacts.js +4 -1
- package/lib/commonjs/SocialComponents/Contacts/useContacts.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 -8
- 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 +365 -89
- package/lib/module/Group/index.js.map +1 -1
- package/lib/module/SocialComponents/Contacts/useContacts.js +4 -1
- package/lib/module/SocialComponents/Contacts/useContacts.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/commonjs/SocialComponents/Contacts/useContacts.d.ts +1 -0
- package/lib/typescript/lib/commonjs/SocialComponents/Contacts/useContacts.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/index.d.ts +1 -0
- 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/lib/module/SocialComponents/Contacts/useContacts.d.ts +1 -0
- package/lib/typescript/lib/module/SocialComponents/Contacts/useContacts.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/lib/typescript/src/SocialComponents/Contacts/useContacts.d.ts +1 -0
- package/lib/typescript/src/SocialComponents/Contacts/useContacts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Components/ConfirmAlert.tsx +39 -0
- package/src/Group/api/index.ts +81 -10
- package/src/Group/components/GroupCTAButton.tsx +12 -10
- package/src/Group/index.tsx +258 -75
- package/src/SocialComponents/Contacts/useContacts.tsx +4 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Alert, Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cross-platform alert with Cancel + Confirm buttons
|
|
5
|
+
*/
|
|
6
|
+
export function showConfirmAlert(
|
|
7
|
+
title: string,
|
|
8
|
+
message: string,
|
|
9
|
+
onConfirm: () => void,
|
|
10
|
+
onCancel?: () => void
|
|
11
|
+
) {
|
|
12
|
+
if (Platform.OS === "web") {
|
|
13
|
+
// Fallback for web: use window.confirm
|
|
14
|
+
const confirmed = window.confirm(`${title}\n\n${message}`);
|
|
15
|
+
if (confirmed) {
|
|
16
|
+
onConfirm();
|
|
17
|
+
} else {
|
|
18
|
+
onCancel?.();
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
// Native Alert
|
|
22
|
+
Alert.alert(
|
|
23
|
+
title,
|
|
24
|
+
message,
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
text: "Cancel",
|
|
28
|
+
style: "cancel",
|
|
29
|
+
onPress: onCancel,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
text: "Confirm",
|
|
33
|
+
onPress: onConfirm,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
{ cancelable: true }
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
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 });
|
|
@@ -110,6 +127,47 @@ const GroupApi = {
|
|
|
110
127
|
return { competition_players:[], competition_records:[], competition_results:[], competitions:[] }
|
|
111
128
|
}
|
|
112
129
|
},
|
|
130
|
+
getActivePolls: async(group_id:string):Promise<PollCampaignProps[]> => {
|
|
131
|
+
try {
|
|
132
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/group/active/${group_id}`);
|
|
133
|
+
return resp.data.poll_campaigns
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return []
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
getHistoryPolls: async(group_id:string, offset:number):Promise<PollCampaignProps[]> => {
|
|
139
|
+
try {
|
|
140
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/group/history/${group_id}?offset=${offset}`);
|
|
141
|
+
return resp.data.poll_campaigns
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return []
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
getActiveSquares: async(group_id:string):Promise<SquaresCompetitionProps[]> => {
|
|
147
|
+
try {
|
|
148
|
+
const resp = await axios.get(`${TP_SVC_API}/v1/squares/group/active/${group_id}`);
|
|
149
|
+
return resp.data.squares_competitions
|
|
150
|
+
} catch (e) {
|
|
151
|
+
return []
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
getHistorySquares: async(group_id:string, offset:number):Promise<SquaresCompetitionProps[]> => {
|
|
155
|
+
try {
|
|
156
|
+
const resp = await axios.get(`${TP_SVC_API}/v1/squares/group/history/${group_id}?offset=${offset}`);
|
|
157
|
+
return resp.data.squares_competitions
|
|
158
|
+
} catch (e) {
|
|
159
|
+
return []
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
getEventsByIds: async(event_ids:string[]):Promise<EventProps[]> => {
|
|
163
|
+
try {
|
|
164
|
+
if(event_ids.length == 0){ return [] }
|
|
165
|
+
const resp = await axios.post(`${EVENT_SVC_API}/v1/events/bulk/get`, { attribute:'event_id', values: event_ids });
|
|
166
|
+
return resp.data.events
|
|
167
|
+
} catch (e) {
|
|
168
|
+
return []
|
|
169
|
+
}
|
|
170
|
+
},
|
|
113
171
|
getPostsByGroupId: async(group_id:string, offset:number):Promise<PostProps[]> => {
|
|
114
172
|
try {
|
|
115
173
|
const resp = await axios.get(`${SOCIAL_SVC_API}/v1/posts/group/${group_id}?offset=${offset}`);
|
|
@@ -132,19 +190,32 @@ const GroupApi = {
|
|
|
132
190
|
|
|
133
191
|
|
|
134
192
|
const GroupHelpers = {
|
|
135
|
-
sortMembers: (group_players:GroupPlayerProps[], order_analytics:OrderAnalyticsProps[]) => {
|
|
193
|
+
sortMembers: (group_players:GroupPlayerProps[], order_analytics:OrderAnalyticsProps[], active_stat?:string) => {
|
|
136
194
|
let player_analytics: { [key:string]: NewOverallAnalytics } = {}
|
|
137
195
|
group_players.map(p => {
|
|
138
196
|
let my_analytics = order_analytics.filter(oa => oa.player_id == p.player_id);
|
|
139
197
|
player_analytics[p.player_id] = GroupHelpers.aggregateAnalytics(my_analytics);
|
|
140
198
|
});
|
|
141
199
|
|
|
142
|
-
let sorted_players = group_players.filter(gp => gp.status
|
|
143
|
-
let
|
|
144
|
-
let
|
|
145
|
-
|
|
200
|
+
let sorted_players = group_players.filter(gp => gp.status != 'inactive').sort((a,b) => {
|
|
201
|
+
let a_active = a.status == 'active' ? 1 : 0
|
|
202
|
+
let b_active = b.status == 'active' ? 1 : 0
|
|
203
|
+
let a_analytics = player_analytics[a.player_id]
|
|
204
|
+
let b_analytcs = player_analytics[b.player_id]
|
|
205
|
+
let a_analytic = a_analytics ? a_analytics[active_stat as keyof NewOverallAnalytics] ?? 0 : 0
|
|
206
|
+
let b_analytic = b_analytcs ? b_analytcs[active_stat as keyof NewOverallAnalytics] ?? 0 : 0
|
|
207
|
+
return b_active - a_active || parseFloat(b_analytic as string) - parseFloat(a_analytic as string)
|
|
146
208
|
});
|
|
147
209
|
return { sorted_players, player_analytics }
|
|
210
|
+
},
|
|
211
|
+
sortCompetitionAction: ( seasons:CompetitionSeasonProps[], competitions:CompetitionProps[], bracket_competitions:BracketCompetitionProps[], squares_competitions:SquaresCompetitionProps[], poll_campaigns:PollCampaignProps[] ):{ id:string, type:string, scheduled_datetime:Moment }[] => {
|
|
212
|
+
let data:{ id: string, type: string, scheduled_datetime:Moment }[] = []
|
|
213
|
+
seasons.map(s => data.push({ id: s.competition_season_id, type: 'season', scheduled_datetime: moment(s.scheduled_datetime) }));
|
|
214
|
+
competitions.map(c => data.push({ id:c.competition_id, type: 'competition', scheduled_datetime: moment(c.scheduled_datetime) }));
|
|
215
|
+
bracket_competitions.map(bc => data.push({ id: bc.bracket_competition_id, type: 'bracket', scheduled_datetime: moment(bc.scheduled_datetime) }));
|
|
216
|
+
squares_competitions.map(sc => data.push({ id: sc.sq_comp_id, type: 'squares', scheduled_datetime: moment(sc.begin_datetime) }));
|
|
217
|
+
poll_campaigns.map(pc => data.push({ id: pc.poll_campaign_id, type: 'poll_campaign', scheduled_datetime: moment(pc.create_datetime) }));
|
|
218
|
+
return data.sort((a,b) => a.scheduled_datetime.unix() - b.scheduled_datetime.unix())
|
|
148
219
|
},
|
|
149
220
|
aggregateAnalytics: (analytics:OrderAnalyticsProps[]):NewOverallAnalytics => {
|
|
150
221
|
const wins = analytics.reduce((a,b) => a + b.wins, 0);
|
|
@@ -155,7 +226,7 @@ const GroupHelpers = {
|
|
|
155
226
|
const original_stake = analytics.reduce((a,b) => a + b.original_stake, 0);
|
|
156
227
|
const cash_rcvd = analytics.reduce((a,b) => a + b.cash_rcvd, 0);
|
|
157
228
|
|
|
158
|
-
const win_pct = (wins + (draws / 2)) / fulfilled_positions
|
|
229
|
+
const win_pct = fulfilled_positions > 0 ? (wins + (draws / 2)) / fulfilled_positions : 0
|
|
159
230
|
const earnings = (winnings + cash_rcvd) - original_stake
|
|
160
231
|
const roi_pct = original_stake > 0 ? earnings / original_stake : 0
|
|
161
232
|
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
|
|