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,1214 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, TextInput, View } from "../../Components/Themed";
3
+ import { FlatList, Image } from 'react-native';
4
+ import { Icons, Switch, Toggle } from '../../Components';
5
+ import { PollApi, PollCampaignApi, PollOptionApi } from '../../Poll/api';
6
+ import ImageUploader from '../../Components/ImageUploader';
7
+ import { useColors } from '../../constants/useColors';
8
+ import FlashOptionCard from './FlashOptionCard';
9
+ import moment from 'moment-mini';
10
+ import BETimePicker from '../../Components/BETimePicker';
11
+ import { FlashMarketHelpers } from '../api';
12
+ import { showConfirmAlert } from '../../Components/ConfirmAlert';
13
+ const sections = ['header', 'activate', 'pause_resume', 'closed', 'resolve', 'toggle', 'image', 'question', 'options', 'settings', 'results'];
14
+ const ManageFlashMarket = ({
15
+ player,
16
+ onClose,
17
+ poll_id,
18
+ onFocusPosition
19
+ }) => {
20
+ const Colors = useColors();
21
+ const [labels, setLabels] = useState({
22
+ base_stake: '0',
23
+ min_stake: '0',
24
+ max_stake: '0'
25
+ });
26
+ const {
27
+ min_stake,
28
+ max_stake,
29
+ base_stake
30
+ } = labels;
31
+ const [expand_participants, setExpandParticipants] = useState(false);
32
+ const [flash_state, setFlashState] = useState({
33
+ loading: false,
34
+ action_loading: false,
35
+ probability_changed: false,
36
+ active_step: 'settings',
37
+ players: [],
38
+ poll_summaries: [],
39
+ poll_options: []
40
+ });
41
+ const {
42
+ loading,
43
+ action_loading,
44
+ poll_options,
45
+ players,
46
+ active_step,
47
+ poll,
48
+ draft_poll,
49
+ poll_summaries,
50
+ probability_changed
51
+ } = flash_state;
52
+ const real_options = poll_options.filter(o => o.status != 'inactive');
53
+ const total_responses = poll_summaries.reduce((a, b) => a + b.count, 0);
54
+ const unlocked_options = real_options.filter(o => !o.probability_locked);
55
+ const prob_locked = unlocked_options.length <= 1 ? true : false;
56
+ const errors = FlashMarketHelpers.isNewValid(real_options, poll_summaries, poll);
57
+ const winning_option = real_options.find(o => o.poll_option_id == poll?.winning_option_id);
58
+ useEffect(() => {
59
+ PollCampaignApi.setEnvironment();
60
+ if (!poll_id) {
61
+ return;
62
+ }
63
+ getData(poll_id);
64
+ }, [poll_id]);
65
+ const getData = async id => {
66
+ setFlashState({
67
+ ...flash_state,
68
+ loading: true
69
+ });
70
+ const server_response = await PollApi.getPollById(id);
71
+ const server_campaign = await PollCampaignApi.getPollCampaignById(server_response.poll.poll_campaign_id);
72
+ let player_ids = [];
73
+ server_response.poll_summaries.map(s => {
74
+ s.player_ids.map(id => id != '4985' ? player_ids.push(id) : console.log(''));
75
+ });
76
+ const server_players = await PollCampaignApi.getPlayersByPlayerIds([...new Set(player_ids.map(id => id))]);
77
+ setFlashState({
78
+ ...flash_state,
79
+ poll: server_response.poll,
80
+ poll_options: server_response.poll_options,
81
+ draft_poll: server_response.poll,
82
+ poll_summaries: server_response.poll_summaries,
83
+ poll_campaign: server_campaign,
84
+ players: server_players,
85
+ loading: false
86
+ });
87
+ setLabels({
88
+ min_stake: server_response.poll.minimum_stake.toString(),
89
+ max_stake: server_response.poll.max_stake.toString(),
90
+ base_stake: server_response.poll.base_stake?.toString() ?? '0'
91
+ });
92
+ };
93
+ const updatePoll = async dp => {
94
+ if (action_loading) {
95
+ return;
96
+ }
97
+ setFlashState({
98
+ ...flash_state,
99
+ action_loading: true
100
+ });
101
+ const new_resp = await PollApi.updatePoll(dp);
102
+ if (!new_resp) {
103
+ return alert('Unable to update');
104
+ }
105
+ setFlashState({
106
+ ...flash_state,
107
+ action_loading: false,
108
+ poll: new_resp.poll,
109
+ draft_poll: new_resp.poll,
110
+ poll_options: new_resp.poll_options
111
+ });
112
+ };
113
+ const handleSelectWinningOption = (checked, option) => {
114
+ if (!poll) {
115
+ return alert('Unable to process');
116
+ }
117
+ if (checked) {
118
+ showConfirmAlert('Are you sure', `Confirm ${option.option_name} is the correct answer`, () => updatePoll({
119
+ ...poll,
120
+ winning_option_id: option.poll_option_id,
121
+ status: 'paused'
122
+ }), () => console.log(''));
123
+ } else {
124
+ if (!poll.winning_option_id) {
125
+ return;
126
+ }
127
+ showConfirmAlert('Are you sure', `Remove ${option.option_name} as the correct answer`, () => updatePoll({
128
+ ...poll,
129
+ winning_option_id: undefined
130
+ }), () => console.log(''));
131
+ }
132
+ };
133
+ const handleChangeProbability = (option, probability) => {
134
+ if (option.probability_locked) {
135
+ return;
136
+ }
137
+ if (probability < 0) {
138
+ return;
139
+ }
140
+ if (probability > 1) {
141
+ return;
142
+ }
143
+ let other_options = [...real_options.filter(o => o.poll_option_id != option.poll_option_id)];
144
+ //Find the min probability
145
+
146
+ //Other option probabilities
147
+ let other_option_probabilities = other_options.reduce((a, b) => a + (b.initial_odds ?? 0), 0);
148
+ //With new probabilities
149
+ let all_probs = other_option_probabilities + probability;
150
+ let difference = 1 - all_probs;
151
+ let unlocked_options = other_options.filter(po => !po.probability_locked);
152
+ if (unlocked_options.length == 0) {
153
+ return;
154
+ } //There are no options!
155
+
156
+ let new_option = {
157
+ ...option,
158
+ initial_odds: probability
159
+ };
160
+ //what is the current total probability
161
+ let delta = difference / unlocked_options.length;
162
+ //Map through the others and update those
163
+
164
+ let min_option = unlocked_options.reduce((min, item) => {
165
+ let item_init = item.initial_odds ?? 0;
166
+ let min_init = min.initial_odds ?? 0;
167
+ if (item_init < min_init) {
168
+ return item;
169
+ } else {
170
+ return min;
171
+ }
172
+ });
173
+ let max_option = unlocked_options.reduce((min, item) => {
174
+ let item_init = item.initial_odds ?? 0;
175
+ let min_init = min.initial_odds ?? 0;
176
+ if (item_init > min_init) {
177
+ return item;
178
+ } else {
179
+ return min;
180
+ }
181
+ });
182
+ let new_delta = delta;
183
+ if (delta < 0) {
184
+ //Make sure our min has enough room
185
+ let min_diff = (min_option.initial_odds ?? 0) + delta;
186
+ if (min_diff < 0) {
187
+ new_delta = min_option.initial_odds ?? 0;
188
+ }
189
+ } else {
190
+ let max_diff = (max_option.initial_odds ?? 0) + delta;
191
+ if (max_diff > 1) {
192
+ new_delta = 1 - (max_option.initial_odds ?? 0);
193
+ }
194
+ }
195
+ let delta_difference = new_delta - delta;
196
+ if (delta_difference != 0) {
197
+ return;
198
+ }
199
+ let failed = false;
200
+ other_options = other_options.map(o => {
201
+ if (o.probability_locked) {
202
+ return o;
203
+ }
204
+ let starting_odds = o.initial_odds ?? 0;
205
+ let new_odds = starting_odds + delta;
206
+ if (new_odds < 0) {
207
+ failed = true;
208
+ }
209
+ if (new_odds > 1) {
210
+ failed = true;
211
+ }
212
+ o.initial_odds = new_odds;
213
+ return o;
214
+ });
215
+ if (failed) {
216
+ return;
217
+ }
218
+ let final_options = other_options.concat(new_option);
219
+ //let check it
220
+ let total_prob = final_options.reduce((a, b) => a + (b.initial_odds ?? 0), 0);
221
+ if (total_prob.toFixed(2) != '1.00') {
222
+ return;
223
+ }
224
+ setFlashState({
225
+ ...flash_state,
226
+ probability_changed: true,
227
+ poll_options: poll_options.filter(po => !final_options.find(fo => fo.poll_option_id == po.poll_option_id)).concat(final_options)
228
+ });
229
+ };
230
+ const renderOptions = data => {
231
+ if (!poll) {
232
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
233
+ }
234
+ const summary = poll_summaries.find(ps => ps.poll_option_id == data.item.poll_option_id);
235
+ if (!summary) {
236
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
237
+ }
238
+ return /*#__PURE__*/React.createElement(View, {
239
+ style: {
240
+ padding: 5
241
+ }
242
+ }, /*#__PURE__*/React.createElement(FlashOptionCard, {
243
+ poll_option: data.item,
244
+ summary: summary,
245
+ poll: poll,
246
+ onSelectWinningOption: handleSelectWinningOption,
247
+ probability_locked: prob_locked,
248
+ onChangeProbability: probability => handleChangeProbability(data.item, probability),
249
+ onLockProbability: locked => {
250
+ setFlashState({
251
+ ...flash_state,
252
+ poll_options: poll_options.filter(po => po.poll_option_id != data.item.poll_option_id).concat({
253
+ ...data.item,
254
+ probability_locked: locked
255
+ })
256
+ });
257
+ },
258
+ onUpdateOption: option => {
259
+ setFlashState({
260
+ ...flash_state,
261
+ poll_options: poll_options.filter(po => po.poll_option_id != option.poll_option_id).concat(option)
262
+ });
263
+ }
264
+ }));
265
+ };
266
+ const handleSaveProbabilities = async () => {
267
+ if (!probability_changed) {
268
+ return;
269
+ }
270
+ if (poll?.status != 'pending') {
271
+ return;
272
+ }
273
+ let total_prob = real_options.reduce((a, b) => a + (b.initial_odds ?? 0), 0);
274
+ if (total_prob.toFixed(2) != '1.00') {
275
+ return;
276
+ }
277
+ setFlashState({
278
+ ...flash_state,
279
+ action_loading: true
280
+ });
281
+ let new_options = [];
282
+ const saveOptions = real_options.map(async o => {
283
+ new_options.push(await PollOptionApi.updatePollOption(o));
284
+ });
285
+ await Promise.all(saveOptions);
286
+ setFlashState({
287
+ ...flash_state,
288
+ poll_options: new_options,
289
+ probability_changed: false
290
+ });
291
+ };
292
+ const handleResolve = () => {
293
+ if (!poll) {
294
+ return;
295
+ }
296
+ if (!winning_option) {
297
+ return;
298
+ }
299
+ showConfirmAlert('Are you sure', `Confirm ${winning_option.option_name} is the correct answer and payout participants`, () => resolveFlashMarket(), () => console.log(''));
300
+ };
301
+ const resolveFlashMarket = async () => {
302
+ if (!poll) {
303
+ return;
304
+ }
305
+ if (!poll.winning_option_id) {
306
+ return;
307
+ }
308
+ setFlashState({
309
+ ...flash_state,
310
+ action_loading: true
311
+ });
312
+ const resolved_poll = await PollApi.closePoll(poll.poll_id);
313
+ if (!resolved_poll) {
314
+ return alert('Unable to activate market at this time');
315
+ }
316
+ setFlashState({
317
+ ...flash_state,
318
+ action_loading: false,
319
+ poll: resolved_poll
320
+ });
321
+ };
322
+ const handleAddOption = async () => {
323
+ if (poll?.status != 'pending') {
324
+ return;
325
+ }
326
+ if (action_loading) {
327
+ return;
328
+ }
329
+ setFlashState({
330
+ ...flash_state,
331
+ action_loading: true
332
+ });
333
+ let length = real_options.length;
334
+ const new_option = await PollOptionApi.createPollOption({
335
+ poll_id: poll.poll_id,
336
+ poll_option_id: '',
337
+ option_name: '',
338
+ initial_odds: length == 0 ? 1 : 0,
339
+ option_value: 'optional',
340
+ response_message: '',
341
+ priority: length + 1,
342
+ create_datetime: '',
343
+ last_update_datetime: '',
344
+ option_type: 'select',
345
+ status: 'pending'
346
+ });
347
+ if (!new_option) {
348
+ setFlashState({
349
+ ...flash_state,
350
+ action_loading: false
351
+ });
352
+ return alert('Unable to process');
353
+ }
354
+ let new_summary = {
355
+ poll_id: poll_id,
356
+ poll_option_id: new_option.poll_option_id,
357
+ count: 0,
358
+ stake: 0,
359
+ winnings: 0,
360
+ player_ids: [],
361
+ pct: 0
362
+ };
363
+ //We have a new option! Now we will need to update the probabilities
364
+ setFlashState({
365
+ ...flash_state,
366
+ action_loading: false,
367
+ poll_options: poll_options.filter(po => po.poll_option_id != new_option.poll_option_id).concat(new_option),
368
+ poll_summaries: poll_summaries.filter(ps => ps.poll_option_id != new_summary.poll_option_id).concat(new_summary)
369
+ });
370
+ };
371
+ const renderPlayers = data => {
372
+ return /*#__PURE__*/React.createElement(View, {
373
+ type: "row",
374
+ style: {
375
+ borderBottomWidth: 1,
376
+ borderColor: Colors.borders.light,
377
+ padding: 10
378
+ }
379
+ }, /*#__PURE__*/React.createElement(Image, {
380
+ source: {
381
+ uri: data.item.profile_pic
382
+ },
383
+ style: {
384
+ height: 30,
385
+ width: 30,
386
+ borderRadius: 100
387
+ }
388
+ }), /*#__PURE__*/React.createElement(View, {
389
+ transparent: true,
390
+ style: {
391
+ flex: 1,
392
+ marginLeft: 10
393
+ }
394
+ }, /*#__PURE__*/React.createElement(Text, {
395
+ theme: "h1"
396
+ }, "@", data.item.username), /*#__PURE__*/React.createElement(Text, {
397
+ theme: "description",
398
+ style: {
399
+ marginTop: 3
400
+ }
401
+ }, "Joined ", moment(data.item.create_datetime).fromNow())));
402
+ };
403
+ const renderSections = data => {
404
+ switch (data.item) {
405
+ case 'header':
406
+ return /*#__PURE__*/React.createElement(View, {
407
+ type: "header",
408
+ style: {
409
+ flexDirection: 'row',
410
+ alignItems: 'center',
411
+ padding: 10
412
+ }
413
+ }, /*#__PURE__*/React.createElement(View, {
414
+ transparent: true,
415
+ style: {
416
+ flex: 1
417
+ }
418
+ }, /*#__PURE__*/React.createElement(Text, {
419
+ theme: "h1"
420
+ }, "Flash Market"), /*#__PURE__*/React.createElement(Text, {
421
+ theme: "description",
422
+ style: {
423
+ marginTop: 3
424
+ }
425
+ }, "Use the form below to manage your custom flash market!")), /*#__PURE__*/React.createElement(Button, {
426
+ float: true,
427
+ title: "X",
428
+ title_color: Colors.text.error,
429
+ onPress: () => onClose()
430
+ }));
431
+ case 'activate':
432
+ if (poll?.status != 'pending') {
433
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
434
+ }
435
+ const ready = errors.length == 0 ? true : false;
436
+ return /*#__PURE__*/React.createElement(View, {
437
+ transparent: true,
438
+ style: {
439
+ flexDirection: 'row',
440
+ alignItems: 'center',
441
+ padding: 10
442
+ }
443
+ }, /*#__PURE__*/React.createElement(View, {
444
+ transparent: true,
445
+ style: {
446
+ flex: 1
447
+ }
448
+ }, /*#__PURE__*/React.createElement(Text, {
449
+ theme: "h1"
450
+ }, "Flash Market is Pending"), /*#__PURE__*/React.createElement(Text, {
451
+ theme: "description"
452
+ }, "Complete set up and select activate when you are ready")), /*#__PURE__*/React.createElement(Button, {
453
+ type: "success",
454
+ title: "Activate",
455
+ loading: action_loading,
456
+ disabled: errors.length > 0 ? true : probability_changed ? true : false,
457
+ style: {
458
+ opacity: ready && !action_loading && !probability_changed ? 1 : 0.5
459
+ },
460
+ onPress: async () => {
461
+ if (errors.length > 0) {
462
+ return alert(errors.map(e => e));
463
+ }
464
+ if (probability_changed) {
465
+ return;
466
+ }
467
+ setFlashState({
468
+ ...flash_state,
469
+ action_loading: true
470
+ });
471
+ const resp = await PollApi.activatePoll(poll.poll_id);
472
+ if (!resp) {
473
+ return alert('Unable to activate market at this time');
474
+ }
475
+ setFlashState({
476
+ ...flash_state,
477
+ action_loading: false,
478
+ poll: resp.poll,
479
+ poll_options: resp.poll_options
480
+ });
481
+ }
482
+ }));
483
+ case 'closed':
484
+ if (!poll) {
485
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
486
+ }
487
+ if (poll.status != 'closed') {
488
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
489
+ }
490
+ return /*#__PURE__*/React.createElement(View, {
491
+ transparent: true,
492
+ style: {
493
+ flexDirection: 'row',
494
+ alignItems: 'center',
495
+ padding: 10,
496
+ backgroundColor: Colors.views.liquidMarket
497
+ }
498
+ }, /*#__PURE__*/React.createElement(View, {
499
+ transparent: true,
500
+ style: {
501
+ flex: 1
502
+ }
503
+ }, /*#__PURE__*/React.createElement(Text, {
504
+ theme: "h1"
505
+ }, "Flash Market is Closed"), /*#__PURE__*/React.createElement(Text, {
506
+ theme: "description"
507
+ }, "This flash market has been completed and all participants have been paid out")));
508
+ case 'pause_resume':
509
+ if (!poll) {
510
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
511
+ }
512
+ if (!['active', 'paused', ''].includes(poll.status)) {
513
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
514
+ }
515
+ if (poll.winning_option_id) {
516
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
517
+ }
518
+ return /*#__PURE__*/React.createElement(View, {
519
+ transparent: true,
520
+ style: {
521
+ flexDirection: 'row',
522
+ alignItems: 'center',
523
+ padding: 10
524
+ }
525
+ }, /*#__PURE__*/React.createElement(View, {
526
+ transparent: true,
527
+ style: {
528
+ flex: 1
529
+ }
530
+ }, /*#__PURE__*/React.createElement(Text, {
531
+ theme: "h1"
532
+ }, "Flash Market is ", poll.status), /*#__PURE__*/React.createElement(Text, {
533
+ theme: "description"
534
+ }, "Complete set up and select activate when you are ready")), poll.status == 'paused' ? /*#__PURE__*/React.createElement(Button, {
535
+ type: "success",
536
+ title: "Resume",
537
+ loading: action_loading,
538
+ disabled: action_loading ? true : false,
539
+ style: {
540
+ opacity: action_loading ? 0.5 : 1
541
+ },
542
+ onPress: async () => {
543
+ updatePoll({
544
+ ...poll,
545
+ status: 'active'
546
+ });
547
+ }
548
+ }) : /*#__PURE__*/React.createElement(Button, {
549
+ type: "warning",
550
+ title: "Pause",
551
+ loading: action_loading,
552
+ disabled: action_loading ? true : false,
553
+ style: {
554
+ opacity: action_loading ? 0.5 : 1
555
+ },
556
+ onPress: async () => {
557
+ updatePoll({
558
+ ...poll,
559
+ status: 'paused'
560
+ });
561
+ }
562
+ }));
563
+ case 'resolve':
564
+ if (!poll) {
565
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
566
+ }
567
+ if (!poll.winning_option_id) {
568
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
569
+ }
570
+ if (!winning_option) {
571
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
572
+ }
573
+ if (poll.status == 'closed') {
574
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
575
+ }
576
+ return /*#__PURE__*/React.createElement(View, {
577
+ transparent: true,
578
+ style: {
579
+ flexDirection: 'row',
580
+ alignItems: 'center',
581
+ padding: 10
582
+ }
583
+ }, /*#__PURE__*/React.createElement(View, {
584
+ transparent: true,
585
+ style: {
586
+ flex: 1
587
+ }
588
+ }, /*#__PURE__*/React.createElement(Text, {
589
+ theme: "h1"
590
+ }, "Resolve Flash Market"), /*#__PURE__*/React.createElement(Text, {
591
+ theme: "description"
592
+ }, "Resolve with option: ", winning_option.option_name, " as the winner")), /*#__PURE__*/React.createElement(Button, {
593
+ type: "success",
594
+ title: "Resolve",
595
+ loading: action_loading,
596
+ disabled: action_loading,
597
+ style: {
598
+ opacity: action_loading ? 0.5 : 1
599
+ },
600
+ onPress: async () => handleResolve()
601
+ }));
602
+ case 'toggle':
603
+ return /*#__PURE__*/React.createElement(View, {
604
+ style: {
605
+ padding: 10
606
+ }
607
+ }, /*#__PURE__*/React.createElement(Toggle, {
608
+ options: [{
609
+ key: 'question',
610
+ label: 'Question'
611
+ }, {
612
+ key: 'options',
613
+ label: 'Options'
614
+ }, {
615
+ key: 'settings',
616
+ label: 'Settings'
617
+ }, {
618
+ key: 'results',
619
+ label: 'Results'
620
+ }],
621
+ selected_option: active_step,
622
+ onSelectOption: key => setFlashState({
623
+ ...flash_state,
624
+ active_step: key
625
+ })
626
+ }));
627
+ case 'image':
628
+ if (active_step != 'question') {
629
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
630
+ }
631
+ if (!draft_poll || !poll) {
632
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
633
+ }
634
+ return /*#__PURE__*/React.createElement(View, {
635
+ style: {
636
+ flexDirection: 'row',
637
+ alignItems: 'center',
638
+ padding: 10,
639
+ borderBottomWidth: 1,
640
+ borderColor: Colors.borders.light
641
+ }
642
+ }, /*#__PURE__*/React.createElement(View, {
643
+ transparent: true,
644
+ style: {
645
+ flex: 1,
646
+ marginRight: 10
647
+ }
648
+ }, /*#__PURE__*/React.createElement(Text, {
649
+ theme: "h1"
650
+ }, "Flash Market Image"), /*#__PURE__*/React.createElement(Text, {
651
+ theme: "description",
652
+ style: {
653
+ marginTop: 3
654
+ }
655
+ }, "Give the question an image that aligns with the question")), /*#__PURE__*/React.createElement(ImageUploader, {
656
+ disabled: poll.status == 'closed' ? true : false,
657
+ public_id: `poll_${poll_id}_${Math.random().toFixed(9)}`,
658
+ onFinishUpload: obj => {
659
+ updatePoll({
660
+ ...draft_poll,
661
+ poll_image: {
662
+ ...obj,
663
+ url: obj.secure_url
664
+ }
665
+ });
666
+ }
667
+ }, poll.poll_image ? /*#__PURE__*/React.createElement(Image, {
668
+ source: {
669
+ uri: poll.poll_image.url
670
+ },
671
+ style: {
672
+ height: 45,
673
+ width: 45
674
+ },
675
+ resizeMode: "contain"
676
+ }) : /*#__PURE__*/React.createElement(Icons.ImageIcon, {
677
+ size: 45,
678
+ color: Colors.text.h1
679
+ }), /*#__PURE__*/React.createElement(Text, {
680
+ style: {
681
+ marginTop: 5
682
+ },
683
+ textAlign: "center",
684
+ theme: "action"
685
+ }, draft_poll.poll_image ? 'CHANGE' : 'UPLOAD')));
686
+ case 'question':
687
+ if (active_step != 'question') {
688
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
689
+ }
690
+ if (!draft_poll || !poll) {
691
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
692
+ }
693
+ const is_q_changed = JSON.stringify(poll.poll_question) != JSON.stringify(draft_poll.poll_question) ? true : false;
694
+ const edit_allowed = poll_summaries.length == 0 && ['pending', 'paused'].includes(poll.status) ? true : false;
695
+ return /*#__PURE__*/React.createElement(View, {
696
+ transparent: true
697
+ }, /*#__PURE__*/React.createElement(View, {
698
+ style: {
699
+ flexDirection: 'row',
700
+ alignItems: 'center',
701
+ padding: 10
702
+ }
703
+ }, /*#__PURE__*/React.createElement(View, {
704
+ transparent: true,
705
+ style: {
706
+ flex: 1
707
+ }
708
+ }, /*#__PURE__*/React.createElement(Text, {
709
+ theme: "h1"
710
+ }, "Flash Market Question"), /*#__PURE__*/React.createElement(Text, {
711
+ theme: "description",
712
+ style: {
713
+ marginTop: 3
714
+ }
715
+ }, "Edit your question below. Questions can be edited until a response is recorded."))), /*#__PURE__*/React.createElement(View, {
716
+ transparent: true,
717
+ style: {
718
+ padding: 20
719
+ }
720
+ }, /*#__PURE__*/React.createElement(TextInput, {
721
+ style: {
722
+ height: 150,
723
+ textAlign: 'center'
724
+ },
725
+ multiline: true,
726
+ editable: edit_allowed,
727
+ placeholder: "Enter Question Here",
728
+ value: draft_poll.poll_question,
729
+ onChangeText: text => setFlashState({
730
+ ...flash_state,
731
+ draft_poll: {
732
+ ...draft_poll,
733
+ poll_question: text
734
+ }
735
+ })
736
+ })), /*#__PURE__*/React.createElement(Button, {
737
+ title: "SAVE QUESTION",
738
+ type: "success",
739
+ disabled: !edit_allowed || !is_q_changed ? true : false,
740
+ style: {
741
+ margin: 10,
742
+ opacity: !edit_allowed || !is_q_changed ? 0.5 : 1
743
+ },
744
+ loading: action_loading,
745
+ onPress: () => updatePoll(draft_poll)
746
+ }));
747
+ case 'results':
748
+ if (!poll) {
749
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
750
+ }
751
+ if (active_step != 'results') {
752
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
753
+ }
754
+ let staked = poll_summaries.reduce((a, b) => a + b.stake, 0) - (poll.base_stake ?? 0);
755
+ let responses = poll_summaries.reduce((a, b) => a + b.count, 0) - poll_summaries.length;
756
+ if (responses < 0) {
757
+ responses = 0;
758
+ }
759
+ let participants = players.length;
760
+ let total_stake = poll_summaries.reduce((a, b) => a + b.stake, 0);
761
+ let winnings = poll_summaries.reduce((a, b) => a + b.winnings, 0);
762
+ let revenue = total_stake - winnings;
763
+ return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
764
+ type: "row",
765
+ style: {
766
+ padding: 20,
767
+ borderBottomWidth: 1,
768
+ borderColor: Colors.borders.light
769
+ }
770
+ }, /*#__PURE__*/React.createElement(View, {
771
+ transparent: true,
772
+ style: {
773
+ flex: 1,
774
+ marginRight: 10
775
+ }
776
+ }, /*#__PURE__*/React.createElement(Text, {
777
+ theme: "h1"
778
+ }, "Total Revenue"), /*#__PURE__*/React.createElement(Text, {
779
+ theme: "description",
780
+ style: {
781
+ marginTop: 3
782
+ }
783
+ }, "Total amount of revenue earned on this flash market")), /*#__PURE__*/React.createElement(Text, {
784
+ theme: "h1"
785
+ }, "$", revenue.toFixed(2))), /*#__PURE__*/React.createElement(View, {
786
+ type: "row",
787
+ style: {
788
+ padding: 20,
789
+ borderBottomWidth: 1,
790
+ borderColor: Colors.borders.light
791
+ }
792
+ }, /*#__PURE__*/React.createElement(View, {
793
+ transparent: true,
794
+ style: {
795
+ flex: 1,
796
+ marginRight: 10
797
+ }
798
+ }, /*#__PURE__*/React.createElement(Text, {
799
+ theme: "h1"
800
+ }, "Total Volume"), /*#__PURE__*/React.createElement(Text, {
801
+ theme: "description",
802
+ style: {
803
+ marginTop: 3
804
+ }
805
+ }, "Total amount bet on this market")), /*#__PURE__*/React.createElement(Text, {
806
+ theme: "h1"
807
+ }, "$", staked.toFixed(2))), /*#__PURE__*/React.createElement(View, {
808
+ type: "row",
809
+ style: {
810
+ padding: 20,
811
+ borderBottomWidth: 1,
812
+ borderColor: Colors.borders.light
813
+ }
814
+ }, /*#__PURE__*/React.createElement(View, {
815
+ transparent: true,
816
+ style: {
817
+ flex: 1,
818
+ marginRight: 10
819
+ }
820
+ }, /*#__PURE__*/React.createElement(Text, {
821
+ theme: "h1"
822
+ }, "Total Responses"), /*#__PURE__*/React.createElement(Text, {
823
+ theme: "description",
824
+ style: {
825
+ marginTop: 3
826
+ }
827
+ }, "Total number of bets on this market")), /*#__PURE__*/React.createElement(Text, {
828
+ theme: "h1"
829
+ }, responses.toFixed())), /*#__PURE__*/React.createElement(View, {
830
+ type: "row",
831
+ style: {
832
+ padding: 20,
833
+ borderBottomWidth: 1,
834
+ borderColor: Colors.borders.light
835
+ }
836
+ }, /*#__PURE__*/React.createElement(View, {
837
+ transparent: true,
838
+ style: {
839
+ flex: 1,
840
+ marginRight: 10
841
+ }
842
+ }, /*#__PURE__*/React.createElement(Text, {
843
+ theme: "h1"
844
+ }, "Participants"), /*#__PURE__*/React.createElement(Text, {
845
+ theme: "description",
846
+ style: {
847
+ marginTop: 3
848
+ }
849
+ }, "Players that participated in this flash market")), /*#__PURE__*/React.createElement(Text, {
850
+ theme: "h1"
851
+ }, participants.toFixed()), /*#__PURE__*/React.createElement(Button, {
852
+ onPress: () => setExpandParticipants(!expand_participants),
853
+ float: true,
854
+ style: {
855
+ marginLeft: 10,
856
+ height: 30,
857
+ width: 30,
858
+ borderRadius: 100,
859
+ padding: 10,
860
+ justifyContent: 'center',
861
+ alignItems: 'center'
862
+ }
863
+ }, /*#__PURE__*/React.createElement(Icons.ChevronIcon, {
864
+ direction: expand_participants ? 'up' : 'down',
865
+ size: 8,
866
+ color: Colors.text.action
867
+ }))), expand_participants ? /*#__PURE__*/React.createElement(View, {
868
+ style: {
869
+ margin: 10
870
+ }
871
+ }, /*#__PURE__*/React.createElement(FlatList, {
872
+ data: players,
873
+ renderItem: renderPlayers,
874
+ key: 'participant_list_poll',
875
+ keyExtractor: item => item.player_id.toString()
876
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null));
877
+ case 'options':
878
+ if (!poll) {
879
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
880
+ }
881
+ if (active_step != 'options') {
882
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
883
+ }
884
+ const add_allowed = ['pending', 'paused'].includes(poll.status) && total_responses == 0 ? true : false;
885
+ return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
886
+ style: {
887
+ flexDirection: 'row',
888
+ alignItems: 'center',
889
+ padding: 10
890
+ }
891
+ }, /*#__PURE__*/React.createElement(View, {
892
+ transparent: true,
893
+ style: {
894
+ flex: 1
895
+ }
896
+ }, /*#__PURE__*/React.createElement(Text, {
897
+ theme: "h1"
898
+ }, "Flash Market Options"), poll.status == 'pending' ? /*#__PURE__*/React.createElement(Text, {
899
+ theme: "description",
900
+ style: {
901
+ marginTop: 3
902
+ }
903
+ }, "Enter the options below!") : /*#__PURE__*/React.createElement(Text, {
904
+ theme: "description",
905
+ style: {
906
+ marginTop: 3
907
+ }
908
+ }, "Select the winning option below")), probability_changed ? /*#__PURE__*/React.createElement(Button, {
909
+ title: "SAVE PROBABILITIES",
910
+ onPress: () => handleSaveProbabilities(),
911
+ type: "success",
912
+ disabled: action_loading,
913
+ loading: action_loading,
914
+ style: {
915
+ margin: 5,
916
+ padding: 10,
917
+ opacity: loading ? 0.5 : 1
918
+ }
919
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(View, {
920
+ style: {
921
+ padding: 10
922
+ }
923
+ }, /*#__PURE__*/React.createElement(FlatList, {
924
+ data: real_options.sort((a, b) => a.priority - b.priority || moment(a.create_datetime).unix() - moment(b.create_datetime).unix()),
925
+ key: "option_list",
926
+ keyboardShouldPersistTaps: true,
927
+ keyExtractor: item => item.poll_option_id.toString(),
928
+ renderItem: renderOptions
929
+ }), add_allowed ? /*#__PURE__*/React.createElement(Button, {
930
+ transparent: true,
931
+ title_color: Colors.text.action,
932
+ title: real_options.length > 0 ? 'Add another option' : 'Add an option',
933
+ style: {
934
+ alignItems: 'flex-start',
935
+ padding: 10
936
+ },
937
+ onPress: async () => handleAddOption()
938
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)));
939
+ case 'settings':
940
+ if (active_step != 'settings') {
941
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
942
+ }
943
+ if (!draft_poll) {
944
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
945
+ }
946
+ let settings_edit_allowed = ['paused', 'pending'].includes(draft_poll.status) && total_responses == 0 ? true : false;
947
+ const min_stake_changed = settings_edit_allowed && poll?.minimum_stake != parseFloat(min_stake) ? true : false;
948
+ const max_stake_changed = settings_edit_allowed && poll?.max_stake != parseFloat(max_stake) ? true : false;
949
+ const base_stake_changed = settings_edit_allowed && poll?.base_stake != parseFloat(base_stake) ? true : false;
950
+ return /*#__PURE__*/React.createElement(View, null, player?.role == 'admin' ? /*#__PURE__*/React.createElement(View, {
951
+ type: "row",
952
+ style: {
953
+ padding: 20,
954
+ borderBottomWidth: 1,
955
+ borderColor: Colors.borders.light
956
+ }
957
+ }, /*#__PURE__*/React.createElement(View, {
958
+ transparent: true,
959
+ style: {
960
+ flex: 1,
961
+ marginRight: 10
962
+ }
963
+ }, /*#__PURE__*/React.createElement(Text, {
964
+ theme: "h1"
965
+ }, "Base Stake"), /*#__PURE__*/React.createElement(Text, {
966
+ theme: "description",
967
+ style: {
968
+ marginTop: 3
969
+ }
970
+ }, "Fill responses with a base stake based on their probabilities.")), /*#__PURE__*/React.createElement(TextInput, {
971
+ value: base_stake,
972
+ editable: settings_edit_allowed,
973
+ style: {
974
+ width: 75,
975
+ textAlign: 'center'
976
+ },
977
+ onFocusPosition: onFocusPosition,
978
+ onChangeText: text => setLabels({
979
+ ...labels,
980
+ base_stake: text
981
+ })
982
+ }), base_stake_changed && poll?.status == 'pending' ? /*#__PURE__*/React.createElement(Button, {
983
+ title: "SAVE",
984
+ type: "success",
985
+ onPress: () => {
986
+ let num = parseFloat(base_stake);
987
+ if (isNaN(num)) {
988
+ return alert('Invalid value');
989
+ }
990
+ if (num < 0) {
991
+ return alert('Invalid amount');
992
+ }
993
+ updatePoll({
994
+ ...draft_poll,
995
+ base_stake: parseFloat(base_stake)
996
+ });
997
+ }
998
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(View, {
999
+ type: "row",
1000
+ style: {
1001
+ padding: 20,
1002
+ borderBottomWidth: 1,
1003
+ borderColor: Colors.borders.light
1004
+ }
1005
+ }, /*#__PURE__*/React.createElement(View, {
1006
+ transparent: true,
1007
+ style: {
1008
+ flex: 1,
1009
+ marginRight: 10
1010
+ }
1011
+ }, /*#__PURE__*/React.createElement(Text, {
1012
+ theme: "h1"
1013
+ }, "Minimum Stake Allowed"), /*#__PURE__*/React.createElement(Text, {
1014
+ theme: "description",
1015
+ style: {
1016
+ marginTop: 3
1017
+ }
1018
+ }, "The smallest bet allowed to be placed on this market.")), /*#__PURE__*/React.createElement(TextInput, {
1019
+ value: min_stake,
1020
+ editable: settings_edit_allowed,
1021
+ onFocus: () => min_stake == '0' ? setLabels({
1022
+ ...labels,
1023
+ min_stake: ''
1024
+ }) : console.log(''),
1025
+ style: {
1026
+ width: 75,
1027
+ textAlign: 'center'
1028
+ },
1029
+ onFocusPosition: onFocusPosition,
1030
+ onChangeText: text => setLabels({
1031
+ ...labels,
1032
+ min_stake: text
1033
+ })
1034
+ }), min_stake_changed ? /*#__PURE__*/React.createElement(Button, {
1035
+ title: "SAVE",
1036
+ type: "success",
1037
+ onPress: () => {
1038
+ let num = parseFloat(min_stake);
1039
+ if (isNaN(num)) {
1040
+ return alert('Invalid value');
1041
+ }
1042
+ if (num < 0) {
1043
+ return alert('Invalid amount');
1044
+ }
1045
+ updatePoll({
1046
+ ...draft_poll,
1047
+ minimum_stake: parseFloat(min_stake)
1048
+ });
1049
+ }
1050
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(View, {
1051
+ type: "row",
1052
+ style: {
1053
+ padding: 20,
1054
+ borderBottomWidth: 1,
1055
+ borderColor: Colors.borders.light
1056
+ }
1057
+ }, /*#__PURE__*/React.createElement(View, {
1058
+ transparent: true,
1059
+ style: {
1060
+ flex: 1,
1061
+ marginRight: 10
1062
+ }
1063
+ }, /*#__PURE__*/React.createElement(Text, {
1064
+ theme: "h1"
1065
+ }, "Max Stake Allowed"), /*#__PURE__*/React.createElement(Text, {
1066
+ theme: "description",
1067
+ style: {
1068
+ marginTop: 3
1069
+ }
1070
+ }, "The largest bet allowed to be placed on this market.")), /*#__PURE__*/React.createElement(TextInput, {
1071
+ value: max_stake,
1072
+ editable: settings_edit_allowed,
1073
+ onFocus: () => max_stake == '0' ? setLabels({
1074
+ ...labels,
1075
+ max_stake: ''
1076
+ }) : console.log(''),
1077
+ style: {
1078
+ width: 75,
1079
+ textAlign: 'center'
1080
+ },
1081
+ onFocusPosition: onFocusPosition,
1082
+ onChangeText: text => setLabels({
1083
+ ...labels,
1084
+ max_stake: text
1085
+ })
1086
+ }), max_stake_changed ? /*#__PURE__*/React.createElement(Button, {
1087
+ title: "SAVE",
1088
+ type: "success",
1089
+ onPress: () => {
1090
+ let num = parseFloat(max_stake);
1091
+ if (isNaN(num)) {
1092
+ return alert('Invalid value');
1093
+ }
1094
+ if (num < 0) {
1095
+ return alert('Invalid amount');
1096
+ }
1097
+ updatePoll({
1098
+ ...draft_poll,
1099
+ max_stake: parseFloat(max_stake)
1100
+ });
1101
+ }
1102
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null)), /*#__PURE__*/React.createElement(View, {
1103
+ type: "row",
1104
+ style: {
1105
+ padding: 20,
1106
+ borderBottomWidth: 1,
1107
+ borderColor: Colors.borders.light
1108
+ }
1109
+ }, /*#__PURE__*/React.createElement(View, {
1110
+ transparent: true,
1111
+ style: {
1112
+ flex: 1,
1113
+ marginRight: 10
1114
+ }
1115
+ }, /*#__PURE__*/React.createElement(Text, {
1116
+ theme: "h1"
1117
+ }, "Allow Multiple Responses"), /*#__PURE__*/React.createElement(Text, {
1118
+ theme: "description",
1119
+ style: {
1120
+ marginTop: 3
1121
+ }
1122
+ }, "If on, players can select multiple options.")), /*#__PURE__*/React.createElement(Switch, {
1123
+ switch_type: "on_off",
1124
+ disabled: settings_edit_allowed ? false : true,
1125
+ value: draft_poll.multi_responses_allowed ?? false,
1126
+ onChange: async val => {
1127
+ updatePoll({
1128
+ ...draft_poll,
1129
+ multi_responses_allowed: val
1130
+ });
1131
+ }
1132
+ })), /*#__PURE__*/React.createElement(View, {
1133
+ type: "row",
1134
+ style: {
1135
+ padding: 20,
1136
+ borderBottomWidth: 1,
1137
+ borderColor: Colors.borders.light
1138
+ }
1139
+ }, /*#__PURE__*/React.createElement(View, {
1140
+ transparent: true,
1141
+ style: {
1142
+ flex: 1,
1143
+ marginRight: 10
1144
+ }
1145
+ }, /*#__PURE__*/React.createElement(Text, {
1146
+ theme: "h1"
1147
+ }, "Allow Increase Stake"), /*#__PURE__*/React.createElement(Text, {
1148
+ theme: "description",
1149
+ style: {
1150
+ marginTop: 3
1151
+ }
1152
+ }, "If on, players can continue to add more funds to a selected option.")), /*#__PURE__*/React.createElement(Switch, {
1153
+ switch_type: "on_off",
1154
+ disabled: settings_edit_allowed ? false : true,
1155
+ value: draft_poll.stake_increase_allowed ?? false,
1156
+ onChange: async val => {
1157
+ updatePoll({
1158
+ ...draft_poll,
1159
+ stake_increase_allowed: val
1160
+ });
1161
+ }
1162
+ })), /*#__PURE__*/React.createElement(View, {
1163
+ type: "row",
1164
+ style: {
1165
+ padding: 20,
1166
+ borderBottomWidth: 1,
1167
+ borderColor: Colors.borders.light
1168
+ }
1169
+ }, /*#__PURE__*/React.createElement(View, {
1170
+ transparent: true,
1171
+ style: {
1172
+ flex: 1,
1173
+ marginRight: 10
1174
+ }
1175
+ }, /*#__PURE__*/React.createElement(Text, {
1176
+ theme: "h1"
1177
+ }, "Flash Close Time"), /*#__PURE__*/React.createElement(Text, {
1178
+ theme: "description",
1179
+ style: {
1180
+ marginTop: 3
1181
+ }
1182
+ }, "When should this market close?")), /*#__PURE__*/React.createElement(BETimePicker, {
1183
+ selected_time: moment(poll?.end_datetime),
1184
+ disabled: settings_edit_allowed ? false : true,
1185
+ onSelectTime: val => {
1186
+ updatePoll({
1187
+ ...draft_poll,
1188
+ end_datetime: val
1189
+ });
1190
+ }
1191
+ })));
1192
+ default:
1193
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
1194
+ }
1195
+ };
1196
+ return /*#__PURE__*/React.createElement(View, {
1197
+ style: {
1198
+ flex: 1
1199
+ }
1200
+ }, /*#__PURE__*/React.createElement(View, {
1201
+ style: {
1202
+ flex: 1
1203
+ }
1204
+ }, /*#__PURE__*/React.createElement(FlatList, {
1205
+ data: sections
1206
+ //keyboardShouldPersistTaps
1207
+ ,
1208
+ key: "flash_market_sections",
1209
+ keyExtractor: item => item,
1210
+ renderItem: renderSections
1211
+ })));
1212
+ };
1213
+ export default ManageFlashMarket;
1214
+ //# sourceMappingURL=ManageFlashMarket.js.map