be-components 7.0.5 → 7.0.8

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 (217) hide show
  1. package/lib/commonjs/Components/BETimePicker.js +110 -0
  2. package/lib/commonjs/Components/BETimePicker.js.map +1 -0
  3. package/lib/commonjs/Components/Icons.js +37 -0
  4. package/lib/commonjs/Components/Icons.js.map +1 -1
  5. package/lib/commonjs/Components/ImageUploader.js +4 -0
  6. package/lib/commonjs/Components/ImageUploader.js.map +1 -1
  7. package/lib/commonjs/Components/Slider.js +2 -0
  8. package/lib/commonjs/Components/Slider.js.map +1 -1
  9. package/lib/commonjs/Components/Themed.js +4 -2
  10. package/lib/commonjs/Components/Themed.js.map +1 -1
  11. package/lib/commonjs/CreateEngagement/api/index.js +89 -1
  12. package/lib/commonjs/CreateEngagement/api/index.js.map +1 -1
  13. package/lib/commonjs/CreateEngagement/index.js +306 -5
  14. package/lib/commonjs/CreateEngagement/index.js.map +1 -1
  15. package/lib/commonjs/Discord/api/index.js +61 -0
  16. package/lib/commonjs/Discord/api/index.js.map +1 -0
  17. package/lib/commonjs/Discord/index.js +516 -0
  18. package/lib/commonjs/Discord/index.js.map +1 -0
  19. package/lib/commonjs/FlashMarket/FlashHolder.js +14 -1
  20. package/lib/commonjs/FlashMarket/FlashHolder.js.map +1 -1
  21. package/lib/commonjs/FlashMarket/api/index.js +42 -0
  22. package/lib/commonjs/FlashMarket/api/index.js.map +1 -1
  23. package/lib/commonjs/FlashMarket/components/FlashOptionCard.js +265 -0
  24. package/lib/commonjs/FlashMarket/components/FlashOptionCard.js.map +1 -0
  25. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js +1222 -0
  26. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js.map +1 -0
  27. package/lib/commonjs/FlashMarket/index.js +18 -6
  28. package/lib/commonjs/FlashMarket/index.js.map +1 -1
  29. package/lib/commonjs/Group/api/index.js +6 -3
  30. package/lib/commonjs/Group/api/index.js.map +1 -1
  31. package/lib/commonjs/Group/index.js +135 -20
  32. package/lib/commonjs/Group/index.js.map +1 -1
  33. package/lib/commonjs/Poll/api/index.js +0 -1
  34. package/lib/commonjs/Poll/api/index.js.map +1 -1
  35. package/lib/commonjs/Squares/index.js +0 -3
  36. package/lib/commonjs/Squares/index.js.map +1 -1
  37. package/lib/commonjs/SquaresManager/index.js +1 -1
  38. package/lib/commonjs/SquaresManager/index.js.map +1 -1
  39. package/lib/commonjs/constants/useColors.js +2 -0
  40. package/lib/commonjs/constants/useColors.js.map +1 -1
  41. package/lib/commonjs/index.js +14 -0
  42. package/lib/commonjs/index.js.map +1 -1
  43. package/lib/commonjs/types.d.js +2 -0
  44. package/lib/commonjs/types.d.js.map +1 -1
  45. package/lib/module/Components/BETimePicker.js +102 -0
  46. package/lib/module/Components/BETimePicker.js.map +1 -0
  47. package/lib/module/Components/Icons.js +37 -0
  48. package/lib/module/Components/Icons.js.map +1 -1
  49. package/lib/module/Components/ImageUploader.js +4 -0
  50. package/lib/module/Components/ImageUploader.js.map +1 -1
  51. package/lib/module/Components/Slider.js +2 -0
  52. package/lib/module/Components/Slider.js.map +1 -1
  53. package/lib/module/Components/Themed.js +4 -2
  54. package/lib/module/Components/Themed.js.map +1 -1
  55. package/lib/module/CreateEngagement/api/index.js +89 -1
  56. package/lib/module/CreateEngagement/api/index.js.map +1 -1
  57. package/lib/module/CreateEngagement/index.js +306 -5
  58. package/lib/module/CreateEngagement/index.js.map +1 -1
  59. package/lib/module/Discord/api/index.js +54 -0
  60. package/lib/module/Discord/api/index.js.map +1 -0
  61. package/lib/module/Discord/index.js +509 -0
  62. package/lib/module/Discord/index.js.map +1 -0
  63. package/lib/module/FlashMarket/FlashHolder.js +14 -1
  64. package/lib/module/FlashMarket/FlashHolder.js.map +1 -1
  65. package/lib/module/FlashMarket/api/index.js +42 -0
  66. package/lib/module/FlashMarket/api/index.js.map +1 -1
  67. package/lib/module/FlashMarket/components/FlashOptionCard.js +258 -0
  68. package/lib/module/FlashMarket/components/FlashOptionCard.js.map +1 -0
  69. package/lib/module/FlashMarket/components/ManageFlashMarket.js +1214 -0
  70. package/lib/module/FlashMarket/components/ManageFlashMarket.js.map +1 -0
  71. package/lib/module/FlashMarket/index.js +18 -6
  72. package/lib/module/FlashMarket/index.js.map +1 -1
  73. package/lib/module/Group/api/index.js +6 -3
  74. package/lib/module/Group/api/index.js.map +1 -1
  75. package/lib/module/Group/index.js +135 -20
  76. package/lib/module/Group/index.js.map +1 -1
  77. package/lib/module/Poll/api/index.js +0 -1
  78. package/lib/module/Poll/api/index.js.map +1 -1
  79. package/lib/module/Squares/index.js +0 -3
  80. package/lib/module/Squares/index.js.map +1 -1
  81. package/lib/module/SquaresManager/index.js +1 -1
  82. package/lib/module/SquaresManager/index.js.map +1 -1
  83. package/lib/module/constants/useColors.js +2 -0
  84. package/lib/module/constants/useColors.js.map +1 -1
  85. package/lib/module/index.js +3 -1
  86. package/lib/module/index.js.map +1 -1
  87. package/lib/module/types.d.js +2 -0
  88. package/lib/module/types.d.js.map +1 -1
  89. package/lib/typescript/lib/commonjs/Components/BETimePicker.d.ts +8 -0
  90. package/lib/typescript/lib/commonjs/Components/BETimePicker.d.ts.map +1 -0
  91. package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
  92. package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
  93. package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts +2 -1
  94. package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts.map +1 -1
  95. package/lib/typescript/lib/commonjs/Components/Slider.d.ts +2 -1
  96. package/lib/typescript/lib/commonjs/Components/Slider.d.ts.map +1 -1
  97. package/lib/typescript/lib/commonjs/Components/Themed.d.ts.map +1 -1
  98. package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts +40 -1
  99. package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts.map +1 -1
  100. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
  101. package/lib/typescript/lib/commonjs/Discord/api/index.d.ts +9 -0
  102. package/lib/typescript/lib/commonjs/Discord/api/index.d.ts.map +1 -0
  103. package/lib/typescript/lib/commonjs/Discord/index.d.ts +11 -0
  104. package/lib/typescript/lib/commonjs/Discord/index.d.ts.map +1 -0
  105. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts +3 -1
  106. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts.map +1 -1
  107. package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts +2 -0
  108. package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts.map +1 -1
  109. package/lib/typescript/lib/commonjs/FlashMarket/components/FlashOptionCard.d.ts +13 -0
  110. package/lib/typescript/lib/commonjs/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
  111. package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts +9 -0
  112. package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
  113. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts +2 -1
  114. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts.map +1 -1
  115. package/lib/typescript/lib/commonjs/Group/api/index.d.ts.map +1 -1
  116. package/lib/typescript/lib/commonjs/Group/index.d.ts +2 -1
  117. package/lib/typescript/lib/commonjs/Group/index.d.ts.map +1 -1
  118. package/lib/typescript/lib/commonjs/Poll/api/index.d.ts.map +1 -1
  119. package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
  120. package/lib/typescript/lib/commonjs/constants/useColors.d.ts +1 -0
  121. package/lib/typescript/lib/commonjs/constants/useColors.d.ts.map +1 -1
  122. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  123. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  124. package/lib/typescript/lib/module/Components/BETimePicker.d.ts +8 -0
  125. package/lib/typescript/lib/module/Components/BETimePicker.d.ts.map +1 -0
  126. package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
  127. package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
  128. package/lib/typescript/lib/module/Components/ImageUploader.d.ts +2 -1
  129. package/lib/typescript/lib/module/Components/ImageUploader.d.ts.map +1 -1
  130. package/lib/typescript/lib/module/Components/Slider.d.ts +2 -1
  131. package/lib/typescript/lib/module/Components/Slider.d.ts.map +1 -1
  132. package/lib/typescript/lib/module/Components/Themed.d.ts.map +1 -1
  133. package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts +41 -1
  134. package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts.map +1 -1
  135. package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
  136. package/lib/typescript/lib/module/Discord/api/index.d.ts +8 -0
  137. package/lib/typescript/lib/module/Discord/api/index.d.ts.map +1 -0
  138. package/lib/typescript/lib/module/Discord/index.d.ts +11 -0
  139. package/lib/typescript/lib/module/Discord/index.d.ts.map +1 -0
  140. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts +3 -1
  141. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts.map +1 -1
  142. package/lib/typescript/lib/module/FlashMarket/api/index.d.ts +2 -0
  143. package/lib/typescript/lib/module/FlashMarket/api/index.d.ts.map +1 -1
  144. package/lib/typescript/lib/module/FlashMarket/components/FlashOptionCard.d.ts +13 -0
  145. package/lib/typescript/lib/module/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
  146. package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts +9 -0
  147. package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
  148. package/lib/typescript/lib/module/FlashMarket/index.d.ts +2 -1
  149. package/lib/typescript/lib/module/FlashMarket/index.d.ts.map +1 -1
  150. package/lib/typescript/lib/module/Group/api/index.d.ts.map +1 -1
  151. package/lib/typescript/lib/module/Group/index.d.ts +2 -1
  152. package/lib/typescript/lib/module/Group/index.d.ts.map +1 -1
  153. package/lib/typescript/lib/module/Poll/api/index.d.ts.map +1 -1
  154. package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
  155. package/lib/typescript/lib/module/constants/useColors.d.ts +1 -0
  156. package/lib/typescript/lib/module/constants/useColors.d.ts.map +1 -1
  157. package/lib/typescript/lib/module/index.d.ts +3 -1
  158. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  159. package/lib/typescript/src/Components/BETimePicker.d.ts +11 -0
  160. package/lib/typescript/src/Components/BETimePicker.d.ts.map +1 -0
  161. package/lib/typescript/src/Components/Icons.d.ts +1 -0
  162. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  163. package/lib/typescript/src/Components/ImageUploader.d.ts +2 -1
  164. package/lib/typescript/src/Components/ImageUploader.d.ts.map +1 -1
  165. package/lib/typescript/src/Components/Slider.d.ts +2 -1
  166. package/lib/typescript/src/Components/Slider.d.ts.map +1 -1
  167. package/lib/typescript/src/Components/Themed.d.ts.map +1 -1
  168. package/lib/typescript/src/CreateEngagement/api/index.d.ts +8 -2
  169. package/lib/typescript/src/CreateEngagement/api/index.d.ts.map +1 -1
  170. package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
  171. package/lib/typescript/src/Discord/api/index.d.ts +9 -0
  172. package/lib/typescript/src/Discord/api/index.d.ts.map +1 -0
  173. package/lib/typescript/src/Discord/index.d.ts +13 -0
  174. package/lib/typescript/src/Discord/index.d.ts.map +1 -0
  175. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts +4 -2
  176. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts.map +1 -1
  177. package/lib/typescript/src/FlashMarket/api/index.d.ts +2 -0
  178. package/lib/typescript/src/FlashMarket/api/index.d.ts.map +1 -1
  179. package/lib/typescript/src/FlashMarket/components/FlashOptionCard.d.ts +15 -0
  180. package/lib/typescript/src/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
  181. package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts +11 -0
  182. package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
  183. package/lib/typescript/src/FlashMarket/index.d.ts +2 -1
  184. package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -1
  185. package/lib/typescript/src/Group/api/index.d.ts +5 -2
  186. package/lib/typescript/src/Group/api/index.d.ts.map +1 -1
  187. package/lib/typescript/src/Group/index.d.ts +3 -2
  188. package/lib/typescript/src/Group/index.d.ts.map +1 -1
  189. package/lib/typescript/src/Poll/api/index.d.ts.map +1 -1
  190. package/lib/typescript/src/Squares/index.d.ts.map +1 -1
  191. package/lib/typescript/src/constants/useColors.d.ts +1 -0
  192. package/lib/typescript/src/constants/useColors.d.ts.map +1 -1
  193. package/lib/typescript/src/index.d.ts +3 -1
  194. package/lib/typescript/src/index.d.ts.map +1 -1
  195. package/package.json +4 -2
  196. package/src/Components/BETimePicker.tsx +77 -0
  197. package/src/Components/Icons.tsx +17 -0
  198. package/src/Components/ImageUploader.tsx +3 -1
  199. package/src/Components/Slider.tsx +3 -1
  200. package/src/Components/Themed.tsx +6 -4
  201. package/src/CreateEngagement/api/index.ts +78 -2
  202. package/src/CreateEngagement/index.tsx +181 -7
  203. package/src/Discord/api/index.ts +57 -0
  204. package/src/Discord/index.tsx +300 -0
  205. package/src/FlashMarket/FlashHolder.tsx +11 -2
  206. package/src/FlashMarket/api/index.ts +24 -1
  207. package/src/FlashMarket/components/FlashOptionCard.tsx +174 -0
  208. package/src/FlashMarket/components/ManageFlashMarket.tsx +766 -0
  209. package/src/FlashMarket/index.tsx +14 -8
  210. package/src/Group/api/index.ts +5 -5
  211. package/src/Group/index.tsx +84 -9
  212. package/src/Poll/api/index.ts +0 -2
  213. package/src/Squares/index.tsx +0 -1
  214. package/src/SquaresManager/index.tsx +1 -1
  215. package/src/constants/useColors.tsx +2 -0
  216. package/src/index.tsx +4 -0
  217. package/src/types.d.ts +23 -2
@@ -0,0 +1,300 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, View } from "../Components/Themed"
3
+ import { DiscordPlayerApi } from './api';
4
+ import type { DiscordPlayerProps } from '../types';
5
+ import { FlatList, Image, type ViewStyle } from 'react-native';
6
+ import { Icons, Toggle } from '../Components';
7
+ import { useColors } from '../constants/useColors';
8
+ import * as Clipboard from 'expo-clipboard';
9
+
10
+ type DiscordConnectionManagerProps = {
11
+ player_id?:string,
12
+ refresh_key?:string,
13
+ header_style?:ViewStyle,
14
+ float?:boolean,
15
+ footer_style?:ViewStyle,
16
+ onRequestAuthenticate: () => void
17
+ }
18
+
19
+ const sections = ['header','toggle', 'logo', 'success', 'step_1','step_2','step_3']
20
+ const DiscordConnectionManager = ({ player_id, refresh_key, header_style, footer_style, float, onRequestAuthenticate }:DiscordConnectionManagerProps) => {
21
+ const Colors = useColors();
22
+ const [ state, setState ] = useState<{
23
+ loading:boolean,
24
+ discord_player?:DiscordPlayerProps,
25
+ active_step:string
26
+ }>({
27
+ loading: false,
28
+ active_step: 'step_1'
29
+ });
30
+ const { loading, discord_player, active_step } = state;
31
+
32
+ useEffect(() => {
33
+ DiscordPlayerApi.setEnvironment();
34
+ if(!player_id){ return onRequestAuthenticate() }
35
+ getData();
36
+ },[player_id, refresh_key]);
37
+
38
+ const getData = async() => {
39
+ setState({ ...state, loading:true });
40
+ const dp = await DiscordPlayerApi.getMyDiscordConnection();
41
+ if(!dp){ return alert('Unable to get your connection status') }
42
+ const step = dp.status == 'inactive' ? 'step_1' : dp.status == 'requested' ? 'step_2' : dp.status == 'pending' ? 'step_3' : 'step_1'
43
+ setState({
44
+ ...state,
45
+ loading:false,
46
+ discord_player: dp,
47
+ active_step: step
48
+ });
49
+ }
50
+
51
+ const handleStartConnection = async() => {
52
+ if(loading){ return }
53
+ setState({ ...state, loading:true });
54
+ const dp = await DiscordPlayerApi.startConnnection();
55
+ if(!dp){
56
+ alert('Unable to process at this time. Please try again')
57
+ getData();
58
+ return
59
+ }
60
+ setState({
61
+ ...state,
62
+ discord_player: dp,
63
+ active_step: 'step_2',
64
+ loading:false
65
+ });
66
+ }
67
+
68
+ const handleConfirmConnection = async() => {
69
+ if(loading){ return }
70
+ setState({ ...state, loading:true });
71
+ const dp = await DiscordPlayerApi.confirmConnection();
72
+ if(!dp){
73
+ alert('Unable to process at this time. Please try again')
74
+ getData();
75
+ return
76
+ }
77
+ setState({
78
+ ...state,
79
+ discord_player: dp,
80
+ loading:false
81
+ });
82
+ }
83
+
84
+ const handleDisconnect = async() => {
85
+ if(loading){ return }
86
+ setState({ ...state, loading:true });
87
+ const dp = await DiscordPlayerApi.disconnect();
88
+ if(!dp){
89
+ alert('Unable to process at this time. Please try again')
90
+ getData();
91
+ return
92
+ }
93
+ setState({
94
+ ...state,
95
+ discord_player: dp,
96
+ loading:false
97
+ });
98
+ }
99
+
100
+
101
+ const renderSections = (data:{item:string, index:number}) => {
102
+ switch(data.item){
103
+ case 'header':
104
+ return (
105
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, ...header_style }}>
106
+ <Image
107
+ source={{ uri: 'https://res.cloudinary.com/hoabts6mc/image/upload/v1758212751/discord_xkfzgw.jpg' }}
108
+ style={{ height:40, width:40 }}
109
+ resizeMode='contain'
110
+ />
111
+ <View transparent style={{ flex:1, marginLeft:10 }}>
112
+ <Text theme='h1'>Connect Your Discord!</Text>
113
+ <Text theme='description'>Follow the instructions below to authenticate discord with your account</Text>
114
+ </View>
115
+ <Button float style={{ padding:10 }} onPress={() => getData()}>
116
+ <Icons.RefreshIcon size={18} color={Colors.text.h1}/>
117
+ </Button>
118
+ </View>
119
+ )
120
+ case 'toggle':
121
+ if(discord_player?.status == 'active'){ return <></> }
122
+ return (
123
+ <View style={{padding:10}}>
124
+ <Toggle
125
+ options={[
126
+ { key: 'step_1', label: 'Step 1' },
127
+ { key: 'step_2', label: 'Step 2' },
128
+ { key: 'step_3', label: 'Step 3' }
129
+ ]}
130
+ selected_option={active_step}
131
+ onSelectOption={(step) => setState({ ...state, active_step:step })}
132
+ />
133
+ </View>
134
+ )
135
+ case 'success':
136
+ if(discord_player?.status != 'active'){ return <></> }
137
+ return (
138
+ <View style={{ padding:10 }}>
139
+ <View float style={{ padding:2, backgroundColor: '#7289da', borderRadius:100, alignSelf:'center' }}>
140
+ {discord_player.image?
141
+ <Image
142
+ source={{ uri: discord_player.image.url }}
143
+ style={{ height:125, width:125, borderRadius:100 }}
144
+ resizeMode='cover'
145
+ />
146
+ :
147
+ <Image
148
+ source={{ uri: 'https://res.cloudinary.com/hoabts6mc/image/upload/v1758213727/discord-logo_zsufoi.png' }}
149
+ style={{ height:125, width:125, borderRadius:100 }}
150
+ resizeMode='cover'
151
+ />
152
+ }
153
+ </View>
154
+ <View float style={{ marginTop:40}}>
155
+ <View transparent style={{ flexDirection:'row', alignItems:'center', padding:10}}>
156
+ {discord_player.image?
157
+ <Image
158
+ source={{ uri: discord_player.image.url }}
159
+ style={{ height:50, width:50, borderRadius:100 }}
160
+ resizeMode='cover'
161
+ />
162
+ :
163
+ <Image
164
+ source={{ uri: 'https://res.cloudinary.com/hoabts6mc/image/upload/v1758213727/discord-logo_zsufoi.png' }}
165
+ style={{ height:50, width:50, borderRadius:100 }}
166
+ resizeMode='cover'
167
+ />
168
+ }
169
+ <View transparent style={{ flex:1, marginLeft:10, marginRight:10 }}>
170
+ <Text theme='h1' size={18}>@{discord_player.username}</Text>
171
+ <Text theme='success' style={{ marginTop:5 }}>CONNECTED</Text>
172
+ </View>
173
+ <Icons.CheckCirlceIcon color={Colors.text.success} size={20} />
174
+ </View>
175
+ </View>
176
+ </View>
177
+ )
178
+ case 'logo':
179
+ if(discord_player?.status == 'active'){ return <></> }
180
+ return (
181
+ <View transparent style={{ flexDirection:'row', paddingLeft:10, paddingRight:10 }}>
182
+ {active_step == 'step_2' ?
183
+ <View style={{ flex:1 }} />
184
+ :active_step == 'step_3' ?
185
+ <View style={{ flex:2 }} />
186
+ :<></>}
187
+ <View style={{ flex:1, justifyContent:'center', alignItems:'center' }}>
188
+ <View float style={{ padding:10, backgroundColor: '#7289da', borderRadius:100 }}>
189
+ <Image
190
+ source={{ uri: 'https://res.cloudinary.com/hoabts6mc/image/upload/v1758213727/discord-logo_zsufoi.png' }}
191
+ style={{ height:50, width:50, borderRadius:100 }}
192
+ resizeMode='cover'
193
+ />
194
+ </View>
195
+ </View>
196
+ {active_step == 'step_1' ?
197
+ <View style={{ flex:2 }} />
198
+ :active_step == 'step_2' ?
199
+ <View style={{ flex:1 }} />
200
+ :<></>}
201
+ </View>
202
+ )
203
+ case 'step_1':
204
+ if(active_step != 'step_1'){ return <></> }
205
+ if(discord_player && discord_player.status == 'active'){ return <></> }
206
+ return (
207
+ <View float style={{ padding:20, margin:10, justifyContent:'center', alignItems:'center' }}>
208
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Press Start Connection below</Text>
209
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>You’ll get a temporary code valid for 10 minutes</Text>
210
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Keep this code handy—you’ll need it in Discord</Text>
211
+ </View>
212
+ )
213
+ case 'step_2':
214
+ if(active_step != 'step_2' || !discord_player){ return <></> }
215
+ if(discord_player?.status == 'active'){ return <></> }
216
+ return (
217
+ <View float style={{ padding:20, margin:10, justifyContent:'center', alignItems:'center' }}>
218
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Open Discord where the bot is installed.</Text>
219
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Use the slash command{'\n'} /connect {discord_player.auth_code}</Text>
220
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Make sure to enter the code exactly as shown. It will expire in 10 minutes</Text>
221
+ </View>
222
+ )
223
+ case 'step_3':
224
+ if(active_step != 'step_3' || !discord_player){ return <></> }
225
+ if(discord_player?.status == 'active'){ return <></> }
226
+ return (
227
+ <View float style={{ padding:20, margin:10, justifyContent:'center', alignItems:'center' }}>
228
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Once Validated, you can confirm the connection</Text>
229
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Press confirm connection below.</Text>
230
+ <Text theme='h1' size={20} style={{ marginTop:20 }} textAlign='center'>Once confirmed, you can use authenticated commands in descord!</Text>
231
+ </View>
232
+ )
233
+ default: return <></>
234
+ }
235
+ }
236
+
237
+ return (
238
+ <View float={float} style={{ flex:1 }}>
239
+ <FlatList
240
+ data={sections}
241
+ key={'discord_connection_sections'}
242
+ keyExtractor={item => item}
243
+ renderItem={renderSections}
244
+ />
245
+ {discord_player ?
246
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, ...footer_style }}>
247
+ {discord_player.status == 'inactive' ?
248
+ <Button
249
+ title='START CONNECTION'
250
+ title_color={Colors.text.white}
251
+ backgroundColor='#7289da'
252
+ loading={loading}
253
+ style={{ flex:1 }}
254
+ onPress={() => handleStartConnection()}
255
+ />
256
+ :discord_player.status == 'requested' ?
257
+ <Button
258
+ type='text'
259
+ loading={loading}
260
+ style={{ flex:1, alignItems:'center', justifyContent:'center' }}
261
+ onPress={async() => {
262
+ if(!discord_player.auth_code){ return }
263
+ await Clipboard.setStringAsync(discord_player.auth_code)
264
+ alert('Code copied to clipboard')
265
+ }}>
266
+ <Text theme='action' size={14}>Press to Copy: {discord_player.auth_code}</Text>
267
+ </Button>
268
+ :discord_player.status == 'pending' ?
269
+ <Button
270
+ title='CONFIRM CONNECTION'
271
+ type='success'
272
+ loading={loading}
273
+ style={{ flex:1 }}
274
+ onPress={() => handleConfirmConnection()}
275
+ />
276
+ :discord_player.status == 'active'?
277
+ <Button
278
+ title='DISCONNECT'
279
+ type='error'
280
+ loading={loading}
281
+ style={{ flex:1 }}
282
+ onPress={() => handleDisconnect()}
283
+ />
284
+ :<></>}
285
+ </View>
286
+ :
287
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, ...footer_style }}>
288
+ <Button
289
+ type='success'
290
+ style={{ flex:1 }}
291
+ title='LOG IN FIRST'
292
+ onPress={() => onRequestAuthenticate()}
293
+ />
294
+ </View>
295
+ }
296
+ </View>
297
+ )
298
+ }
299
+
300
+ export default DiscordConnectionManager
@@ -21,6 +21,7 @@ type FlashHolderProps = {
21
21
  contest_type?:string,
22
22
  parent_style?:ViewStyle,
23
23
  hide_footer?:boolean,
24
+ poll_campaign_id?:string,
24
25
  contest_id?:string,
25
26
  hide_tabs?:boolean,
26
27
  style?:ViewStyle,
@@ -31,13 +32,14 @@ type FlashHolderProps = {
31
32
  side_id?:string,
32
33
  default_poll_id?:string,
33
34
  poll_id?:string,
35
+ onManageFlash?: (poll:PollProps) => void,
34
36
  onSelectCompactPoll?:(poll_id:string) => void,
35
37
  onRequestLocation:() => void,
36
38
  onFocusPosition?: (position:{ x:number, y:number, width:number, height:number }) => void,
37
39
  onRequestAuthenticate: () => void
38
40
  }
39
41
  const sections = [ 'selector','explainer','flash_market','options','footer' ]
40
- const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_timer, distinct_id, hide_footer, no_highlight, hide_tabs, parent_style, league_id, init_expanded, player_id, player, location, contest_type, contest_id, side_type, side_id, poll_id, onSelectCompactPoll, onRequestAuthenticate, onFocusPosition, onRequestLocation } : FlashHolderProps) => {
42
+ const FlashHolder = ({ float, poll_campaign_id, company_id, compact, style, default_poll_id, hide_timer, distinct_id, hide_footer, no_highlight, hide_tabs, parent_style, league_id, init_expanded, player_id, player, location, contest_type, contest_id, side_type, side_id, poll_id, onSelectCompactPoll, onRequestAuthenticate, onFocusPosition, onRequestLocation, onManageFlash } : FlashHolderProps) => {
41
43
  const Colors = useColors();
42
44
  const [ needs_reload, setNeedsReload ] = useState(false);
43
45
  const [ socket_campaigns, setSocketCampaigns ] = useState<PollCampaignProps[]>([]);
@@ -77,7 +79,7 @@ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_
77
79
  const [ active_flash_market, setActiveFlashMarket ] = useState<string | undefined>(undefined);
78
80
  const flash_market = flash_markets.find(fm => fm.poll_id == active_flash_market);
79
81
  const sorted_flashes = flash_markets.sort((a,b) => moment(a.end_datetime).unix() - moment(b.end_datetime).unix() || parseInt(a.poll_id) - parseInt(b.poll_id))
80
-
82
+
81
83
  useEffect(() => {
82
84
  loadData();
83
85
  },[league_id, contest_type, contest_id, side_type, side_id, poll_id]);
@@ -167,6 +169,12 @@ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_
167
169
  return handleSelectPoll(poll_id, options);
168
170
  }
169
171
 
172
+ if(poll_campaign_id){
173
+ let resp = await FlashMarketApi.getPollsByCampaignId(poll_campaign_id);
174
+ let active_polls = resp.filter(p => p.status != 'closed');
175
+ setFlashData({ ...flash_data, loaded:true, holder_loading: false, flash_markets:active_polls })
176
+ }
177
+
170
178
  let found_polls:PollProps[] = []
171
179
  if(company_id){
172
180
  let resp = await FlashMarketApi.getActiveMarkets(company_id);
@@ -301,6 +309,7 @@ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_
301
309
  header_style={{ borderTopRightRadius:0, borderTopLeftRadius:0 }}
302
310
  onReload={() => loadMarket(active_flash_market)}
303
311
  onRequestAuthenticate={onRequestAuthenticate}
312
+ onManageFlash={onManageFlash}
304
313
  onRequestLocation={onRequestLocation}
305
314
  onFocusPosition={onFocusPosition}
306
315
  />
@@ -29,6 +29,14 @@ const FlashMarketApi = {
29
29
  return undefined
30
30
  }
31
31
  },
32
+ getPollsByCampaignId: async(poll_campaign_id:string):Promise<PollProps[]> => {
33
+ try {
34
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/campaign/${poll_campaign_id}`);
35
+ return resp.data.polls
36
+ } catch (e) {
37
+ return []
38
+ }
39
+ },
32
40
  getActiveFlashMarkets: async():Promise<PollProps[]> => {
33
41
  try {
34
42
  const resp = await axios.get(`${AUTH_SVC_API}/v2/pm/flash/active`);
@@ -107,7 +115,22 @@ export const FlashMarketHelpers = {
107
115
  toWin: (stake:number, parimutuel_odds?:number):number => {
108
116
  if(!parimutuel_odds){ return 0 }
109
117
  return stake / parimutuel_odds
110
-
118
+ },
119
+ isNewValid: (options:PollOptionProps[], summaries:PollSummaryProps[], poll?:PollProps) => {
120
+ let errors:string[] = []
121
+ if(!poll){ return ['Waiting for market'] }
122
+ options.map(o => !o.option_name ? errors.push('Option must have a valid name') : console.log(''))
123
+ if(options.length <= 1){ errors.push('Need at least 2 options') }
124
+ let total_prob = options.reduce((a,b) => a + (b.initial_odds ?? 0), 0);
125
+ let total_stake = summaries.reduce((a,b) => a + b.count, 0)
126
+ if(!poll.poll_question){ errors.push('Please enter a question') }
127
+ if(poll.max_stake < 1){ errors.push('Max stake must be at least $1') }
128
+ if(poll.minimum_stake < 0.1){ errors.push('Min stake must be greater than 10 cents') }
129
+ if(moment().isAfter(moment(poll.end_datetime))){ errors.push('Market close time is in the past') }
130
+ if(poll.status != 'pending'){ errors.push('Only pending markets can be activated') }
131
+ if(total_stake > 0){ errors.push('Cannot activate with existing responses') }
132
+ if(total_prob.toFixed(2) != '1.00'){ errors.push('Initial probabilities do not add to 1') }
133
+ return errors
111
134
  },
112
135
  getResponseStats: (option:PollOptionProps, poll_response?:PollResponseProps) => {
113
136
  let empty_reponse = { stake: 0, potential_winnings: 0, winnings: 0, earnings:0 }
@@ -0,0 +1,174 @@
1
+ import React from 'react';
2
+ import { useEffect, useState } from "react"
3
+ import type { PollOptionProps, PollProps, PollSummaryProps } from "../../types"
4
+ import { Button, Text, TextInput, View } from "../../Components/Themed"
5
+ import { PollOptionApi } from '../../Poll/api';
6
+ import { useColors } from '../../constants/useColors';
7
+ import { Checkbox, Icons } from '../../Components';
8
+ import Slider from '../../Components/Slider';
9
+ import { MarketComponentHelpers } from '../../MarketComponents/api';
10
+
11
+ type FlashOptionCardProps = {
12
+ poll:PollProps,
13
+ poll_option: PollOptionProps,
14
+ probability_locked?:boolean,
15
+ summary:PollSummaryProps,
16
+ onUpdateOption:(poll_option:PollOptionProps) => void,
17
+ onLockProbability:(locked:boolean) => void,
18
+ onChangeProbability: (probability:number) => void,
19
+ onSelectWinningOption: (checked:boolean, option:PollOptionProps) => void
20
+ }
21
+
22
+ const FlashOptionCard = ({ poll, poll_option, probability_locked, summary, onUpdateOption, onLockProbability, onChangeProbability, onSelectWinningOption }:FlashOptionCardProps) => {
23
+ const Colors = useColors();
24
+ const [ size, setSize ] = useState({ width: 0 });
25
+ const [ state, setState ] = useState<{
26
+ action_loading:boolean,
27
+ draft_option:PollOptionProps
28
+ }>({
29
+ action_loading: false,
30
+ draft_option: poll_option
31
+ });
32
+ const { action_loading, draft_option } = state;
33
+ const delete_allowed = poll.status == 'pending' ? true : false
34
+ const probability = (poll_option.initial_odds ?? 0) * 100
35
+ const probability_label = `${probability.toFixed(2)}%`
36
+ const odds_label = MarketComponentHelpers.getOddsLabel(MarketComponentHelpers.calcAmericanOddsFromProbability(probability / 100))
37
+ const label_left = probability < 15 ? probability + 40 : 0
38
+ const summary_width = summary.pct * size.width
39
+ useEffect(() => {
40
+ setState({ ...state, draft_option: poll_option });
41
+ },[JSON.stringify(poll_option)]);
42
+
43
+ const updateOption = async(po:PollOptionProps) => {
44
+ if(action_loading){ return }
45
+ setState({ ...state, action_loading: true });
46
+ const new_option = await PollOptionApi.updatePollOption(po);
47
+ if(!new_option){ alert('Unabel to update'); setState({ ...state, action_loading: false }); return }
48
+ setState({
49
+ ...state,
50
+ action_loading: false
51
+ });
52
+ onUpdateOption(new_option)
53
+ }
54
+
55
+ const handleManualTimeChange = async(val:number) => {
56
+ //updat manual time!!
57
+ onChangeProbability(val / 100);
58
+ }
59
+
60
+ const is_changed = JSON.stringify(poll_option) != JSON.stringify(draft_option) ? true : false
61
+ const is_winning_option = poll_option.result_ind == 'win' ? true : false
62
+ return (
63
+ <View style={{ padding:2 }}>
64
+ <View type='row'>
65
+ {['paused','active'].includes(poll.status) ?
66
+ <Checkbox
67
+ style={{ marginRight:10 }}
68
+ color={is_winning_option ? Colors.text.success : Colors.text.h1}
69
+ checked={is_winning_option}
70
+ onSelect={(checked) => onSelectWinningOption(checked, poll_option)}
71
+ />
72
+ :<></>}
73
+ <View transparent style={{flex:1}}>
74
+ <TextInput
75
+ value={draft_option.option_name}
76
+ editable={poll.status == 'pending' ? true : false}
77
+ onSubmitEditing={() => {
78
+ if(!is_changed){ return }
79
+ updateOption(draft_option)
80
+ }}
81
+ style={{ borderColor:draft_option.option_name ? Colors.text.success: Colors.text.warning }}
82
+ placeholder={`Option ${draft_option.priority}`}
83
+ onChangeText={(text) => setState({ ...state, draft_option: { ...draft_option, option_name: text } })}
84
+ />
85
+ {summary.pct > 0 ?
86
+ <View type='blur' style={{ position:'absolute', top:0, left:0, bottom:0, width: summary_width, backgroundColor:'rgba(125, 205, 133, 0.3)' }} />
87
+ :<></>}
88
+ </View>
89
+
90
+ {is_changed ?
91
+ <Button
92
+ title='SAVE'
93
+ style={{ padding:10, marginLeft:5, opacity: action_loading ? 0.5: 1 }}
94
+ disabled={action_loading}
95
+ type='success'
96
+ loading={action_loading}
97
+ onPress={() => updateOption(draft_option)}
98
+ />
99
+ : delete_allowed ?
100
+ <Button
101
+ title='X'
102
+ transparent
103
+ loading={action_loading}
104
+ title_color={Colors.text.error}
105
+ style={{ padding:10, marginLeft:5 }}
106
+ onPress={() => updateOption({ ...draft_option, status: 'inactive' })}
107
+ />
108
+ :<></>}
109
+ </View>
110
+ {poll.status == 'pending' ?
111
+ <View style={{ padding:10, flexDirection:'row', alignItems:'center' }}>
112
+ <Button
113
+ transparent
114
+ style={{ padding:0, height:35, width:35, borderRadius:100, justifyContent:'center', alignItems:'center' }}
115
+ onPress={() => onLockProbability(!poll_option.probability_locked)}
116
+ >
117
+ {poll_option.probability_locked ?
118
+ <Icons.LockClosedIcon size={20} color={Colors.text.h1} />
119
+ :
120
+ <Icons.LockOpenIcon size={24} color={Colors.text.success} />
121
+ }
122
+ </Button>
123
+ <Button
124
+ title='-'
125
+ title_color={Colors.text.error}
126
+ float
127
+ disabled={poll_option.probability_locked || probability <= 0.2 ? true : false}
128
+ style={{ padding:0, height:35, width:35, borderRadius:100, justifyContent:'center', alignItems:'center' }}
129
+ onPress={() => onChangeProbability((probability / 100) - 0.005)}
130
+ />
131
+ <View style={{ flex:1, marginLeft:5, marginRight:5 }} onLayout={(ev) => {
132
+ const { width } = ev.nativeEvent.layout;
133
+ setSize({ width })
134
+ }}>
135
+ <Slider
136
+ width={size.width}
137
+ value={probability}
138
+ minimum_value={0}
139
+ disabled={poll_option.probability_locked || probability_locked}
140
+ minimum_track_tint={Colors.text.success}
141
+ maximum_track_tint={Colors.text.h1}
142
+ thumb_tint_color={Colors.text.success}
143
+ maximum_value={100}
144
+ onSlidingStart={() => console.log('started')}
145
+ //onSlidingStart={() => handleStartSliding()}
146
+ onSlidingComplete={(val) => handleManualTimeChange(val)}
147
+ />
148
+ <Text theme='description' style={{ position:'absolute', left:label_left, bottom:-5 }}>{probability_label} ({odds_label})</Text>
149
+ </View>
150
+
151
+ <Button
152
+ title='+'
153
+ title_color={Colors.text.success}
154
+ float
155
+ disabled={poll_option.probability_locked || probability >= 99 ? true : false}
156
+ style={{ padding:0, height:35, width:35, borderRadius:100, justifyContent:'center', alignItems:'center' }}
157
+ onPress={() => onChangeProbability((probability / 100) + 0.005)}
158
+ />
159
+ </View>
160
+ :
161
+ <View style={{ flex:1, flexDirection:'row', alignItems:'center', marginTop:3}} onLayout={(ev) => {
162
+ const { width } = ev.nativeEvent.layout;
163
+ setSize({ width: width -100 })
164
+ }}>
165
+ <Text theme='description' textAlign='left'>{(summary.pct * 100).toFixed(2)}%</Text>
166
+ <View transparent style={{ flex:1 }} />
167
+ <Text theme='description' textAlign='right'>{summary.count} Responses</Text>
168
+ </View>
169
+ }
170
+ </View>
171
+ )
172
+ }
173
+
174
+ export default FlashOptionCard