be-components 5.0.8 → 5.1.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/Bracket/components/BracketPlay/index.js +9 -2
- package/lib/commonjs/Bracket/components/BracketPlay/index.js.map +1 -1
- package/lib/commonjs/Bracket/index.js +10 -0
- package/lib/commonjs/Bracket/index.js.map +1 -1
- package/lib/commonjs/Campaign/api/index.js +105 -0
- package/lib/commonjs/Campaign/api/index.js.map +1 -0
- package/lib/commonjs/Campaign/components/ActionList.js +96 -0
- package/lib/commonjs/Campaign/components/ActionList.js.map +1 -0
- package/lib/commonjs/Campaign/components/AnalyticsCard.js +42 -0
- package/lib/commonjs/Campaign/components/AnalyticsCard.js.map +1 -0
- package/lib/commonjs/Campaign/components/AutoManager.js +101 -0
- package/lib/commonjs/Campaign/components/AutoManager.js.map +1 -0
- package/lib/commonjs/Campaign/components/BetAlert.js +176 -0
- package/lib/commonjs/Campaign/components/BetAlert.js.map +1 -0
- package/lib/commonjs/Campaign/components/CampaignAnalytics.js +51 -0
- package/lib/commonjs/Campaign/components/CampaignAnalytics.js.map +1 -0
- package/lib/commonjs/Campaign/components/ParticipantCard.js +135 -0
- package/lib/commonjs/Campaign/components/ParticipantCard.js.map +1 -0
- package/lib/commonjs/Campaign/components/ParticipantsList.js +117 -0
- package/lib/commonjs/Campaign/components/ParticipantsList.js.map +1 -0
- package/lib/commonjs/Campaign/components/ProgressTimer.js +50 -0
- package/lib/commonjs/Campaign/components/ProgressTimer.js.map +1 -0
- package/lib/commonjs/Campaign/index.js +440 -0
- package/lib/commonjs/Campaign/index.js.map +1 -0
- package/lib/commonjs/Components/ConfirmationModal.js +32 -3
- package/lib/commonjs/Components/ConfirmationModal.js.map +1 -1
- package/lib/commonjs/Components/Icons.js +49 -0
- package/lib/commonjs/Components/Icons.js.map +1 -1
- package/lib/commonjs/Components/ProgressBar.js +94 -0
- package/lib/commonjs/Components/ProgressBar.js.map +1 -0
- package/lib/commonjs/Components/index.js +7 -0
- package/lib/commonjs/Components/index.js.map +1 -1
- package/lib/commonjs/MarketComponents/api/index.js +17 -0
- package/lib/commonjs/MarketComponents/api/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/api/index.js +3 -0
- package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
- package/lib/commonjs/Ticker/components/TradeText.js +82 -0
- package/lib/commonjs/Ticker/components/TradeText.js.map +1 -0
- package/lib/commonjs/Ticker/index.js +254 -0
- package/lib/commonjs/Ticker/index.js.map +1 -0
- package/lib/commonjs/constants/useColors.js +2 -2
- package/lib/commonjs/constants/useColors.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Bracket/components/BracketPlay/index.js +9 -2
- package/lib/module/Bracket/components/BracketPlay/index.js.map +1 -1
- package/lib/module/Bracket/index.js +10 -0
- package/lib/module/Bracket/index.js.map +1 -1
- package/lib/module/Campaign/api/index.js +99 -0
- package/lib/module/Campaign/api/index.js.map +1 -0
- package/lib/module/Campaign/components/ActionList.js +89 -0
- package/lib/module/Campaign/components/ActionList.js.map +1 -0
- package/lib/module/Campaign/components/AnalyticsCard.js +35 -0
- package/lib/module/Campaign/components/AnalyticsCard.js.map +1 -0
- package/lib/module/Campaign/components/AutoManager.js +92 -0
- package/lib/module/Campaign/components/AutoManager.js.map +1 -0
- package/lib/module/Campaign/components/BetAlert.js +169 -0
- package/lib/module/Campaign/components/BetAlert.js.map +1 -0
- package/lib/module/Campaign/components/CampaignAnalytics.js +42 -0
- package/lib/module/Campaign/components/CampaignAnalytics.js.map +1 -0
- package/lib/module/Campaign/components/ParticipantCard.js +128 -0
- package/lib/module/Campaign/components/ParticipantCard.js.map +1 -0
- package/lib/module/Campaign/components/ParticipantsList.js +108 -0
- package/lib/module/Campaign/components/ParticipantsList.js.map +1 -0
- package/lib/module/Campaign/components/ProgressTimer.js +43 -0
- package/lib/module/Campaign/components/ProgressTimer.js.map +1 -0
- package/lib/module/Campaign/index.js +431 -0
- package/lib/module/Campaign/index.js.map +1 -0
- package/lib/module/Components/ConfirmationModal.js +31 -4
- package/lib/module/Components/ConfirmationModal.js.map +1 -1
- package/lib/module/Components/Icons.js +49 -0
- package/lib/module/Components/Icons.js.map +1 -1
- package/lib/module/Components/ProgressBar.js +86 -0
- package/lib/module/Components/ProgressBar.js.map +1 -0
- package/lib/module/Components/index.js +2 -1
- package/lib/module/Components/index.js.map +1 -1
- package/lib/module/MarketComponents/api/index.js +17 -0
- package/lib/module/MarketComponents/api/index.js.map +1 -1
- package/lib/module/SocialComponents/api/index.js +2 -0
- package/lib/module/SocialComponents/api/index.js.map +1 -1
- package/lib/module/Ticker/components/TradeText.js +74 -0
- package/lib/module/Ticker/components/TradeText.js.map +1 -0
- package/lib/module/Ticker/index.js +245 -0
- package/lib/module/Ticker/index.js.map +1 -0
- package/lib/module/constants/useColors.js +2 -2
- package/lib/module/constants/useColors.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Bracket/index.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Bracket/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Campaign/api/index.d.ts +30 -0
- package/lib/typescript/lib/commonjs/Campaign/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ActionList.d.ts +8 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ActionList.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/AnalyticsCard.d.ts +9 -0
- package/lib/typescript/lib/commonjs/Campaign/components/AnalyticsCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/AutoManager.d.ts +10 -0
- package/lib/typescript/lib/commonjs/Campaign/components/AutoManager.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/BetAlert.d.ts +12 -0
- package/lib/typescript/lib/commonjs/Campaign/components/BetAlert.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/CampaignAnalytics.d.ts +6 -0
- package/lib/typescript/lib/commonjs/Campaign/components/CampaignAnalytics.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ParticipantCard.d.ts +10 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ParticipantCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ParticipantsList.d.ts +11 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ParticipantsList.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ProgressTimer.d.ts +8 -0
- package/lib/typescript/lib/commonjs/Campaign/components/ProgressTimer.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Campaign/index.d.ts +14 -0
- package/lib/typescript/lib/commonjs/Campaign/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Components/ConfirmationModal.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Components/ConfirmationModal.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
- package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/ProgressBar.d.ts +15 -0
- package/lib/typescript/lib/commonjs/Components/ProgressBar.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Components/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/MarketComponents/api/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/MarketComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Ticker/components/TradeText.d.ts +9 -0
- package/lib/typescript/lib/commonjs/Ticker/components/TradeText.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Ticker/index.d.ts +9 -0
- package/lib/typescript/lib/commonjs/Ticker/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/constants/useColors.d.ts +1 -1
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Bracket/index.d.ts +2 -1
- package/lib/typescript/lib/module/Bracket/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Campaign/api/index.d.ts +29 -0
- package/lib/typescript/lib/module/Campaign/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/ActionList.d.ts +8 -0
- package/lib/typescript/lib/module/Campaign/components/ActionList.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/AnalyticsCard.d.ts +9 -0
- package/lib/typescript/lib/module/Campaign/components/AnalyticsCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/AutoManager.d.ts +12 -0
- package/lib/typescript/lib/module/Campaign/components/AutoManager.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/BetAlert.d.ts +12 -0
- package/lib/typescript/lib/module/Campaign/components/BetAlert.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/CampaignAnalytics.d.ts +6 -0
- package/lib/typescript/lib/module/Campaign/components/CampaignAnalytics.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/ParticipantCard.d.ts +10 -0
- package/lib/typescript/lib/module/Campaign/components/ParticipantCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/ParticipantsList.d.ts +11 -0
- package/lib/typescript/lib/module/Campaign/components/ParticipantsList.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/components/ProgressTimer.d.ts +10 -0
- package/lib/typescript/lib/module/Campaign/components/ProgressTimer.d.ts.map +1 -0
- package/lib/typescript/lib/module/Campaign/index.d.ts +14 -0
- package/lib/typescript/lib/module/Campaign/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/Components/ConfirmationModal.d.ts +2 -1
- package/lib/typescript/lib/module/Components/ConfirmationModal.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
- package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/ProgressBar.d.ts +16 -0
- package/lib/typescript/lib/module/Components/ProgressBar.d.ts.map +1 -0
- package/lib/typescript/lib/module/Components/index.d.ts +2 -1
- package/lib/typescript/lib/module/Components/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/MarketComponents/api/index.d.ts +2 -0
- package/lib/typescript/lib/module/MarketComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Ticker/components/TradeText.d.ts +10 -0
- package/lib/typescript/lib/module/Ticker/components/TradeText.d.ts.map +1 -0
- package/lib/typescript/lib/module/Ticker/index.d.ts +9 -0
- package/lib/typescript/lib/module/Ticker/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/constants/useColors.d.ts +1 -1
- package/lib/typescript/lib/module/index.d.ts +3 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts.map +1 -1
- package/lib/typescript/src/Bracket/index.d.ts +3 -2
- package/lib/typescript/src/Bracket/index.d.ts.map +1 -1
- package/lib/typescript/src/Campaign/api/index.d.ts +24 -0
- package/lib/typescript/src/Campaign/api/index.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/ActionList.d.ts +10 -0
- package/lib/typescript/src/Campaign/components/ActionList.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/AnalyticsCard.d.ts +10 -0
- package/lib/typescript/src/Campaign/components/AnalyticsCard.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/AutoManager.d.ts +16 -0
- package/lib/typescript/src/Campaign/components/AutoManager.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/BetAlert.d.ts +14 -0
- package/lib/typescript/src/Campaign/components/BetAlert.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/CampaignAnalytics.d.ts +7 -0
- package/lib/typescript/src/Campaign/components/CampaignAnalytics.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/ParticipantCard.d.ts +12 -0
- package/lib/typescript/src/Campaign/components/ParticipantCard.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/ParticipantsList.d.ts +13 -0
- package/lib/typescript/src/Campaign/components/ParticipantsList.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/components/ProgressTimer.d.ts +10 -0
- package/lib/typescript/src/Campaign/components/ProgressTimer.d.ts.map +1 -0
- package/lib/typescript/src/Campaign/index.d.ts +24 -0
- package/lib/typescript/src/Campaign/index.d.ts.map +1 -0
- package/lib/typescript/src/Components/ConfirmationModal.d.ts +2 -1
- package/lib/typescript/src/Components/ConfirmationModal.d.ts.map +1 -1
- package/lib/typescript/src/Components/Icons.d.ts +1 -0
- package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/src/Components/ProgressBar.d.ts +19 -0
- package/lib/typescript/src/Components/ProgressBar.d.ts.map +1 -0
- package/lib/typescript/src/Components/index.d.ts +2 -1
- package/lib/typescript/src/Components/index.d.ts.map +1 -1
- package/lib/typescript/src/MarketComponents/api/index.d.ts +2 -0
- package/lib/typescript/src/MarketComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Ticker/components/TradeText.d.ts +11 -0
- package/lib/typescript/src/Ticker/components/TradeText.d.ts.map +1 -0
- package/lib/typescript/src/Ticker/index.d.ts +11 -0
- package/lib/typescript/src/Ticker/index.d.ts.map +1 -0
- package/lib/typescript/src/constants/useColors.d.ts +5 -1
- package/lib/typescript/src/constants/useColors.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 +2 -1
- package/src/Bracket/components/BracketPlay/index.tsx +10 -1
- package/src/Bracket/index.tsx +12 -3
- package/src/Campaign/api/index.ts +92 -0
- package/src/Campaign/components/ActionList.tsx +64 -0
- package/src/Campaign/components/AnalyticsCard.tsx +29 -0
- package/src/Campaign/components/AutoManager.tsx +88 -0
- package/src/Campaign/components/BetAlert.tsx +111 -0
- package/src/Campaign/components/CampaignAnalytics.tsx +54 -0
- package/src/Campaign/components/ParticipantCard.tsx +78 -0
- package/src/Campaign/components/ParticipantsList.tsx +69 -0
- package/src/Campaign/components/ProgressTimer.tsx +47 -0
- package/src/Campaign/index.tsx +377 -0
- package/src/Components/ConfirmationModal.tsx +22 -5
- package/src/Components/Icons.tsx +19 -0
- package/src/Components/ProgressBar.tsx +54 -0
- package/src/Components/index.tsx +2 -1
- package/src/MarketComponents/api/index.ts +17 -0
- package/src/SocialComponents/api/index.ts +2 -1
- package/src/Ticker/components/TradeText.tsx +55 -0
- package/src/Ticker/index.tsx +202 -0
- package/src/constants/useColors.tsx +5 -3
- package/src/index.tsx +5 -0
- package/src/types.d.ts +60 -0
|
@@ -317,12 +317,21 @@ const BracketPlay = ({ player, view_mode, width, bracket_id, onSelectContest, pl
|
|
|
317
317
|
<Text size={14} theme='h1'>No Bracket Selected</Text>
|
|
318
318
|
<Text style={{ marginTop:3 }} size={12} theme='description'>{0.00}% Complete</Text>
|
|
319
319
|
</View>
|
|
320
|
+
{!player ?
|
|
321
|
+
<Button
|
|
322
|
+
style={{ padding:10 }}
|
|
323
|
+
title='Sign In'
|
|
324
|
+
onPress={() => onRequestAuthenticate()}
|
|
325
|
+
type='success'
|
|
326
|
+
/>
|
|
327
|
+
:
|
|
320
328
|
<Button
|
|
321
329
|
style={{ padding:10 }}
|
|
322
330
|
title='Select Bracket'
|
|
323
331
|
onPress={() => onChangePlayerBracket(bracket.bracket_id)}
|
|
324
332
|
type='success'
|
|
325
333
|
/>
|
|
334
|
+
}
|
|
326
335
|
</View>
|
|
327
336
|
}
|
|
328
337
|
|
|
@@ -345,7 +354,7 @@ const BracketPlay = ({ player, view_mode, width, bracket_id, onSelectContest, pl
|
|
|
345
354
|
}
|
|
346
355
|
}}>
|
|
347
356
|
<View transparent>
|
|
348
|
-
{width > 1000 && !selected_round && !selected_group ?
|
|
357
|
+
{width > 1000 && bracket_rounds.length > 5 && !selected_round && !selected_group ?
|
|
349
358
|
<View onLayout={(ev) => {
|
|
350
359
|
const { height, width, x, y } = ev.nativeEvent.layout;
|
|
351
360
|
setBracketSize({ height, width, x, y })
|
package/src/Bracket/index.tsx
CHANGED
|
@@ -23,6 +23,7 @@ type BracketRoomProps = {
|
|
|
23
23
|
restrict_competition?:boolean,
|
|
24
24
|
player_balance?:PlayerBalanceProps,
|
|
25
25
|
bracket_competition_id?:string,
|
|
26
|
+
onCompleteBracket?:(player:MyPlayerProps, player_bracket:PlayerBracketProps, bracket_competition?:BracketCompetitionProps, cpb?:CompetitionPlayerBracketProps) => void,
|
|
26
27
|
onManageCompetition:(bracket_competition_id:string) => void,
|
|
27
28
|
onFocusPosition?:(data:{ x:number, y:number, height:number, width:number }) => void,
|
|
28
29
|
onShareCompetition:(bracket_competition:BracketCompetitionProps) => void,
|
|
@@ -35,7 +36,7 @@ type BracketRoomProps = {
|
|
|
35
36
|
const sections = ['header', 'home', 'bracket_selector', 'bracket']
|
|
36
37
|
const MAX_WIDTH = 2000
|
|
37
38
|
|
|
38
|
-
const BracketRoom = ({ player_id, hide_home, restrict_competition, width, height, view_mode, bracket_id, insets, onSelectContest, onCreateNewCompetition, onManageCompetition, bracket_competition_id, player_balance, onRequestAuthenticate, onFocusPosition, onShareCompetition }:BracketRoomProps) => {
|
|
39
|
+
const BracketRoom = ({ player_id, hide_home, restrict_competition, width, height, view_mode, bracket_id, insets, onCompleteBracket, onSelectContest, onCreateNewCompetition, onManageCompetition, bracket_competition_id, player_balance, onRequestAuthenticate, onFocusPosition, onShareCompetition }:BracketRoomProps) => {
|
|
39
40
|
const Colors = useColors();
|
|
40
41
|
const [ loading, setLoading ] = useState<string|undefined>(undefined);
|
|
41
42
|
const [ load_pb, setLoadPb ] = useState<PlayerBracketProps|undefined>(undefined);
|
|
@@ -267,7 +268,11 @@ const BracketRoom = ({ player_id, hide_home, restrict_competition, width, height
|
|
|
267
268
|
...play_data,
|
|
268
269
|
player_brackets:player_brackets.filter(pb => pb.player_bracket_id != newpb.player_bracket_id).concat(newpb),
|
|
269
270
|
competition_player_brackets: competition_player_brackets.filter(cpb => !ncpbs.find(ncpb => ncpb.competition_player_bracket_id == cpb.competition_player_bracket_id)).concat(ncpbs)
|
|
270
|
-
})
|
|
271
|
+
});
|
|
272
|
+
if(player && onCompleteBracket && newpb.completion_pct == 1){
|
|
273
|
+
let cpb = ncpbs.find(cpb => cpb.player_bracket_id == newpb.player_bracket_id && cpb.bracket_competition_id == active_competition?.bracket_competition_id);
|
|
274
|
+
onCompleteBracket(player, newpb, active_competition, cpb)
|
|
275
|
+
}
|
|
271
276
|
}}
|
|
272
277
|
bracket_id={active_bracket_id}
|
|
273
278
|
player_bracket_id={active_player_bracket_id}
|
|
@@ -439,8 +444,12 @@ const BracketRoom = ({ player_id, hide_home, restrict_competition, width, height
|
|
|
439
444
|
...play_data,
|
|
440
445
|
player_brackets: new_pb ? player_brackets.concat(new_pb) : player_brackets,
|
|
441
446
|
competition_player_brackets: competition_player_brackets.concat(new_cpb)
|
|
442
|
-
|
|
443
447
|
})
|
|
448
|
+
if(onCompleteBracket && player && active_player_bracket && active_player_bracket.completion_pct == 1){
|
|
449
|
+
setTimeout(() => {
|
|
450
|
+
onCompleteBracket(player, active_player_bracket, new_bc, new_cpb);
|
|
451
|
+
}, 400);
|
|
452
|
+
}
|
|
444
453
|
}}
|
|
445
454
|
competition_id={active_competition?.bracket_competition_id}
|
|
446
455
|
onLeaveCompetition={(bc, rem_cpb) => {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import type { CampaignParticipantProps, CampaignProps, OrderAnalyticsProps, OrderProps, OverallOrderAnalyticsProps, PublicPlayerProps } from '../../types';
|
|
4
|
+
import { APIOverrides } from '../../ApiOverrides';
|
|
5
|
+
import moment from 'moment-mini';
|
|
6
|
+
|
|
7
|
+
//let SOCIAL_SVC_API = '';
|
|
8
|
+
//let EVENT_SVC_API = '';
|
|
9
|
+
let MK_SVC_API = '';
|
|
10
|
+
let AUTH_SVC_API = '';
|
|
11
|
+
|
|
12
|
+
export const CampaignApi = {
|
|
13
|
+
setEnvironment: () => {
|
|
14
|
+
const endpoints = APIOverrides.getEndpoints();
|
|
15
|
+
//SOCIAL_SVC_API = endpoints['SOCIAL_SVC_API'] as string;
|
|
16
|
+
//EVENT_SVC_API = endpoints['EVENT_SVC_API'] as string;
|
|
17
|
+
MK_SVC_API = endpoints['MK_SVC_API'] as string;
|
|
18
|
+
AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
|
|
19
|
+
|
|
20
|
+
},
|
|
21
|
+
getPlayersByPlayerIds : async(player_ids:string[]):Promise<PublicPlayerProps[]> => {
|
|
22
|
+
try {
|
|
23
|
+
if(player_ids.length == 0){ return [] }
|
|
24
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/players/bulk/get`, { player_ids })
|
|
25
|
+
return resp.data.players
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return []
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
getCampaignById: async(campaign_id:string):Promise<{campaign?:CampaignProps, campaign_participants:CampaignParticipantProps[]}> => {
|
|
31
|
+
try {
|
|
32
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/campaigns/campaign/${campaign_id}`);
|
|
33
|
+
return resp.data
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return { campaign: undefined, campaign_participants:[] }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
getCampaignAction: async(campaign_id:string):Promise<OrderProps[]> => {
|
|
39
|
+
try {
|
|
40
|
+
const resp = await axios.get(`${MK_SVC_API}/v1/orders/campaign/action/${campaign_id}`);
|
|
41
|
+
return resp.data.orders
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
getCampaignAnalytics: async(campaign_id:string, to:number, from:number):Promise<OrderAnalyticsProps[]> => {
|
|
47
|
+
try {
|
|
48
|
+
const resp = await axios.get(`${MK_SVC_API}/v1/analytics/campaign/details/${campaign_id}?to=${to}&from=${from}`);
|
|
49
|
+
return resp.data.analytics
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.log(e);
|
|
52
|
+
return []
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const CampaignHelpers = {
|
|
58
|
+
aggregateAnalytics: (analytics:OrderAnalyticsProps[]):OverallOrderAnalyticsProps&{roi_pct:number, win_pct:number, earnings:number} => {
|
|
59
|
+
const wins = analytics.reduce((a,b) => a + b.wins, 0);
|
|
60
|
+
const losses = analytics.reduce((a,b) => a + b.losses, 0);
|
|
61
|
+
const draws = analytics.reduce((a,b) => a + b.draws, 0);
|
|
62
|
+
const fulfilled_positions = analytics.reduce((a,b) => a + parseFloat(b.fulfilled_positions as any), 0);
|
|
63
|
+
const winnings = analytics.reduce((a,b) => a + b.winnings, 0);
|
|
64
|
+
const original_stake = analytics.reduce((a,b) => a + b.original_stake, 0);
|
|
65
|
+
const cash_rcvd = analytics.reduce((a,b) => a + b.cash_rcvd, 0);
|
|
66
|
+
|
|
67
|
+
const win_pct = (wins + (draws / 2)) / fulfilled_positions
|
|
68
|
+
const earnings = (winnings + cash_rcvd) - original_stake
|
|
69
|
+
const roi_pct = earnings / original_stake
|
|
70
|
+
return {
|
|
71
|
+
winnings,
|
|
72
|
+
original_stake,
|
|
73
|
+
wins,
|
|
74
|
+
losses,
|
|
75
|
+
draws,
|
|
76
|
+
net_winnings: 0,
|
|
77
|
+
player_id: '',
|
|
78
|
+
fulfilled_positions,
|
|
79
|
+
cash_rcvd,
|
|
80
|
+
earnings,
|
|
81
|
+
win_pct,
|
|
82
|
+
roi_pct
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
getTimeOptions: () => {
|
|
86
|
+
const time_options = [
|
|
87
|
+
{ label: 'All Time', to: moment().unix(), from: moment().subtract(7, 'years').unix() },
|
|
88
|
+
{ label: 'Last 7 Days', to: moment().unix(), from: moment().subtract(7, 'days').unix() }
|
|
89
|
+
]
|
|
90
|
+
return time_options
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, View } from "../../Components/Themed"
|
|
3
|
+
import type { EventProps, OrderProps, PublicPlayerProps } from "../../types"
|
|
4
|
+
import { FlatList, Image } from 'react-native';
|
|
5
|
+
import moment from 'moment-mini';
|
|
6
|
+
import OrderGradeBar from '../../MarketComponents/components/OrderGradeBar';
|
|
7
|
+
|
|
8
|
+
type ActionListProps = {
|
|
9
|
+
orders:OrderProps[],
|
|
10
|
+
events:EventProps[],
|
|
11
|
+
players:PublicPlayerProps[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ActionList = ({ orders, events, players }:ActionListProps) => {
|
|
15
|
+
|
|
16
|
+
const renderAction = (data:{ item:OrderProps, index:number }) => {
|
|
17
|
+
const event = events.find(e => e.event_id == data.item.event_id);
|
|
18
|
+
if(!event){ return <></> }
|
|
19
|
+
const player = players.find(p => p.player_id == data.item.player_id)
|
|
20
|
+
return (
|
|
21
|
+
<View float style={{ margin:10 }}>
|
|
22
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:8, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
23
|
+
<Text style={{ flex:1 }} theme='h2'>{event.event_title}</Text>
|
|
24
|
+
<Text theme='action'>{moment(data.item.create_datetime).fromNow()}</Text>
|
|
25
|
+
</View>
|
|
26
|
+
<View transparent style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
27
|
+
{player ?
|
|
28
|
+
<Image
|
|
29
|
+
source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
|
|
30
|
+
style={{ height:35, width:35, borderRadius:100 }}
|
|
31
|
+
resizeMode='cover'
|
|
32
|
+
/>
|
|
33
|
+
:<></>}
|
|
34
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
35
|
+
<Text theme='h1'>{data.item.title}</Text>
|
|
36
|
+
<Text theme='description'>@{player?.username}</Text>
|
|
37
|
+
</View>
|
|
38
|
+
{data.item.status == 'approved' && data.item.grade ?
|
|
39
|
+
<View transparent style={{ padding:5, marginRight:10 }}>
|
|
40
|
+
<OrderGradeBar
|
|
41
|
+
grade={data.item.grade}
|
|
42
|
+
view_type='book'
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
45
|
+
:<></>}
|
|
46
|
+
</View>
|
|
47
|
+
</View>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View transparent style={{ flex:1 }}>
|
|
54
|
+
<FlatList
|
|
55
|
+
data={orders}
|
|
56
|
+
renderItem={renderAction}
|
|
57
|
+
keyExtractor={(item) => item.order_id.toString()}
|
|
58
|
+
key={'campaign_action'}
|
|
59
|
+
/>
|
|
60
|
+
</View>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default ActionList
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, View } from "../../Components/Themed"
|
|
3
|
+
import { useColors } from '../../constants/useColors';
|
|
4
|
+
|
|
5
|
+
type AnalyticsCardProps = {
|
|
6
|
+
label:string,
|
|
7
|
+
value:number,
|
|
8
|
+
value_label:string,
|
|
9
|
+
success_limit:number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AnalyticsCard = ({ label, value, success_limit, value_label }:AnalyticsCardProps) => {
|
|
13
|
+
const Colors = useColors();
|
|
14
|
+
const color = value >= success_limit ? Colors.text.success : Colors.text.error
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<View float>
|
|
19
|
+
<View type='header' style={{ padding:8, borderTopRightRadius:8, borderTopLeftRadius:8}}>
|
|
20
|
+
<Text theme='h2'>{label}</Text>
|
|
21
|
+
</View>
|
|
22
|
+
<View transparent style={{ flex:1, padding:15 }}>
|
|
23
|
+
<Text theme='h1' color={color}>{value_label}</Text>
|
|
24
|
+
</View>
|
|
25
|
+
</View>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default AnalyticsCard
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View } from "../../Components/Themed"
|
|
3
|
+
import ProgressTimer from "./ProgressTimer"
|
|
4
|
+
import type { CampaignParticipantProps, CampaignProps, OrderAnalyticsProps, OrderProps } from '../../types';
|
|
5
|
+
|
|
6
|
+
type AutoManagerProps = {
|
|
7
|
+
active?:boolean,
|
|
8
|
+
campaign:CampaignProps,
|
|
9
|
+
campaign_participants:CampaignParticipantProps[],
|
|
10
|
+
analytics:OrderAnalyticsProps[],
|
|
11
|
+
orders:OrderProps[]
|
|
12
|
+
onChangeParticipant:(cp:CampaignParticipantProps) => void,
|
|
13
|
+
onChangeAd: (ad:{url:string}) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const AutoManager = ({ campaign, active, campaign_participants, onChangeParticipant, onChangeAd }:AutoManagerProps) => {
|
|
17
|
+
const active_participants = campaign_participants.filter(cp => cp.status == 'active');
|
|
18
|
+
const [ current_type, setCurrentType ] = useState('participant');
|
|
19
|
+
const [ started, setStarted ] = useState(false);
|
|
20
|
+
const [ timer_id, setTimerId ] = useState(Math.random().toString());
|
|
21
|
+
const [ active_ad, setActiveAd ] = useState<number>(0);
|
|
22
|
+
const [ active_participant, setActiveParticipant ] = useState<number>(0);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if(!active || started){ return }
|
|
26
|
+
setStarted(true);
|
|
27
|
+
if(active_participants.length == 0){
|
|
28
|
+
setCurrentType('participant');
|
|
29
|
+
if(!campaign.ads || campaign.ads.length == 0){ return }
|
|
30
|
+
handleTimesUpAd(0)
|
|
31
|
+
} else {
|
|
32
|
+
setCurrentType('ad');
|
|
33
|
+
if(active_participants.length == 0){ return }
|
|
34
|
+
handleTimesUpParticipant(0);
|
|
35
|
+
}
|
|
36
|
+
},[active, active_participants.length, campaign.ads])
|
|
37
|
+
|
|
38
|
+
const handleTimesUpAd = (index:number) => {
|
|
39
|
+
if(!campaign.ads){ return }
|
|
40
|
+
if(campaign.ads.length == 0){ return }
|
|
41
|
+
let active_index = index
|
|
42
|
+
let next_ad = campaign.ads[active_index]
|
|
43
|
+
if(!next_ad){
|
|
44
|
+
active_index = 0
|
|
45
|
+
next_ad = campaign.ads[active_index]
|
|
46
|
+
}
|
|
47
|
+
if(!next_ad){ return }
|
|
48
|
+
setCurrentType('participant')
|
|
49
|
+
onChangeAd(next_ad)
|
|
50
|
+
setActiveAd(active_index);
|
|
51
|
+
|
|
52
|
+
setTimerId(Math.random().toString())
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const handleTimesUpParticipant = (index:number) => {
|
|
56
|
+
let active_index = index
|
|
57
|
+
let next_cp = active_participants[active_index]
|
|
58
|
+
if(!next_cp){
|
|
59
|
+
active_index = 0
|
|
60
|
+
next_cp = active_participants[active_index]
|
|
61
|
+
}
|
|
62
|
+
if(!next_cp){ return }
|
|
63
|
+
onChangeParticipant(next_cp)
|
|
64
|
+
setActiveParticipant(active_index);
|
|
65
|
+
setCurrentType('ad');
|
|
66
|
+
setTimerId(Math.random().toString())
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const handleTimesUp = () => {
|
|
70
|
+
if(current_type == 'ad'){ handleTimesUpAd(active_ad + 1) }
|
|
71
|
+
if(current_type == 'participant'){ handleTimesUpParticipant(active_participant + 1) }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if(!active || !started){ return <></> }
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<View transparent>
|
|
78
|
+
<ProgressTimer
|
|
79
|
+
total_time={10}
|
|
80
|
+
time_id={timer_id}
|
|
81
|
+
onTimesUp={() => handleTimesUp()}
|
|
82
|
+
/>
|
|
83
|
+
</View>
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default AutoManager
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Image } from "react-native";
|
|
2
|
+
import { Icons } from "../../Components";
|
|
3
|
+
import { Text, View } from "../../Components/Themed";
|
|
4
|
+
import type { AthleteProps, EventProps, OrderProps, PublicPlayerProps, TeamProps } from "../../types"
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import OrderGradeBar from "../../MarketComponents/components/OrderGradeBar";
|
|
7
|
+
import { MarketComponentHelpers } from "../../MarketComponents/api";
|
|
8
|
+
import QRCode from "react-qr-code";
|
|
9
|
+
import { useColors } from "../../constants/useColors";
|
|
10
|
+
import moment from "moment-mini";
|
|
11
|
+
import ProgressTimer from "./ProgressTimer";
|
|
12
|
+
|
|
13
|
+
type BetAlertProps = {
|
|
14
|
+
order:OrderProps,
|
|
15
|
+
team?:TeamProps,
|
|
16
|
+
athlete?:AthleteProps,
|
|
17
|
+
event?:EventProps,
|
|
18
|
+
player?:PublicPlayerProps,
|
|
19
|
+
color_mode?:'light'|'dark'
|
|
20
|
+
|
|
21
|
+
onClose:() => void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const BetAlert = ({ player, order, team, athlete, event, color_mode, onClose }:BetAlertProps) => {
|
|
25
|
+
const Colors = useColors({ mode: color_mode });
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View float style={{ width:350 }}>
|
|
29
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:18, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
30
|
+
<Icons.BettorEdgeIcon size={18} color={Colors.text.h1} />
|
|
31
|
+
<View transparent style={{ flex:1, marginLeft:20, marginRight:10 }}>
|
|
32
|
+
<Text theme='h1'>NEW BET ALERT!</Text>
|
|
33
|
+
<Text theme='description' style={{ marginTop:5 }}>@{player?.username} {`\u2022`} {moment(order.create_datetime).fromNow()}</Text>
|
|
34
|
+
</View>
|
|
35
|
+
|
|
36
|
+
</View>
|
|
37
|
+
<View>
|
|
38
|
+
{event ?
|
|
39
|
+
<View style={{ flexDirection:'row', alignItems:'center', justifyContent:'center', padding:10 }}>
|
|
40
|
+
<Image
|
|
41
|
+
source={{ uri: event?.away?.image?.url }}
|
|
42
|
+
style={{ height:40, width:40, marginRight:10 }}
|
|
43
|
+
resizeMode='cover'
|
|
44
|
+
/>
|
|
45
|
+
<Text theme='h2'>{event.away?.market_name}</Text>
|
|
46
|
+
<Text theme='h1' style={{ marginRight:20, marginLeft:20 }}>VS</Text>
|
|
47
|
+
<Image
|
|
48
|
+
source={{ uri: event?.home?.image?.url }}
|
|
49
|
+
style={{ height:40, width:40, marginRight:10 }}
|
|
50
|
+
resizeMode='cover'
|
|
51
|
+
/>
|
|
52
|
+
<Text theme='h2'>{event.home?.market_name}</Text>
|
|
53
|
+
</View>
|
|
54
|
+
:<></>}
|
|
55
|
+
{player ?
|
|
56
|
+
<View>
|
|
57
|
+
<Image
|
|
58
|
+
source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
|
|
59
|
+
style={{ height:200, width:350 }}
|
|
60
|
+
resizeMode='cover'
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
64
|
+
{team ?
|
|
65
|
+
<Image
|
|
66
|
+
source={{ uri: team.image?.url }}
|
|
67
|
+
style={{ height:60, width:60 }}
|
|
68
|
+
resizeMode='cover'
|
|
69
|
+
/>
|
|
70
|
+
:athlete ?
|
|
71
|
+
<Image
|
|
72
|
+
source={{ uri: athlete.image?.url }}
|
|
73
|
+
style={{ height:60, width:60 }}
|
|
74
|
+
resizeMode='cover'
|
|
75
|
+
/>
|
|
76
|
+
:<></>}
|
|
77
|
+
|
|
78
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
79
|
+
<Text theme='h1'>{order.title}</Text>
|
|
80
|
+
<Text style={{ marginTop:3 }} theme='description'>{MarketComponentHelpers.getOddsLabel(order.odds)} {`\u2022`} {(order.probability * 100).toFixed(2)}%</Text>
|
|
81
|
+
</View>
|
|
82
|
+
{order.grade ?
|
|
83
|
+
<OrderGradeBar
|
|
84
|
+
grade={order.grade}
|
|
85
|
+
view_type='card'
|
|
86
|
+
/>
|
|
87
|
+
:<></>}
|
|
88
|
+
</View>
|
|
89
|
+
</View>
|
|
90
|
+
:<></>}
|
|
91
|
+
|
|
92
|
+
</View>
|
|
93
|
+
<View type='header' style={{alignItems:'center', padding:10}}>
|
|
94
|
+
<QRCode
|
|
95
|
+
size={100}
|
|
96
|
+
value={`https://play.bettoredge.com/markets?order=${order.order_id}&type=fade`}
|
|
97
|
+
/>
|
|
98
|
+
<Text textAlign='center' theme='h2' style={{ marginTop:4 }}>FADE ME NOW!</Text>
|
|
99
|
+
</View>
|
|
100
|
+
<View type='footer' style={{ borderBottomRightRadius:8, borderBottomLeftRadius:8, }}>
|
|
101
|
+
<ProgressTimer
|
|
102
|
+
onTimesUp={() => onClose()}
|
|
103
|
+
time_id={order.order_id.toString()}
|
|
104
|
+
total_time={15}
|
|
105
|
+
/>
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default BetAlert
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View } from "../../Components/Themed"
|
|
3
|
+
import moment from 'moment-mini';
|
|
4
|
+
import { CampaignApi, CampaignHelpers } from '../api';
|
|
5
|
+
import type { OrderAnalyticsProps } from '../../types';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type CampaignAnalyticsProps = {
|
|
9
|
+
campaign_id:string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const CampaignAnalytics = ({ campaign_id }:CampaignAnalyticsProps) => {
|
|
13
|
+
|
|
14
|
+
const time_options = [
|
|
15
|
+
{ label: 'Last 7 Days', to: moment().unix(), from: moment().subtract(7, 'days').unix() }
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const [ module_state, setModuleState ] = useState<{
|
|
19
|
+
loading:boolean,
|
|
20
|
+
time_option: any,
|
|
21
|
+
analytics:OrderAnalyticsProps[]
|
|
22
|
+
}>({
|
|
23
|
+
loading:false,
|
|
24
|
+
time_option: time_options[0],
|
|
25
|
+
analytics: []
|
|
26
|
+
});
|
|
27
|
+
const { analytics } = module_state;
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
let option = time_options[0]
|
|
31
|
+
if(!option){ return }
|
|
32
|
+
handleLoadAnalytics(option);
|
|
33
|
+
},[])
|
|
34
|
+
|
|
35
|
+
const handleLoadAnalytics = async(option:{ label:string, to:number, from:number }) => {
|
|
36
|
+
CampaignApi.setEnvironment();
|
|
37
|
+
const analytics = await CampaignApi.getCampaignAnalytics(campaign_id, option.to, option.from);
|
|
38
|
+
setModuleState({
|
|
39
|
+
...module_state,
|
|
40
|
+
time_option: option,
|
|
41
|
+
analytics
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const agg = CampaignHelpers.aggregateAnalytics(analytics)
|
|
46
|
+
console.log(agg)
|
|
47
|
+
return (
|
|
48
|
+
<View>
|
|
49
|
+
|
|
50
|
+
</View>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default CampaignAnalytics
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, View } from "../../Components/Themed"
|
|
3
|
+
import type { CampaignParticipantProps, EventProps, OrderAnalyticsProps, OrderProps, PublicPlayerProps } from "../../types"
|
|
4
|
+
import { Image } from 'react-native';
|
|
5
|
+
import moment from 'moment-mini';
|
|
6
|
+
import ActionList from './ActionList';
|
|
7
|
+
import { CampaignHelpers } from '../api';
|
|
8
|
+
import AnalyticsCard from './AnalyticsCard';
|
|
9
|
+
|
|
10
|
+
type ParticipantCardProps = {
|
|
11
|
+
campaign_participant:CampaignParticipantProps,
|
|
12
|
+
player:PublicPlayerProps,
|
|
13
|
+
orders:OrderProps[],
|
|
14
|
+
analytics:OrderAnalyticsProps[],
|
|
15
|
+
events:EventProps[]
|
|
16
|
+
}
|
|
17
|
+
const ParticipantCard = ({ player, campaign_participant, orders, events, analytics }:ParticipantCardProps) => {
|
|
18
|
+
const agg = CampaignHelpers.aggregateAnalytics(analytics);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<View transparent style={{ marginTop:65, flex:1 }}>
|
|
22
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
23
|
+
<View float style={{ padding:2, borderRadius:100, marginTop:-65, marginLeft:10 }}>
|
|
24
|
+
<Image
|
|
25
|
+
source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
|
|
26
|
+
style={{ height:100, width:100, borderRadius:100}}
|
|
27
|
+
/>
|
|
28
|
+
</View>
|
|
29
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
30
|
+
<Text theme='h1'>@{player.username}</Text>
|
|
31
|
+
<Text theme='description' style={{ marginTop:3 }}>{player.bio ?? `Last visited ${moment(campaign_participant.last_update_datetime).fromNow()}`}</Text>
|
|
32
|
+
</View>
|
|
33
|
+
</View>
|
|
34
|
+
<View type='header' style={{ flexDirection:'row', padding:6 }}>
|
|
35
|
+
<View transparent style={{ margin:4, flex:1 }}>
|
|
36
|
+
<AnalyticsCard
|
|
37
|
+
label='Bets Fulfilled'
|
|
38
|
+
value={agg.fulfilled_positions}
|
|
39
|
+
success_limit={0}
|
|
40
|
+
value_label={agg.fulfilled_positions.toString()}
|
|
41
|
+
/>
|
|
42
|
+
</View>
|
|
43
|
+
<View transparent style={{ margin:4, flex:1 }}>
|
|
44
|
+
<AnalyticsCard
|
|
45
|
+
label='ROI %'
|
|
46
|
+
value={agg.roi_pct}
|
|
47
|
+
success_limit={0}
|
|
48
|
+
value_label={`${(agg.roi_pct * 100).toFixed(2)}%`}
|
|
49
|
+
/>
|
|
50
|
+
</View>
|
|
51
|
+
<View transparent style={{ margin:4, flex:1 }}>
|
|
52
|
+
<AnalyticsCard
|
|
53
|
+
label={`Win %`}
|
|
54
|
+
value={agg.win_pct}
|
|
55
|
+
success_limit={0.5}
|
|
56
|
+
value_label={`${(agg.win_pct * 100).toFixed(2)}%`}
|
|
57
|
+
/>
|
|
58
|
+
</View>
|
|
59
|
+
|
|
60
|
+
</View>
|
|
61
|
+
<View transparent style={{ flex:1 }}>
|
|
62
|
+
<View type='header' style={{ flexDirection:'row', padding:10 }}>
|
|
63
|
+
<View transparent style={{ flex:1 }}>
|
|
64
|
+
<Text theme='h1'>Recent Action</Text>
|
|
65
|
+
<Text theme='description' style={{ marginTop:4 }}>Bets recently placed by @{player.username}</Text>
|
|
66
|
+
</View>
|
|
67
|
+
</View>
|
|
68
|
+
<ActionList
|
|
69
|
+
orders={orders}
|
|
70
|
+
players={[player]}
|
|
71
|
+
events={events}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
</View>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default ParticipantCard
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, Text, View } from "../../Components/Themed"
|
|
3
|
+
import type { CampaignParticipantProps, PublicPlayerProps } from "../../types"
|
|
4
|
+
import { FlatList, Image } from 'react-native';
|
|
5
|
+
import { useColors } from '../../constants/useColors';
|
|
6
|
+
import moment from 'moment-mini';
|
|
7
|
+
|
|
8
|
+
type CampaignParticipantListProps = {
|
|
9
|
+
campaign_participants:CampaignParticipantProps[],
|
|
10
|
+
players:PublicPlayerProps[],
|
|
11
|
+
selected_participant?:string,
|
|
12
|
+
horizontal?:boolean,
|
|
13
|
+
onSelect:(cp:CampaignParticipantProps) => void,
|
|
14
|
+
onDeselect: (cp:CampaignParticipantProps) => void
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ParticipantsList = ({ campaign_participants, players, selected_participant, horizontal, onSelect, onDeselect }:CampaignParticipantListProps) => {
|
|
19
|
+
const [ participant_page ] = useState(1);
|
|
20
|
+
const Colors = useColors();
|
|
21
|
+
const visible_participants = campaign_participants.sort((a,b) => a.status.localeCompare(b.status) || moment(b.create_datetime).unix() - moment(a.create_datetime).unix()).slice((participant_page-1) * 5, ((participant_page-1) * 5) + 5)
|
|
22
|
+
|
|
23
|
+
const renderParticipants = (data:{ item:CampaignParticipantProps, index:number }) => {
|
|
24
|
+
const player = players.find(p => p.player_id == data.item.player_id);
|
|
25
|
+
const active = data.item.status == 'active' ? true : false
|
|
26
|
+
if(!player){ return <></> }
|
|
27
|
+
const selected = data.item.campaign_participant_id == selected_participant ? true : false
|
|
28
|
+
return (
|
|
29
|
+
<Button float
|
|
30
|
+
style={{ flexDirection:horizontal?'column':'row', alignItems:'center', borderRadius:100, margin:8, padding:2, borderWidth:selected || active?2:0, borderColor:selected?Colors.text.action:active?Colors.text.success:'transparent' }}
|
|
31
|
+
onPress={() => selected ? onDeselect(data.item) : onSelect(data.item)}>
|
|
32
|
+
<Image
|
|
33
|
+
source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
|
|
34
|
+
style={{ height:50, width:50, borderRadius:100 }}
|
|
35
|
+
/>
|
|
36
|
+
{!horizontal ?
|
|
37
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
38
|
+
<Text theme='h2'>@{player.username}</Text>
|
|
39
|
+
<Text style={{ marginTop:3 }} theme='description'>Visited {moment(data.item.last_update_datetime).fromNow()}</Text>
|
|
40
|
+
</View>
|
|
41
|
+
:<></>}
|
|
42
|
+
</Button>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View type='header' style={{ flex:1 }}>
|
|
48
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
49
|
+
<View transparent style={{ flex:1, marginRight:10 }}>
|
|
50
|
+
<Text theme='h1'>Participants</Text>
|
|
51
|
+
<Text theme='description' style={{ marginTop:4 }}>Check out who is participating here!</Text>
|
|
52
|
+
</View>
|
|
53
|
+
<View transparent style={{ justifyContent:'center', alignItems:'center' }}>
|
|
54
|
+
<Text theme='h1' color={Colors.text.action}>{campaign_participants.length}</Text>
|
|
55
|
+
<Text theme='description' style={{ marginTop:3 }}>Participants</Text>
|
|
56
|
+
</View>
|
|
57
|
+
</View>
|
|
58
|
+
<FlatList
|
|
59
|
+
data={visible_participants}
|
|
60
|
+
renderItem={renderParticipants}
|
|
61
|
+
horizontal={horizontal}
|
|
62
|
+
key={'campaign_particpant_list'}
|
|
63
|
+
keyExtractor={(item) => item.campaign_participant_id.toString()}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default ParticipantsList
|