be-components 7.4.2 → 7.4.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.
Files changed (89) hide show
  1. package/lib/commonjs/ApiOverrides/index.js +4 -2
  2. package/lib/commonjs/ApiOverrides/index.js.map +1 -1
  3. package/lib/commonjs/BettorBot/api/index.js +64 -0
  4. package/lib/commonjs/BettorBot/api/index.js.map +1 -0
  5. package/lib/commonjs/BettorBot/components/BroadcastMessageCard.js +233 -0
  6. package/lib/commonjs/BettorBot/components/BroadcastMessageCard.js.map +1 -0
  7. package/lib/commonjs/BettorBot/components/ServerInfoCard.js +126 -0
  8. package/lib/commonjs/BettorBot/components/ServerInfoCard.js.map +1 -0
  9. package/lib/commonjs/BettorBot/index.js +532 -0
  10. package/lib/commonjs/BettorBot/index.js.map +1 -0
  11. package/lib/commonjs/NotificationManager/api/index.js +448 -0
  12. package/lib/commonjs/NotificationManager/api/index.js.map +1 -0
  13. package/lib/commonjs/NotificationManager/index.js +1159 -0
  14. package/lib/commonjs/NotificationManager/index.js.map +1 -0
  15. package/lib/commonjs/index.js +27 -0
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/types.d.js.map +1 -1
  18. package/lib/module/ApiOverrides/index.js +4 -2
  19. package/lib/module/ApiOverrides/index.js.map +1 -1
  20. package/lib/module/BettorBot/api/index.js +57 -0
  21. package/lib/module/BettorBot/api/index.js.map +1 -0
  22. package/lib/module/BettorBot/components/BroadcastMessageCard.js +226 -0
  23. package/lib/module/BettorBot/components/BroadcastMessageCard.js.map +1 -0
  24. package/lib/module/BettorBot/components/ServerInfoCard.js +119 -0
  25. package/lib/module/BettorBot/components/ServerInfoCard.js.map +1 -0
  26. package/lib/module/BettorBot/index.js +524 -0
  27. package/lib/module/BettorBot/index.js.map +1 -0
  28. package/lib/module/NotificationManager/api/index.js +441 -0
  29. package/lib/module/NotificationManager/api/index.js.map +1 -0
  30. package/lib/module/NotificationManager/index.js +1140 -0
  31. package/lib/module/NotificationManager/index.js.map +1 -0
  32. package/lib/module/index.js +4 -1
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/types.d.js.map +1 -1
  35. package/lib/typescript/lib/commonjs/ApiOverrides/index.d.ts.map +1 -1
  36. package/lib/typescript/lib/commonjs/BettorBot/api/index.d.ts +9 -0
  37. package/lib/typescript/lib/commonjs/BettorBot/api/index.d.ts.map +1 -0
  38. package/lib/typescript/lib/commonjs/BettorBot/components/BroadcastMessageCard.d.ts +10 -0
  39. package/lib/typescript/lib/commonjs/BettorBot/components/BroadcastMessageCard.d.ts.map +1 -0
  40. package/lib/typescript/lib/commonjs/BettorBot/components/ServerInfoCard.d.ts +10 -0
  41. package/lib/typescript/lib/commonjs/BettorBot/components/ServerInfoCard.d.ts.map +1 -0
  42. package/lib/typescript/lib/commonjs/BettorBot/index.d.ts +7 -0
  43. package/lib/typescript/lib/commonjs/BettorBot/index.d.ts.map +1 -0
  44. package/lib/typescript/lib/commonjs/NotificationManager/api/index.d.ts +804 -0
  45. package/lib/typescript/lib/commonjs/NotificationManager/api/index.d.ts.map +1 -0
  46. package/lib/typescript/lib/commonjs/NotificationManager/index.d.ts +815 -0
  47. package/lib/typescript/lib/commonjs/NotificationManager/index.d.ts.map +1 -0
  48. package/lib/typescript/lib/commonjs/index.d.ts +804 -0
  49. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  50. package/lib/typescript/lib/module/ApiOverrides/index.d.ts.map +1 -1
  51. package/lib/typescript/lib/module/BettorBot/api/index.d.ts +8 -0
  52. package/lib/typescript/lib/module/BettorBot/api/index.d.ts.map +1 -0
  53. package/lib/typescript/lib/module/BettorBot/components/BroadcastMessageCard.d.ts +10 -0
  54. package/lib/typescript/lib/module/BettorBot/components/BroadcastMessageCard.d.ts.map +1 -0
  55. package/lib/typescript/lib/module/BettorBot/components/ServerInfoCard.d.ts +10 -0
  56. package/lib/typescript/lib/module/BettorBot/components/ServerInfoCard.d.ts.map +1 -0
  57. package/lib/typescript/lib/module/BettorBot/index.d.ts +7 -0
  58. package/lib/typescript/lib/module/BettorBot/index.d.ts.map +1 -0
  59. package/lib/typescript/lib/module/NotificationManager/api/index.d.ts +803 -0
  60. package/lib/typescript/lib/module/NotificationManager/api/index.d.ts.map +1 -0
  61. package/lib/typescript/lib/module/NotificationManager/index.d.ts +16 -0
  62. package/lib/typescript/lib/module/NotificationManager/index.d.ts.map +1 -0
  63. package/lib/typescript/lib/module/index.d.ts +5 -1
  64. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  65. package/lib/typescript/src/ApiOverrides/index.d.ts.map +1 -1
  66. package/lib/typescript/src/BettorBot/api/index.d.ts +9 -0
  67. package/lib/typescript/src/BettorBot/api/index.d.ts.map +1 -0
  68. package/lib/typescript/src/BettorBot/components/BroadcastMessageCard.d.ts +15 -0
  69. package/lib/typescript/src/BettorBot/components/BroadcastMessageCard.d.ts.map +1 -0
  70. package/lib/typescript/src/BettorBot/components/ServerInfoCard.d.ts +12 -0
  71. package/lib/typescript/src/BettorBot/components/ServerInfoCard.d.ts.map +1 -0
  72. package/lib/typescript/src/BettorBot/index.d.ts +9 -0
  73. package/lib/typescript/src/BettorBot/index.d.ts.map +1 -0
  74. package/lib/typescript/src/NotificationManager/api/index.d.ts +822 -0
  75. package/lib/typescript/src/NotificationManager/api/index.d.ts.map +1 -0
  76. package/lib/typescript/src/NotificationManager/index.d.ts +17 -0
  77. package/lib/typescript/src/NotificationManager/index.d.ts.map +1 -0
  78. package/lib/typescript/src/index.d.ts +4 -1
  79. package/lib/typescript/src/index.d.ts.map +1 -1
  80. package/package.json +1 -1
  81. package/src/ApiOverrides/index.ts +4 -2
  82. package/src/BettorBot/api/index.ts +49 -0
  83. package/src/BettorBot/components/BroadcastMessageCard.tsx +159 -0
  84. package/src/BettorBot/components/ServerInfoCard.tsx +73 -0
  85. package/src/BettorBot/index.tsx +295 -0
  86. package/src/NotificationManager/api/index.ts +134 -0
  87. package/src/NotificationManager/index.tsx +894 -0
  88. package/src/index.tsx +8 -1
  89. package/src/types.d.ts +118 -0
@@ -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
@@ -0,0 +1,134 @@
1
+ import axios from 'axios';
2
+ import { APIOverrides } from '../../ApiOverrides';
3
+ import type { NotificationGroupMemberProps, NotificationGroupProps, PlayerNotificationProps, PublicPlayerProps } from '../../types';
4
+
5
+ let AUTH_SVC_API = '';
6
+
7
+ export interface CreateNotificationProps {
8
+ player_id?: string;
9
+ player_ids?: string[];
10
+ title: string;
11
+ message: string;
12
+ notification_type: 'info' | 'success' | 'warning' | 'error' | 'promo';
13
+ action_url?: string;
14
+ image_url?: string;
15
+ metadata?: Record<string, any>;
16
+ }
17
+
18
+ export const NotificationHelpers = {
19
+ app_paths: [
20
+ // Account Routes
21
+ { label: 'Account Home', path_name: '/account', params: {}, requiredParams: [] as string[], primary: false },
22
+ { label: 'Account Analytics', path_name: '/account/analytics', params: {}, requiredParams: [], primary: false },
23
+ { label: 'Account Discord', path_name: '/account/discord', params: {}, requiredParams: [], primary: false },
24
+ { label: 'Account Funds', path_name: '/account/funds', params: {}, requiredParams: [], primary: false },
25
+ { label: 'Account Notifications', path_name: '/account/notifications', params: {}, requiredParams: [], primary: false },
26
+ { label: 'Account Premium', path_name: '/account/premium', params: {}, requiredParams: [], primary: false },
27
+ { label: 'Account Rebates', path_name: '/account/rebates', params: {}, requiredParams: [], primary: false },
28
+ { label: 'Account Refer', path_name: '/account/refer', params: {}, requiredParams: [], primary: false },
29
+ { label: 'Account Verify', path_name: '/account/verify', params: {}, requiredParams: [], primary: false },
30
+ { label: 'Account Orders', path_name: '/account/orders/[contest_id]', params: { contest_id: '' }, requiredParams: ['contest_id'], primary: false },
31
+ { label: 'Account Rebate', path_name: '/account/rebate/[rebate_id]', params: { rebate_id: '' }, requiredParams: ['rebate_id'], primary: false },
32
+
33
+ // Competition Routes - PRIMARY
34
+ { label: 'Competitions Home', path_name: '/competitions', params: {}, requiredParams: [], primary: false },
35
+ { label: 'Bracket Competition', path_name: '/competitions/bracket/[bracket_competition_id]', params: { bracket_competition_id: '', mode: '' }, requiredParams: ['bracket_competition_id'], primary: true },
36
+ { label: 'Competition', path_name: '/competitions/competition/[competition_id]', params: { competition_id: '' }, requiredParams: ['competition_id'], primary: true },
37
+ { label: 'Season', path_name: '/competitions/season/[season_id]', params: { season_id: '' }, requiredParams: ['season_id'], primary: false },
38
+ { label: 'Squares Competition', path_name: '/competitions/squares/[sq_comp_id]', params: { sq_comp_id: '' }, requiredParams: ['sq_comp_id'], primary: true },
39
+ { label: 'Trivia', path_name: '/competitions/trivia/[trivia_id]', params: { trivia_id: '' }, requiredParams: ['trivia_id'], primary: false },
40
+
41
+ // Market Routes - PRIMARY
42
+ { label: 'Markets Home', path_name: '/markets', params: {}, requiredParams: [], primary: false },
43
+ { label: 'Favorites', path_name: '/markets/favorites', params: {}, requiredParams: [], primary: false },
44
+ { label: 'Filters', path_name: '/markets/filters', params: {}, requiredParams: [], primary: false },
45
+ { label: 'Live Markets', path_name: '/markets/live', params: {}, requiredParams: [], primary: false },
46
+ { label: 'Parlays', path_name: '/markets/parlays', params: {}, requiredParams: [], primary: false },
47
+ { label: 'Market Activity', path_name: '/markets/activity/[content_id]', params: { content_id: '' }, requiredParams: ['content_id'], primary: false },
48
+ { label: 'Contest', path_name: '/markets/contest/[contest_id]', params: { contest_id: '', contest_type: '' }, requiredParams: ['contest_id', 'contest_type'], primary: true },
49
+ { label: 'Filter', path_name: '/markets/filter/[player_filter_id]', params: { player_filter_id: '', mode: '' }, requiredParams: ['player_filter_id'], primary: false },
50
+ { label: 'Fund', path_name: '/markets/fund/[fund_id]', params: { fund_id: '' }, requiredParams: ['fund_id'], primary: false },
51
+ { label: 'Hedge', path_name: '/markets/hedge/[hedge_id]', params: { hedge_id: '' }, requiredParams: ['hedge_id'], primary: false },
52
+ { label: 'Hedges', path_name: '/markets/hedges/[contest_id]', params: { contest_id: '' }, requiredParams: ['contest_id'], primary: false },
53
+ { label: 'League', path_name: '/markets/league/[league_id]', params: { league_id: '' }, requiredParams: ['league_id'], primary: false },
54
+ { label: 'Market', path_name: '/markets/market/[contest_id]', params: { contest_id: '', contest_type: '', market_id: '', side_type: '', side_id: '' }, requiredParams: ['contest_id', 'contest_type', 'market_id'], primary: true },
55
+ { label: 'Team', path_name: '/markets/team/[team_id]', params: { team_id: '' }, requiredParams: ['team_id'], primary: false },
56
+
57
+ // Partner Routes
58
+ { label: 'Partner Home', path_name: '/partner', params: {}, requiredParams: [], primary: false },
59
+ { label: 'BettorBot', path_name: '/partner/bettorbot', params: {}, requiredParams: [], primary: false },
60
+ { label: 'Flash Campaign', path_name: '/partner/flash/[flash_campaign_id]', params: { flash_campaign_id: '' }, requiredParams: ['flash_campaign_id'], primary: false },
61
+
62
+ // Social Routes
63
+ { label: 'Social Home', path_name: '/social', params: {}, requiredParams: [], primary: false },
64
+ { label: 'Contacts', path_name: '/social/contacts', params: {}, requiredParams: [], primary: false },
65
+ { label: 'Feed', path_name: '/social/feed', params: {}, requiredParams: [], primary: false },
66
+ { label: 'Groups', path_name: '/social/groups', params: {}, requiredParams: [], primary: false },
67
+ { label: 'Leaders', path_name: '/social/leaders', params: {}, requiredParams: [], primary: false },
68
+ { label: 'Players', path_name: '/social/players', params: {}, requiredParams: [], primary: false },
69
+ { label: 'Post Activity', path_name: '/social/activity/[post_id]', params: { post_id: '' }, requiredParams: ['post_id'], primary: false },
70
+ { label: 'Campaign', path_name: '/social/campaign/[campaign_id]', params: { campaign_id: '' }, requiredParams: ['campaign_id'], primary: false },
71
+ { label: 'Chat', path_name: '/social/chat/[player_id]', params: { player_id: '' }, requiredParams: ['player_id'], primary: false },
72
+ { label: 'Company', path_name: '/social/company/[company_id]', params: { company_id: '' }, requiredParams: ['company_id'], primary: false },
73
+ { label: 'Group', path_name: '/social/group/[group_id]', params: { group_id: '' }, requiredParams: ['group_id'], primary: false },
74
+ { label: 'Head to Head', path_name: '/social/h2h/[player_id]', params: { player_id: '' }, requiredParams: ['player_id'], primary: false },
75
+ { label: 'Order', path_name: '/social/order/[order_id]', params: { order_id: '' }, requiredParams: ['order_id'], primary: false },
76
+ { label: 'Player Profile', path_name: '/social/player/[player_id]', params: { player_id: '' }, requiredParams: ['player_id'], primary: false },
77
+ { label: 'Podcast', path_name: '/social/podcast/[podcast_id]', params: { podcast_id: '' }, requiredParams: ['podcast_id'], primary: false },
78
+ { label: 'Share', path_name: '/social/share/[content_id]', params: { content_id: '' }, requiredParams: ['content_id'], primary: false },
79
+
80
+ // Custom
81
+ { label: 'Custom Path', path_name: 'custom', params: {}, requiredParams: [], primary: false }
82
+ ]
83
+ };
84
+
85
+ export const NotificationApi = {
86
+ setEnvironment: () => {
87
+ const endpoints = APIOverrides.getEndpoints();
88
+ AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
89
+ },
90
+
91
+ /**
92
+ * Get players by player IDs
93
+ */
94
+ getPlayersByPlayerIds: async(player_ids: string[]): Promise<PublicPlayerProps[]> => {
95
+ try {
96
+ if(player_ids.length === 0) { return [] }
97
+ const resp = await axios.post(`${AUTH_SVC_API}/v1/players/bulk/get`, { player_ids });
98
+ return resp.data.players;
99
+ } catch (e) {
100
+ console.log('Error fetching players:', e);
101
+ return [];
102
+ }
103
+ },
104
+
105
+ /**
106
+ * Send notifications to multiple players
107
+ */
108
+ broadcastNotifications: async(player_notification: PlayerNotificationProps, player_ids: string[]): Promise<{ message: string }> => {
109
+ try {
110
+ const resp = await axios.post(`${AUTH_SVC_API}/v1/notifications/bulk/send`, { player_notification, player_ids });
111
+ console.log(resp.data)
112
+ return resp.data;
113
+ } catch (e) {
114
+ console.log('Error broadcasting notifications:', e);
115
+ throw e;
116
+ }
117
+ },
118
+ getActiveNotificationGroups: async():Promise<NotificationGroupProps[]> => {
119
+ try {
120
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/notifications/groups/active`);
121
+ return resp.data.notification_groups
122
+ } catch (e) {
123
+ return []
124
+ }
125
+ },
126
+ getNotificationGroupMembersByGroup: async(notification_group_id:string):Promise<NotificationGroupMemberProps[]> => {
127
+ try {
128
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/notifications/group/members/${notification_group_id}`);
129
+ return resp.data.notification_group_members
130
+ } catch (e) {
131
+ return []
132
+ }
133
+ }
134
+ }