be-components 7.4.0 → 7.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/ApiOverrides/index.js +4 -0
- package/lib/commonjs/ApiOverrides/index.js.map +1 -1
- package/lib/commonjs/BettorBot/api/index.js +64 -0
- package/lib/commonjs/BettorBot/api/index.js.map +1 -0
- package/lib/commonjs/BettorBot/components/BroadcastMessageCard.js +233 -0
- package/lib/commonjs/BettorBot/components/BroadcastMessageCard.js.map +1 -0
- package/lib/commonjs/BettorBot/components/ServerInfoCard.js +126 -0
- package/lib/commonjs/BettorBot/components/ServerInfoCard.js.map +1 -0
- package/lib/commonjs/BettorBot/index.js +532 -0
- package/lib/commonjs/BettorBot/index.js.map +1 -0
- package/lib/commonjs/CreateEngagement/index.js +3 -0
- package/lib/commonjs/CreateEngagement/index.js.map +1 -1
- package/lib/commonjs/FlashMarket/api/index.js +61 -0
- package/lib/commonjs/FlashMarket/api/index.js.map +1 -1
- package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js +55 -81
- package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js.map +1 -1
- package/lib/commonjs/MyAction/api/index.js +580 -0
- package/lib/commonjs/MyAction/api/index.js.map +1 -0
- package/lib/commonjs/MyAction/components/BracketRow.js +67 -0
- package/lib/commonjs/MyAction/components/BracketRow.js.map +1 -0
- package/lib/commonjs/MyAction/components/CompetitionRow.js +68 -0
- package/lib/commonjs/MyAction/components/CompetitionRow.js.map +1 -0
- package/lib/commonjs/MyAction/components/ContestStatRow.js +265 -0
- package/lib/commonjs/MyAction/components/ContestStatRow.js.map +1 -0
- package/lib/commonjs/MyAction/components/FlashRow.js +131 -0
- package/lib/commonjs/MyAction/components/FlashRow.js.map +1 -0
- package/lib/commonjs/MyAction/components/ParlayRow.js +236 -0
- package/lib/commonjs/MyAction/components/ParlayRow.js.map +1 -0
- package/lib/commonjs/MyAction/components/SquaresRow.js +83 -0
- package/lib/commonjs/MyAction/components/SquaresRow.js.map +1 -0
- package/lib/commonjs/MyAction/index.js +354 -0
- package/lib/commonjs/MyAction/index.js.map +1 -0
- package/lib/commonjs/PartnerPortal/components/EmbedManager.js +42 -0
- package/lib/commonjs/PartnerPortal/components/EmbedManager.js.map +1 -1
- package/lib/commonjs/PartnerPortal/components/StringSelector.js +90 -0
- package/lib/commonjs/PartnerPortal/components/StringSelector.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.d.js.map +1 -1
- package/lib/module/ApiOverrides/index.js +4 -0
- package/lib/module/ApiOverrides/index.js.map +1 -1
- package/lib/module/BettorBot/api/index.js +57 -0
- package/lib/module/BettorBot/api/index.js.map +1 -0
- package/lib/module/BettorBot/components/BroadcastMessageCard.js +226 -0
- package/lib/module/BettorBot/components/BroadcastMessageCard.js.map +1 -0
- package/lib/module/BettorBot/components/ServerInfoCard.js +119 -0
- package/lib/module/BettorBot/components/ServerInfoCard.js.map +1 -0
- package/lib/module/BettorBot/index.js +524 -0
- package/lib/module/BettorBot/index.js.map +1 -0
- package/lib/module/CreateEngagement/index.js +3 -0
- package/lib/module/CreateEngagement/index.js.map +1 -1
- package/lib/module/FlashMarket/api/index.js +61 -0
- package/lib/module/FlashMarket/api/index.js.map +1 -1
- package/lib/module/FlashMarket/components/ManageFlashMarket.js +55 -81
- package/lib/module/FlashMarket/components/ManageFlashMarket.js.map +1 -1
- package/lib/module/MyAction/api/index.js +573 -0
- package/lib/module/MyAction/api/index.js.map +1 -0
- package/lib/module/MyAction/components/BracketRow.js +60 -0
- package/lib/module/MyAction/components/BracketRow.js.map +1 -0
- package/lib/module/MyAction/components/CompetitionRow.js +61 -0
- package/lib/module/MyAction/components/CompetitionRow.js.map +1 -0
- package/lib/module/MyAction/components/ContestStatRow.js +258 -0
- package/lib/module/MyAction/components/ContestStatRow.js.map +1 -0
- package/lib/module/MyAction/components/FlashRow.js +124 -0
- package/lib/module/MyAction/components/FlashRow.js.map +1 -0
- package/lib/module/MyAction/components/ParlayRow.js +229 -0
- package/lib/module/MyAction/components/ParlayRow.js.map +1 -0
- package/lib/module/MyAction/components/SquaresRow.js +76 -0
- package/lib/module/MyAction/components/SquaresRow.js.map +1 -0
- package/lib/module/MyAction/index.js +344 -0
- package/lib/module/MyAction/index.js.map +1 -0
- package/lib/module/PartnerPortal/components/EmbedManager.js +42 -0
- package/lib/module/PartnerPortal/components/EmbedManager.js.map +1 -1
- package/lib/module/PartnerPortal/components/StringSelector.js +83 -0
- package/lib/module/PartnerPortal/components/StringSelector.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.d.js.map +1 -1
- package/lib/typescript/lib/commonjs/ApiOverrides/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/BettorBot/api/index.d.ts +9 -0
- package/lib/typescript/lib/commonjs/BettorBot/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/BettorBot/components/BroadcastMessageCard.d.ts +10 -0
- package/lib/typescript/lib/commonjs/BettorBot/components/BroadcastMessageCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/BettorBot/components/ServerInfoCard.d.ts +10 -0
- package/lib/typescript/lib/commonjs/BettorBot/components/ServerInfoCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/BettorBot/index.d.ts +7 -0
- package/lib/typescript/lib/commonjs/BettorBot/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/MyAction/api/index.d.ts +110 -0
- package/lib/typescript/lib/commonjs/MyAction/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/components/BracketRow.d.ts +8 -0
- package/lib/typescript/lib/commonjs/MyAction/components/BracketRow.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/components/CompetitionRow.d.ts +9 -0
- package/lib/typescript/lib/commonjs/MyAction/components/CompetitionRow.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/components/ContestStatRow.d.ts +15 -0
- package/lib/typescript/lib/commonjs/MyAction/components/ContestStatRow.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/components/FlashRow.d.ts +10 -0
- package/lib/typescript/lib/commonjs/MyAction/components/FlashRow.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/components/ParlayRow.d.ts +15 -0
- package/lib/typescript/lib/commonjs/MyAction/components/ParlayRow.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/components/SquaresRow.d.ts +8 -0
- package/lib/typescript/lib/commonjs/MyAction/components/SquaresRow.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/MyAction/index.d.ts +7 -0
- package/lib/typescript/lib/commonjs/MyAction/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/PartnerPortal/components/EmbedManager.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/PartnerPortal/components/StringSelector.d.ts +8 -0
- package/lib/typescript/lib/commonjs/PartnerPortal/components/StringSelector.d.ts.map +1 -0
- 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/ApiOverrides/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/BettorBot/api/index.d.ts +8 -0
- package/lib/typescript/lib/module/BettorBot/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/BettorBot/components/BroadcastMessageCard.d.ts +10 -0
- package/lib/typescript/lib/module/BettorBot/components/BroadcastMessageCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/BettorBot/components/ServerInfoCard.d.ts +10 -0
- package/lib/typescript/lib/module/BettorBot/components/ServerInfoCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/BettorBot/index.d.ts +7 -0
- package/lib/typescript/lib/module/BettorBot/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/FlashMarket/api/index.d.ts +1 -0
- package/lib/typescript/lib/module/FlashMarket/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
- package/lib/typescript/lib/module/MyAction/api/index.d.ts +110 -0
- package/lib/typescript/lib/module/MyAction/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/components/BracketRow.d.ts +8 -0
- package/lib/typescript/lib/module/MyAction/components/BracketRow.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/components/CompetitionRow.d.ts +9 -0
- package/lib/typescript/lib/module/MyAction/components/CompetitionRow.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/components/ContestStatRow.d.ts +15 -0
- package/lib/typescript/lib/module/MyAction/components/ContestStatRow.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/components/FlashRow.d.ts +10 -0
- package/lib/typescript/lib/module/MyAction/components/FlashRow.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/components/ParlayRow.d.ts +15 -0
- package/lib/typescript/lib/module/MyAction/components/ParlayRow.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/components/SquaresRow.d.ts +8 -0
- package/lib/typescript/lib/module/MyAction/components/SquaresRow.d.ts.map +1 -0
- package/lib/typescript/lib/module/MyAction/index.d.ts +7 -0
- package/lib/typescript/lib/module/MyAction/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/PartnerPortal/components/EmbedManager.d.ts.map +1 -1
- package/lib/typescript/lib/module/PartnerPortal/components/StringSelector.d.ts +8 -0
- package/lib/typescript/lib/module/PartnerPortal/components/StringSelector.d.ts.map +1 -0
- 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/ApiOverrides/index.d.ts.map +1 -1
- package/lib/typescript/src/BettorBot/api/index.d.ts +9 -0
- package/lib/typescript/src/BettorBot/api/index.d.ts.map +1 -0
- package/lib/typescript/src/BettorBot/components/BroadcastMessageCard.d.ts +15 -0
- package/lib/typescript/src/BettorBot/components/BroadcastMessageCard.d.ts.map +1 -0
- package/lib/typescript/src/BettorBot/components/ServerInfoCard.d.ts +12 -0
- package/lib/typescript/src/BettorBot/components/ServerInfoCard.d.ts.map +1 -0
- package/lib/typescript/src/BettorBot/index.d.ts +9 -0
- package/lib/typescript/src/BettorBot/index.d.ts.map +1 -0
- package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/src/FlashMarket/api/index.d.ts +1 -0
- package/lib/typescript/src/FlashMarket/api/index.d.ts.map +1 -1
- package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
- package/lib/typescript/src/MyAction/api/index.d.ts +103 -0
- package/lib/typescript/src/MyAction/api/index.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/components/BracketRow.d.ts +10 -0
- package/lib/typescript/src/MyAction/components/BracketRow.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/components/CompetitionRow.d.ts +15 -0
- package/lib/typescript/src/MyAction/components/CompetitionRow.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/components/ContestStatRow.d.ts +18 -0
- package/lib/typescript/src/MyAction/components/ContestStatRow.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/components/FlashRow.d.ts +12 -0
- package/lib/typescript/src/MyAction/components/FlashRow.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/components/ParlayRow.d.ts +18 -0
- package/lib/typescript/src/MyAction/components/ParlayRow.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/components/SquaresRow.d.ts +10 -0
- package/lib/typescript/src/MyAction/components/SquaresRow.d.ts.map +1 -0
- package/lib/typescript/src/MyAction/index.d.ts +14 -0
- package/lib/typescript/src/MyAction/index.d.ts.map +1 -0
- package/lib/typescript/src/PartnerPortal/components/EmbedManager.d.ts.map +1 -1
- package/lib/typescript/src/PartnerPortal/components/StringSelector.d.ts +10 -0
- package/lib/typescript/src/PartnerPortal/components/StringSelector.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ApiOverrides/index.ts +4 -0
- package/src/BettorBot/api/index.ts +49 -0
- package/src/BettorBot/components/BroadcastMessageCard.tsx +159 -0
- package/src/BettorBot/components/ServerInfoCard.tsx +73 -0
- package/src/BettorBot/index.tsx +295 -0
- package/src/CreateEngagement/index.tsx +4 -1
- package/src/FlashMarket/api/index.ts +72 -0
- package/src/FlashMarket/components/ManageFlashMarket.tsx +10 -0
- package/src/MyAction/api/index.ts +393 -0
- package/src/MyAction/components/BracketRow.tsx +34 -0
- package/src/MyAction/components/CompetitionRow.tsx +39 -0
- package/src/MyAction/components/ContestStatRow.tsx +153 -0
- package/src/MyAction/components/FlashRow.tsx +74 -0
- package/src/MyAction/components/ParlayRow.tsx +137 -0
- package/src/MyAction/components/SquaresRow.tsx +55 -0
- package/src/MyAction/index.tsx +316 -0
- package/src/PartnerPortal/components/EmbedManager.tsx +20 -0
- package/src/PartnerPortal/components/StringSelector.tsx +55 -0
- package/src/index.tsx +4 -0
- package/src/types.d.ts +60 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, Text, View } from "../../Components/Themed";
|
|
3
|
+
import type { AccessibleChannel, ServerInfo } from '../../types';
|
|
4
|
+
import { FlatList, Image } from 'react-native';
|
|
5
|
+
import { Checkbox, SearchBox } from '../../Components';
|
|
6
|
+
import { useColors } from '../../constants/useColors';
|
|
7
|
+
|
|
8
|
+
type ServerInfoProps = {
|
|
9
|
+
server:ServerInfo
|
|
10
|
+
selected_channels: string[],
|
|
11
|
+
onClose:() => void,
|
|
12
|
+
onSelectChannel: (channel_id:string) => void,
|
|
13
|
+
onDeselectChannel: (channel_id:string) => void
|
|
14
|
+
}
|
|
15
|
+
const ServerInfoCard = ({ server, selected_channels, onDeselectChannel, onSelectChannel, onClose }:ServerInfoProps) => {
|
|
16
|
+
const Colors = useColors();
|
|
17
|
+
const [ channel_search, setChannelSearch ] = useState('');
|
|
18
|
+
const filtered_channels = server.accessibleChannels.filter(c => `${c.name}`.toLowerCase().includes(channel_search));
|
|
19
|
+
|
|
20
|
+
const renderChannels = (data: { item: AccessibleChannel, index:number }) => {
|
|
21
|
+
const selected = selected_channels.includes(data.item.id) ? true : false
|
|
22
|
+
return (
|
|
23
|
+
<View transparent type='row' style={{ padding:8, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
24
|
+
<Checkbox
|
|
25
|
+
style={{ marginRight:10 }}
|
|
26
|
+
checked={selected}
|
|
27
|
+
onSelect={() => selected ? onDeselectChannel(data.item.id) : onSelectChannel(data.item.id)}
|
|
28
|
+
/>
|
|
29
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
30
|
+
<Text theme='h1'>{data.item.name}</Text>
|
|
31
|
+
</View>
|
|
32
|
+
</View>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<View float style={{ flex:1 }}>
|
|
38
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
39
|
+
<Image
|
|
40
|
+
source={{ uri: server.icon ?? '' }}
|
|
41
|
+
style={{ height:40, width:40 }}
|
|
42
|
+
/>
|
|
43
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
44
|
+
<Text theme='h1'>{server.name}</Text>
|
|
45
|
+
<Text theme='description' style={{ marginTop:3 }}>{server.description}</Text>
|
|
46
|
+
</View>
|
|
47
|
+
</View>
|
|
48
|
+
<View style={{ flex:1, padding:10 }}>
|
|
49
|
+
<Text theme='h1' style={{ marginBottom:10 }}>Select Channels Below</Text>
|
|
50
|
+
<View transparent style={{ padding:5 }}>
|
|
51
|
+
<SearchBox onChange={(text) => setChannelSearch(text)} hide_search_button/>
|
|
52
|
+
</View>
|
|
53
|
+
<FlatList
|
|
54
|
+
key={'channel_list'}
|
|
55
|
+
data={filtered_channels.sort((a,b) => a.name.localeCompare(b.name))}
|
|
56
|
+
renderItem={renderChannels}
|
|
57
|
+
keyExtractor={(item) => item.id}
|
|
58
|
+
/>
|
|
59
|
+
</View>
|
|
60
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
|
|
61
|
+
<Button
|
|
62
|
+
type='close'
|
|
63
|
+
title='CLOSE'
|
|
64
|
+
style={{ flex:1 }}
|
|
65
|
+
onPress={() => onClose()}
|
|
66
|
+
/>
|
|
67
|
+
</View>
|
|
68
|
+
</View>
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default ServerInfoCard
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Text, View } from "../Components/Themed"
|
|
3
|
+
import { FlatList, Image } from 'react-native';
|
|
4
|
+
import type { DiscordPlayerStatsProps, FocusPositionProps, MyPlayerProps, PublicPlayerProps, ServerInfo } from '../types';
|
|
5
|
+
import { BettorBotApi } from './api';
|
|
6
|
+
import Pagination from '../Components/Pagination';
|
|
7
|
+
import { useColors } from '../constants/useColors';
|
|
8
|
+
import { Checkbox, SearchBox } from '../Components';
|
|
9
|
+
import moment from 'moment-mini';
|
|
10
|
+
import ServerInfoCard from './components/ServerInfoCard';
|
|
11
|
+
import BroadcastMessageCard from './components/BroadcastMessageCard';
|
|
12
|
+
|
|
13
|
+
type BettorBotDashboardProps = {
|
|
14
|
+
me?:MyPlayerProps,
|
|
15
|
+
onFocusPosition?:(pos:FocusPositionProps) => void,
|
|
16
|
+
}
|
|
17
|
+
const PAGE_SIZE = 5
|
|
18
|
+
const sections = ['broadcast', 'row_1', 'row_2']
|
|
19
|
+
const BettorBotDashboard = ({ me, onFocusPosition }:BettorBotDashboardProps) => {
|
|
20
|
+
const Colors = useColors();
|
|
21
|
+
const [ size, setSize ] = useState({ width:0, height:0 });
|
|
22
|
+
const [ server_offset, setServerOffset ] = useState(0);
|
|
23
|
+
const [ server_search, setServerSearch ] = useState('');
|
|
24
|
+
const [ show_server_id, setShowServerId ] = useState<string|undefined>(undefined);
|
|
25
|
+
const [ player_offset, setPlayerOffset ] = useState(0);
|
|
26
|
+
const [ player_search, setPlayerSearch ] = useState('');
|
|
27
|
+
const [ selected_servers, setSelectedServers ] = useState<{ guild_id:string, channels:string[] }[]>([]);
|
|
28
|
+
const [ show_message, setShowMessage ] = useState(false);
|
|
29
|
+
const [ state, setState ] = useState<{
|
|
30
|
+
loading: boolean,
|
|
31
|
+
servers:ServerInfo[],
|
|
32
|
+
players:PublicPlayerProps[],
|
|
33
|
+
discord_player_stats:DiscordPlayerStatsProps[]
|
|
34
|
+
}>({
|
|
35
|
+
loading:false,
|
|
36
|
+
servers: [],
|
|
37
|
+
players:[],
|
|
38
|
+
discord_player_stats:[]
|
|
39
|
+
});
|
|
40
|
+
const { servers, discord_player_stats, players } = state;
|
|
41
|
+
const total_servers = servers.length
|
|
42
|
+
const total_channels = servers.reduce((a,b) => a + b.accessibleChannels.length, 0)
|
|
43
|
+
const total_members = servers.reduce((a,b) => a + b.memberCount, 0);
|
|
44
|
+
let filtered_servers = servers.sort((a,b) => b.memberCount - a.memberCount || a.name.localeCompare(b.name)).slice(server_offset * PAGE_SIZE, (server_offset * PAGE_SIZE) + PAGE_SIZE);
|
|
45
|
+
if(server_search){ filtered_servers = servers.filter(s => `${s.name}`.toLowerCase().includes(server_search.toLowerCase())).slice(server_offset * PAGE_SIZE, (server_offset * PAGE_SIZE) + PAGE_SIZE) }
|
|
46
|
+
|
|
47
|
+
const total_discord_players = discord_player_stats.reduce((a,b) => a + b.count, 0)
|
|
48
|
+
const connected = discord_player_stats.filter(s => s.status == 'active').reduce((a,b) => a + b.count, 0);
|
|
49
|
+
const not_connected = discord_player_stats.filter(s => s.status != 'active').reduce((a,b) => a + b.count, 0);
|
|
50
|
+
|
|
51
|
+
let filtered_players = players.sort((a,b) => a.username.localeCompare(b.username)).slice(player_offset * PAGE_SIZE, (player_offset * PAGE_SIZE) + PAGE_SIZE);
|
|
52
|
+
if(player_search){ filtered_players = players.filter(s => `${s.username}`.toLowerCase().includes(player_search.toLowerCase())).slice(player_offset * PAGE_SIZE, (player_offset * PAGE_SIZE) + PAGE_SIZE) }
|
|
53
|
+
|
|
54
|
+
const show_server = servers.find(s => s.id == show_server_id);
|
|
55
|
+
const selected_channel_count = selected_servers.reduce((a,b) => a + b.channels.length, 0);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if(!me){ return }
|
|
59
|
+
if(me.role != 'admin'){ return alert('You are not authorized') }
|
|
60
|
+
BettorBotApi.setEnvironment();
|
|
61
|
+
getData();
|
|
62
|
+
},[me]);
|
|
63
|
+
|
|
64
|
+
const getData = async() => {
|
|
65
|
+
setState({ ...state, loading:true });
|
|
66
|
+
const resp = await BettorBotApi.getServers();
|
|
67
|
+
if(resp.error){ alert('Unable to get data') }
|
|
68
|
+
const dps = await BettorBotApi.getDiscordStats();
|
|
69
|
+
let player_ids:string[] = []
|
|
70
|
+
dps.map(p => p.player_ids.map(id => player_ids.push(id)));
|
|
71
|
+
let s_players = await BettorBotApi.getPlayersByPlayerIds(player_ids)
|
|
72
|
+
setState({
|
|
73
|
+
...state,
|
|
74
|
+
servers: resp.servers,
|
|
75
|
+
discord_player_stats: dps,
|
|
76
|
+
players: s_players,
|
|
77
|
+
loading: false,
|
|
78
|
+
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const renderPlayers = (data:{ item:PublicPlayerProps, index:number }) => {
|
|
83
|
+
return (
|
|
84
|
+
<View transparent type='row' style={{ padding:8, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
85
|
+
<Image
|
|
86
|
+
source={{ uri: data.item.profile_pic ?? '' }}
|
|
87
|
+
style={{ height:40, width:40 }}
|
|
88
|
+
resizeMode='cover'
|
|
89
|
+
/>
|
|
90
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
91
|
+
<Text theme='h1'>{data.item.username}</Text>
|
|
92
|
+
<Text theme='description' style={{ marginTop:3, maxWidth: size.width *0.7 }}>Joined {moment(data.item.create_datetime).fromNow()}</Text>
|
|
93
|
+
</View>
|
|
94
|
+
</View>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const renderServers = (data:{ item:ServerInfo, index:number }) => {
|
|
99
|
+
const selected = selected_servers.find(s => s.guild_id == data.item.id) ? true : false
|
|
100
|
+
return (
|
|
101
|
+
<View transparent type='row' style={{ padding:8, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
102
|
+
<Checkbox
|
|
103
|
+
style={{ marginRight:10 }}
|
|
104
|
+
checked={selected}
|
|
105
|
+
onSelect={() => {
|
|
106
|
+
if(!selected){
|
|
107
|
+
setSelectedServers(selected_servers.concat({ guild_id: data.item.id, channels: [] }));
|
|
108
|
+
return setShowServerId(data.item.id);
|
|
109
|
+
}
|
|
110
|
+
setSelectedServers(selected_servers.filter(s => s.guild_id != data.item.id))
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
<Image
|
|
114
|
+
source={{ uri: data.item.icon ?? '' }}
|
|
115
|
+
style={{ height:40, width:40 }}
|
|
116
|
+
resizeMode='cover'
|
|
117
|
+
/>
|
|
118
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
119
|
+
<Text theme='h1'>{data.item.name}</Text>
|
|
120
|
+
<Text theme='description' style={{ marginTop:3, maxWidth: size.width *0.7 }}>{data.item.description}</Text>
|
|
121
|
+
</View>
|
|
122
|
+
<View transparent style={{ padding:5 }}>
|
|
123
|
+
<Text theme='h1'>{data.item.memberCount}</Text>
|
|
124
|
+
<Text theme='description' style={{ marginTop:3 }}>Members</Text>
|
|
125
|
+
</View>
|
|
126
|
+
</View>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const renderSections = (data: { item:string, index:number }) => {
|
|
131
|
+
switch(data.item){
|
|
132
|
+
case 'row_1':
|
|
133
|
+
return (
|
|
134
|
+
<View style={{ flexDirection:'row', flexWrap:'wrap' }}>
|
|
135
|
+
<View float style={{ margin:5, minWidth:150, flexGrow:1 }}>
|
|
136
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
137
|
+
<View transparent style={{ flex:1 }}>
|
|
138
|
+
<Text theme='h1'>Bot Stats</Text>
|
|
139
|
+
</View>
|
|
140
|
+
</View>
|
|
141
|
+
<View transparent style={{ padding:10 }}>
|
|
142
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
143
|
+
<Text style={{ flex:1 }} theme='h2'>Total Servers</Text>
|
|
144
|
+
<Text theme='h1'>{total_servers}</Text>
|
|
145
|
+
</View>
|
|
146
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
147
|
+
<Text style={{ flex:1 }} theme='h2'>Total Channels</Text>
|
|
148
|
+
<Text theme='h1'>{total_channels}</Text>
|
|
149
|
+
</View>
|
|
150
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
151
|
+
<Text style={{ flex:1 }} theme='h2'>Total Members</Text>
|
|
152
|
+
<Text theme='h1'>{total_members}</Text>
|
|
153
|
+
</View>
|
|
154
|
+
</View>
|
|
155
|
+
</View>
|
|
156
|
+
<View float style={{ margin:5, minWidth:350, flexGrow:1 }}>
|
|
157
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
158
|
+
<View transparent style={{ flex:1 }}>
|
|
159
|
+
<Text theme='h1'>Servers</Text>
|
|
160
|
+
<Text style={{ marginTop:3 }} theme='description'>Select Servers to send message to below.</Text>
|
|
161
|
+
</View>
|
|
162
|
+
{selected_servers.length > 0 && selected_channel_count > 0 ?
|
|
163
|
+
<Button type='action' style={{ padding:10 }} onPress={() => setShowMessage(true)}>
|
|
164
|
+
<Text theme='description' color={Colors.text.white}>Send Message</Text>
|
|
165
|
+
<Text style={{ marginTop:3 }} theme='light' color={Colors.text.white}>{selected_servers.length} Servers</Text>
|
|
166
|
+
</Button>
|
|
167
|
+
:<></>}
|
|
168
|
+
</View>
|
|
169
|
+
<View transparent>
|
|
170
|
+
<View transparent style={{ padding:10 }}>
|
|
171
|
+
<SearchBox
|
|
172
|
+
hide_search_button
|
|
173
|
+
onChange={(text) => {
|
|
174
|
+
setServerSearch(text);
|
|
175
|
+
setServerOffset(0)
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
</View>
|
|
179
|
+
<Pagination offset={server_offset} onNext={() => setServerOffset(server_offset + 1)} onPrevious={() => setServerOffset(server_offset - 1)} />
|
|
180
|
+
<FlatList
|
|
181
|
+
data={filtered_servers.sort((a,b) => b.memberCount - a.memberCount || a.name.localeCompare(b.name))}
|
|
182
|
+
renderItem={renderServers}
|
|
183
|
+
keyExtractor={item => item.id}
|
|
184
|
+
key={'server_list'}
|
|
185
|
+
/>
|
|
186
|
+
</View>
|
|
187
|
+
</View>
|
|
188
|
+
</View>
|
|
189
|
+
)
|
|
190
|
+
case 'row_2':
|
|
191
|
+
return (
|
|
192
|
+
<View style={{ flexDirection:'row', flexWrap:'wrap' }}>
|
|
193
|
+
<View float style={{ margin:5, minWidth:150, flexGrow:1 }}>
|
|
194
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
195
|
+
<View transparent style={{ flex:1 }}>
|
|
196
|
+
<Text theme='h1'>Connection Stats</Text>
|
|
197
|
+
</View>
|
|
198
|
+
</View>
|
|
199
|
+
<View transparent style={{ padding:10 }}>
|
|
200
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
201
|
+
<Text style={{ flex:1 }} theme='h2'>Total Players</Text>
|
|
202
|
+
<Text theme='h1'>{total_discord_players}</Text>
|
|
203
|
+
</View>
|
|
204
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
205
|
+
<Text style={{ flex:1 }} theme='h2'>Fully Connected</Text>
|
|
206
|
+
<Text theme='h1'>{connected}</Text>
|
|
207
|
+
</View>
|
|
208
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
209
|
+
<Text style={{ flex:1 }} theme='h2'>Inactive</Text>
|
|
210
|
+
<Text theme='h1'>{not_connected}</Text>
|
|
211
|
+
</View>
|
|
212
|
+
</View>
|
|
213
|
+
</View>
|
|
214
|
+
<View float style={{ margin:5, minWidth:350, flexGrow:1 }}>
|
|
215
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
216
|
+
<View transparent style={{ flex:1 }}>
|
|
217
|
+
<Text theme='h1'>Players</Text>
|
|
218
|
+
</View>
|
|
219
|
+
</View>
|
|
220
|
+
<View transparent>
|
|
221
|
+
<View transparent style={{ padding:10 }}>
|
|
222
|
+
<SearchBox
|
|
223
|
+
hide_search_button
|
|
224
|
+
onChange={(text) => {
|
|
225
|
+
setPlayerSearch(text);
|
|
226
|
+
setPlayerOffset(0)
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
</View>
|
|
230
|
+
<Pagination offset={player_offset} onNext={() => setPlayerOffset(player_offset + 1)} onPrevious={() => setPlayerOffset(player_offset - 1)} />
|
|
231
|
+
<FlatList
|
|
232
|
+
data={filtered_players.sort((a,b) => a.username.localeCompare(b.username))}
|
|
233
|
+
renderItem={renderPlayers}
|
|
234
|
+
keyExtractor={item => item.player_id.toString()}
|
|
235
|
+
key={'player_list'}
|
|
236
|
+
/>
|
|
237
|
+
</View>
|
|
238
|
+
</View>
|
|
239
|
+
</View>
|
|
240
|
+
)
|
|
241
|
+
default: return <></>
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<View style={{ flex:1 }} onLayout={(ev) => {
|
|
247
|
+
const { height, width } = ev.nativeEvent.layout
|
|
248
|
+
setSize({ height, width })
|
|
249
|
+
}}>
|
|
250
|
+
<FlatList
|
|
251
|
+
data={sections}
|
|
252
|
+
key={'bot_sections'}
|
|
253
|
+
keyExtractor={item => item}
|
|
254
|
+
renderItem={renderSections}
|
|
255
|
+
/>
|
|
256
|
+
{show_server ?
|
|
257
|
+
<View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, padding:10 }}>
|
|
258
|
+
<ServerInfoCard
|
|
259
|
+
selected_channels={selected_servers.find(s => s.guild_id == show_server.id)?.channels ?? []}
|
|
260
|
+
server={show_server}
|
|
261
|
+
onClose={() => setShowServerId(undefined)}
|
|
262
|
+
onSelectChannel={(channel_id) => {
|
|
263
|
+
let guild = selected_servers.find(s => s.guild_id == show_server.id);
|
|
264
|
+
if(!guild){ return alert('Error') }
|
|
265
|
+
let channels = guild.channels.concat(channel_id);
|
|
266
|
+
setSelectedServers(selected_servers.filter(s => s.guild_id != show_server.id).concat({ guild_id: show_server.id, channels }))
|
|
267
|
+
}}
|
|
268
|
+
onDeselectChannel={(channel_id) => {
|
|
269
|
+
let guild = selected_servers.find(s => s.guild_id == show_server.id);
|
|
270
|
+
if(!guild){ return alert('Error') }
|
|
271
|
+
let channels = guild.channels.filter(id => id != channel_id);
|
|
272
|
+
setSelectedServers(selected_servers.filter(s => s.guild_id != show_server.id).concat({ guild_id: show_server.id, channels }))
|
|
273
|
+
}}
|
|
274
|
+
/>
|
|
275
|
+
</View>
|
|
276
|
+
:<></>}
|
|
277
|
+
{show_message ?
|
|
278
|
+
<View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, padding:10 }}>
|
|
279
|
+
<BroadcastMessageCard
|
|
280
|
+
selected_servers={selected_servers}
|
|
281
|
+
servers={servers}
|
|
282
|
+
onFocusPosition={onFocusPosition}
|
|
283
|
+
onClose={() => setShowMessage(false)}
|
|
284
|
+
onSendMessage={(_) => {
|
|
285
|
+
setSelectedServers([])
|
|
286
|
+
setShowMessage(false)
|
|
287
|
+
}}
|
|
288
|
+
/>
|
|
289
|
+
</View>
|
|
290
|
+
:<></>}
|
|
291
|
+
</View>
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export default BettorBotDashboard
|
|
@@ -106,7 +106,10 @@ const CreateEngagement = ({ float, player, bracket_id, flash_campaign_id, init_e
|
|
|
106
106
|
groups: my_grups.groups,
|
|
107
107
|
companies: my_comps.companies,
|
|
108
108
|
loading:false
|
|
109
|
-
})
|
|
109
|
+
});
|
|
110
|
+
if(act_company?.company_image?.url){
|
|
111
|
+
setDraftImage(act_company.company_image)
|
|
112
|
+
}
|
|
110
113
|
}
|
|
111
114
|
const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash, draft_bracket_competition);
|
|
112
115
|
|
|
@@ -116,6 +116,78 @@ export const FlashMarketHelpers = {
|
|
|
116
116
|
if(!parimutuel_odds){ return 0 }
|
|
117
117
|
return stake / parimutuel_odds
|
|
118
118
|
},
|
|
119
|
+
updatePollOptionProbability: (
|
|
120
|
+
changingOptionId: string,
|
|
121
|
+
newProbability: number,
|
|
122
|
+
allOptions: PollOptionProps[]
|
|
123
|
+
): PollOptionProps[] => {
|
|
124
|
+
const total = 1;
|
|
125
|
+
const minProb = 0.001; // minimum probability for unlocked options
|
|
126
|
+
|
|
127
|
+
// Clone and update changing option
|
|
128
|
+
const updatedOptions = allOptions.map(o =>
|
|
129
|
+
o.poll_option_id === changingOptionId
|
|
130
|
+
? { ...o, initial_odds: newProbability }
|
|
131
|
+
: { ...o }
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const lockedOptions = updatedOptions.filter(o => o.probability_locked);
|
|
135
|
+
const unlockedOptions = updatedOptions.filter(
|
|
136
|
+
o => !o.probability_locked && o.poll_option_id !== changingOptionId
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const lockedSum = lockedOptions.reduce(
|
|
140
|
+
(sum, o) => sum + (o.initial_odds ?? 0),
|
|
141
|
+
0
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const changedOption = updatedOptions.find(o => o.poll_option_id === changingOptionId);
|
|
145
|
+
if (!changedOption) return updatedOptions;
|
|
146
|
+
|
|
147
|
+
const oldProb = changedOption.initial_odds ?? 0;
|
|
148
|
+
//const delta = newProbability - oldProb; // positive if increasing, negative if decreasing
|
|
149
|
+
|
|
150
|
+
// Calculate the maximum allowed increase for the changing option
|
|
151
|
+
const maxForChanged = total - lockedSum - unlockedOptions.length * minProb;
|
|
152
|
+
changedOption.initial_odds = Math.min(Math.max(minProb, newProbability), maxForChanged);
|
|
153
|
+
|
|
154
|
+
const adjustedDelta = changedOption.initial_odds - oldProb;
|
|
155
|
+
|
|
156
|
+
// Remaining probability to redistribute among unlocked options
|
|
157
|
+
let remaining = total - lockedSum - changedOption.initial_odds;
|
|
158
|
+
|
|
159
|
+
if (unlockedOptions.length === 0) return updatedOptions;
|
|
160
|
+
|
|
161
|
+
// Redistribute probabilities
|
|
162
|
+
const finalOptions = updatedOptions.map(o => {
|
|
163
|
+
if (o.probability_locked || o.poll_option_id === changingOptionId) return o;
|
|
164
|
+
|
|
165
|
+
if (adjustedDelta < 0) {
|
|
166
|
+
// Changing option decreased → distribute evenly to others
|
|
167
|
+
const evenly = remaining / unlockedOptions.length;
|
|
168
|
+
return { ...o, initial_odds: Math.max(minProb, evenly) };
|
|
169
|
+
} else {
|
|
170
|
+
// Changing option increased → reduce proportionally
|
|
171
|
+
const sumUnlocked = unlockedOptions.reduce((sum, u) => sum + (u.initial_odds ?? 0), 0);
|
|
172
|
+
const proportion = (o.initial_odds ?? 0) / sumUnlocked;
|
|
173
|
+
const newOdds = Math.max(minProb, proportion * remaining);
|
|
174
|
+
return { ...o, initial_odds: newOdds };
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Fix rounding errors
|
|
179
|
+
const currentSum = finalOptions.reduce((sum, o) => sum + (o.initial_odds ?? 0), 0);
|
|
180
|
+
const roundingError = total - currentSum;
|
|
181
|
+
|
|
182
|
+
if (roundingError !== 0) {
|
|
183
|
+
const target = finalOptions.find(o => !o.probability_locked && o.poll_option_id !== changingOptionId);
|
|
184
|
+
if (target) {
|
|
185
|
+
target.initial_odds = Math.max(minProb, (target.initial_odds ?? 0) + roundingError);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return finalOptions;
|
|
190
|
+
},
|
|
119
191
|
isNewValid: (options:PollOptionProps[], summaries:PollSummaryProps[], poll?:PollProps) => {
|
|
120
192
|
let errors:string[] = []
|
|
121
193
|
if(!poll){ return ['Waiting for market'] }
|
|
@@ -181,6 +181,15 @@ const ManageFlashMarket = ({ float, header_style, player, onClose, poll_id, onFo
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
const handleChangeProbability = (option:PollOptionProps, probability:number) => {
|
|
184
|
+
|
|
185
|
+
const final_options = FlashMarketHelpers.updatePollOptionProbability(option.poll_option_id, probability, [ ...real_options ]);
|
|
186
|
+
setFlashState({
|
|
187
|
+
...flash_state,
|
|
188
|
+
probability_changed: true,
|
|
189
|
+
poll_options: poll_options.filter(po => !final_options.find(fo => fo.poll_option_id == po.poll_option_id)).concat(final_options)
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
/*
|
|
184
193
|
if(option.probability_locked){ return }
|
|
185
194
|
if(probability < 0){ return }
|
|
186
195
|
if(probability > 1){ return }
|
|
@@ -249,6 +258,7 @@ const ManageFlashMarket = ({ float, header_style, player, onClose, poll_id, onFo
|
|
|
249
258
|
probability_changed: true,
|
|
250
259
|
poll_options: poll_options.filter(po => !final_options.find(fo => fo.poll_option_id == po.poll_option_id)).concat(final_options)
|
|
251
260
|
});
|
|
261
|
+
*/
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
const renderOptions = (data:{ item:PollOptionProps, index:number }) => {
|