be-components 0.7.6 → 0.7.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.
- package/lib/commonjs/Poll/api/index.js +63 -18
- package/lib/commonjs/Poll/api/index.js.map +1 -1
- package/lib/commonjs/Poll/components/CampaignPlay.js +7 -4
- package/lib/commonjs/Poll/components/CampaignPlay.js.map +1 -1
- package/lib/commonjs/Poll/components/CampaignProgressBar.js +1 -0
- package/lib/commonjs/Poll/components/CampaignProgressBar.js.map +1 -1
- package/lib/commonjs/Poll/components/CampaignResult.js +2 -2
- package/lib/commonjs/Poll/components/CampaignResult.js.map +1 -1
- package/lib/commonjs/Poll/components/ResponseTimer.js.map +1 -1
- package/lib/commonjs/Poll/flashmarket/ResultCard.js +419 -0
- package/lib/commonjs/Poll/flashmarket/ResultCard.js.map +1 -0
- package/lib/commonjs/Poll/flashmarket/index.js +355 -68
- package/lib/commonjs/Poll/flashmarket/index.js.map +1 -1
- package/lib/commonjs/Poll/index.js +8 -5
- package/lib/commonjs/Poll/index.js.map +1 -1
- package/lib/module/Poll/api/index.js +63 -18
- package/lib/module/Poll/api/index.js.map +1 -1
- package/lib/module/Poll/components/CampaignPlay.js +7 -4
- package/lib/module/Poll/components/CampaignPlay.js.map +1 -1
- package/lib/module/Poll/components/CampaignProgressBar.js +1 -0
- package/lib/module/Poll/components/CampaignProgressBar.js.map +1 -1
- package/lib/module/Poll/components/CampaignResult.js +2 -2
- package/lib/module/Poll/components/CampaignResult.js.map +1 -1
- package/lib/module/Poll/components/ResponseTimer.js.map +1 -1
- package/lib/module/Poll/flashmarket/ResultCard.js +410 -0
- package/lib/module/Poll/flashmarket/ResultCard.js.map +1 -0
- package/lib/module/Poll/flashmarket/index.js +357 -70
- package/lib/module/Poll/flashmarket/index.js.map +1 -1
- package/lib/module/Poll/index.js +8 -5
- package/lib/module/Poll/index.js.map +1 -1
- package/lib/typescript/src/Poll/api/index.d.ts +7 -2
- package/lib/typescript/src/Poll/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Poll/components/CampaignPlay.d.ts +1 -1
- package/lib/typescript/src/Poll/components/CampaignPlay.d.ts.map +1 -1
- package/lib/typescript/src/Poll/components/CampaignProgressBar.d.ts.map +1 -1
- package/lib/typescript/src/Poll/components/ResponseTimer.d.ts.map +1 -1
- package/lib/typescript/src/Poll/flashmarket/ResultCard.d.ts +12 -0
- package/lib/typescript/src/Poll/flashmarket/ResultCard.d.ts.map +1 -0
- package/lib/typescript/src/Poll/flashmarket/index.d.ts +5 -3
- package/lib/typescript/src/Poll/flashmarket/index.d.ts.map +1 -1
- package/lib/typescript/src/Poll/index.d.ts +5 -4
- package/lib/typescript/src/Poll/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Poll/api/index.ts +54 -16
- package/src/Poll/components/CampaignPlay.tsx +8 -5
- package/src/Poll/components/CampaignProgressBar.tsx +1 -2
- package/src/Poll/components/CampaignResult.tsx +2 -2
- package/src/Poll/components/ResponseTimer.tsx +1 -0
- package/src/Poll/flashmarket/ResultCard.tsx +194 -0
- package/src/Poll/flashmarket/index.tsx +309 -96
- package/src/Poll/index.tsx +11 -8
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { ActivityIndicator, View, Image, TouchableOpacity } from "react-native";
|
|
3
3
|
import Colors from '../../constants/colors';
|
|
4
|
-
import {
|
|
5
|
-
import { PollApi, PollCampaignApi, PollResponseApi, PollResponseHelpers } from '../api';
|
|
4
|
+
import { Button, Icons, Text, TextInput } from '../../Components';
|
|
5
|
+
import { PollApi, PollCampaignApi, PollCampaignHelpers, PollResponseApi, PollResponseHelpers } from '../api';
|
|
6
6
|
import { view_styles } from '../../constants/styles';
|
|
7
7
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
8
|
+
import CampaignProgressBar from '../components/CampaignProgressBar';
|
|
9
|
+
import ResponseTimer from '../components/ResponseTimer';
|
|
10
|
+
import ResultCard from './ResultCard';
|
|
8
11
|
const MAX_IMAGE_SIZE = 125;
|
|
9
12
|
const MAX_OPTION_WIDTH = 200;
|
|
10
13
|
const FlashMarket = ({
|
|
14
|
+
hide_progress_bar,
|
|
15
|
+
poll_campaign_id,
|
|
11
16
|
poll_id,
|
|
12
17
|
player_id,
|
|
13
18
|
onRequestAuthenticate
|
|
@@ -16,11 +21,11 @@ const FlashMarket = ({
|
|
|
16
21
|
height: 0,
|
|
17
22
|
width: 0
|
|
18
23
|
});
|
|
19
|
-
const [
|
|
24
|
+
const [poll_data, setPollData] = useState({
|
|
20
25
|
loading: false,
|
|
21
26
|
poll_options: [],
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
show_complete: false,
|
|
28
|
+
poll_summaries: []
|
|
24
29
|
});
|
|
25
30
|
const {
|
|
26
31
|
loading,
|
|
@@ -28,34 +33,79 @@ const FlashMarket = ({
|
|
|
28
33
|
poll_options,
|
|
29
34
|
poll_summaries,
|
|
30
35
|
poll_response
|
|
36
|
+
} = poll_data;
|
|
37
|
+
const [data, setData] = useState({
|
|
38
|
+
loaded: false,
|
|
39
|
+
polls: [],
|
|
40
|
+
show_leaders: false,
|
|
41
|
+
poll_responses: []
|
|
42
|
+
});
|
|
43
|
+
const {
|
|
44
|
+
loaded,
|
|
45
|
+
poll_campaign,
|
|
46
|
+
polls,
|
|
47
|
+
active_poll_index,
|
|
48
|
+
poll_responses,
|
|
49
|
+
show_leaders
|
|
31
50
|
} = data;
|
|
32
51
|
let visible_options = poll_options;
|
|
33
52
|
if (poll_response && poll_response.status == 'pending') {
|
|
34
53
|
visible_options = poll_options.filter(po => po.poll_option_id == poll_response.poll_option_id);
|
|
35
54
|
}
|
|
36
|
-
|
|
55
|
+
const selected_option = poll_options.find(po => po.poll_option_id == poll_response?.poll_option_id);
|
|
56
|
+
let image_size = flash_size.width * 0.15;
|
|
37
57
|
if (image_size > MAX_IMAGE_SIZE) {
|
|
38
58
|
image_size = MAX_IMAGE_SIZE;
|
|
39
59
|
}
|
|
40
|
-
let option_width = flash_size.width
|
|
60
|
+
let option_width = flash_size.width / 3 - 5;
|
|
41
61
|
if (option_width > MAX_OPTION_WIDTH) {
|
|
42
62
|
option_width = MAX_OPTION_WIDTH;
|
|
43
63
|
}
|
|
44
64
|
useEffect(() => {
|
|
45
|
-
getDataFromServer(
|
|
46
|
-
}, [
|
|
47
|
-
|
|
65
|
+
getDataFromServer(poll_campaign_id);
|
|
66
|
+
}, [poll_campaign_id, player_id]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!active_poll_index && active_poll_index != 0) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let active_poll = polls[active_poll_index];
|
|
72
|
+
if (!active_poll) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
getPollFromServer(active_poll.poll_id);
|
|
76
|
+
}, [active_poll_index]);
|
|
77
|
+
const getDataFromServer = async poll_campaign_id => {
|
|
78
|
+
const pc = await PollCampaignApi.getPollCampaignById(poll_campaign_id);
|
|
79
|
+
const ps_response = await PollApi.getPollsByCampaignId(poll_campaign_id);
|
|
80
|
+
let prs = [];
|
|
81
|
+
if (player_id) {
|
|
82
|
+
prs = await PollResponseApi.getMyCampaignResponses(poll_campaign_id);
|
|
83
|
+
}
|
|
84
|
+
//if(poll_id){ await getPollFromServer(poll_id) }
|
|
85
|
+
let index = polls.findIndex(p => p.poll_id == poll_id);
|
|
86
|
+
if (pc.campaign_type == 'trivia') {
|
|
87
|
+
index = -1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//const campaign_complete = PollCampaignHelpers.isCampaignComplete(ps_response.polls, prs, pc)
|
|
91
|
+
|
|
48
92
|
setData({
|
|
49
93
|
...data,
|
|
94
|
+
loaded: true,
|
|
95
|
+
polls: ps_response.polls.sort((a, b) => a.priority - b.priority),
|
|
96
|
+
poll_campaign: pc,
|
|
97
|
+
//show_leaders: campaign_complete,
|
|
98
|
+
active_poll_index: index >= 0 ? index : undefined,
|
|
99
|
+
poll_responses: prs
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const getPollFromServer = async poll_id => {
|
|
103
|
+
setPollData({
|
|
104
|
+
...poll_data,
|
|
50
105
|
loading: true
|
|
51
106
|
});
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
let my_response = undefined;
|
|
55
|
-
//First if there is a player_id - lets grab from the server first
|
|
56
|
-
if (player_id) {
|
|
57
|
-
my_response = await PollResponseApi.getResponseByPollId(poll_id);
|
|
58
|
-
}
|
|
107
|
+
const p = await PollApi.getPollById(poll_id);
|
|
108
|
+
let my_response = poll_responses.find(pr => pr.poll_id == poll_id);
|
|
59
109
|
if (!my_response) {
|
|
60
110
|
//If no-response - check cache
|
|
61
111
|
let cached_response = await AsyncStorage.getItem(`response:${poll_id}`);
|
|
@@ -63,23 +113,22 @@ const FlashMarket = ({
|
|
|
63
113
|
my_response = JSON.parse(cached_response);
|
|
64
114
|
}
|
|
65
115
|
}
|
|
66
|
-
|
|
116
|
+
setPollData({
|
|
117
|
+
...poll_data,
|
|
67
118
|
loading: false,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
poll_response: my_response,
|
|
73
|
-
show_complete: my_response && my_response?.status != 'pending' ? true : false
|
|
119
|
+
poll: p.poll,
|
|
120
|
+
poll_options: p.poll_options,
|
|
121
|
+
poll_summaries: p.poll_summaries,
|
|
122
|
+
poll_response: my_response
|
|
74
123
|
});
|
|
75
124
|
};
|
|
76
125
|
const handleSelectOption = async po => {
|
|
77
|
-
if (!poll) {
|
|
126
|
+
if (!poll || poll.status != 'active') {
|
|
78
127
|
return;
|
|
79
128
|
}
|
|
80
129
|
if (poll_response && poll_response.status != 'pending') {
|
|
81
|
-
return
|
|
82
|
-
...
|
|
130
|
+
return setPollData({
|
|
131
|
+
...poll_data,
|
|
83
132
|
show_complete: true
|
|
84
133
|
});
|
|
85
134
|
}
|
|
@@ -87,8 +136,8 @@ const FlashMarket = ({
|
|
|
87
136
|
if (cached_response) {
|
|
88
137
|
if (JSON.parse(cached_response).poll_option_id == po.poll_option_id) {
|
|
89
138
|
await AsyncStorage.removeItem(`response:${poll_id}`);
|
|
90
|
-
return
|
|
91
|
-
...
|
|
139
|
+
return setPollData({
|
|
140
|
+
...poll_data,
|
|
92
141
|
poll_response: undefined
|
|
93
142
|
});
|
|
94
143
|
}
|
|
@@ -108,10 +157,50 @@ const FlashMarket = ({
|
|
|
108
157
|
last_update_datetime: ''
|
|
109
158
|
};
|
|
110
159
|
await AsyncStorage.setItem(`response:${poll_id}`, JSON.stringify(draft_response));
|
|
160
|
+
setPollData({
|
|
161
|
+
...poll_data,
|
|
162
|
+
poll_response: draft_response
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const handleTimesUp = async () => {
|
|
166
|
+
if (!poll || poll.status != 'active') {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (!player_id) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (poll_response && poll_response.status == 'pending') {
|
|
173
|
+
return handleSubmit();
|
|
174
|
+
}
|
|
175
|
+
const draft_response = {
|
|
176
|
+
poll_id: poll.poll_id,
|
|
177
|
+
poll_option_id: '0',
|
|
178
|
+
stake: poll.minimum_stake,
|
|
179
|
+
market_type: 'FREE',
|
|
180
|
+
poll_response_id: '',
|
|
181
|
+
player_id: '',
|
|
182
|
+
winnings: 0,
|
|
183
|
+
timed_out: true,
|
|
184
|
+
response_body: {},
|
|
185
|
+
status: 'pending',
|
|
186
|
+
create_datetime: '',
|
|
187
|
+
last_update_datetime: ''
|
|
188
|
+
};
|
|
189
|
+
const new_resp = await PollResponseApi.createPollResponse({
|
|
190
|
+
...draft_response
|
|
191
|
+
});
|
|
192
|
+
const updated_ps = PollResponseHelpers.updateSummariesWithResponse(new_resp, poll_summaries);
|
|
193
|
+
setPollData({
|
|
194
|
+
...poll_data,
|
|
195
|
+
poll_response: new_resp,
|
|
196
|
+
poll_summaries: updated_ps,
|
|
197
|
+
show_complete: true
|
|
198
|
+
});
|
|
111
199
|
setData({
|
|
112
200
|
...data,
|
|
113
|
-
|
|
201
|
+
poll_responses: poll_responses.concat(new_resp)
|
|
114
202
|
});
|
|
203
|
+
await AsyncStorage.removeItem(`response:${poll_id}`);
|
|
115
204
|
};
|
|
116
205
|
const handleSubmit = async () => {
|
|
117
206
|
if (!poll_response) {
|
|
@@ -121,7 +210,7 @@ const FlashMarket = ({
|
|
|
121
210
|
return;
|
|
122
211
|
}
|
|
123
212
|
if (!player_id) {
|
|
124
|
-
return onRequestAuthenticate();
|
|
213
|
+
return onRequestAuthenticate(poll_campaign?.auth_strategy_id, poll_campaign?.company_id);
|
|
125
214
|
}
|
|
126
215
|
let stake_number = parseFloat(poll_response.stake);
|
|
127
216
|
if (isNaN(stake_number)) {
|
|
@@ -132,12 +221,16 @@ const FlashMarket = ({
|
|
|
132
221
|
stake: stake_number
|
|
133
222
|
});
|
|
134
223
|
const updated_ps = PollResponseHelpers.updateSummariesWithResponse(new_resp, poll_summaries);
|
|
135
|
-
|
|
136
|
-
...
|
|
224
|
+
setPollData({
|
|
225
|
+
...poll_data,
|
|
137
226
|
poll_response: new_resp,
|
|
138
227
|
poll_summaries: updated_ps,
|
|
139
228
|
show_complete: true
|
|
140
229
|
});
|
|
230
|
+
setData({
|
|
231
|
+
...data,
|
|
232
|
+
poll_responses: poll_responses.concat(new_resp)
|
|
233
|
+
});
|
|
141
234
|
await AsyncStorage.removeItem(`response:${poll_id}`);
|
|
142
235
|
};
|
|
143
236
|
|
|
@@ -147,15 +240,22 @@ const FlashMarket = ({
|
|
|
147
240
|
//const correct_summary = poll_summaries.find(ps => ps.poll_option_id == correct_option?.poll_option_id);
|
|
148
241
|
|
|
149
242
|
const renderPollOptions = data => {
|
|
243
|
+
const poll = polls.find(p => p.poll_id == data.item.poll_id);
|
|
244
|
+
if (!poll) {
|
|
245
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
246
|
+
}
|
|
150
247
|
const selected = data.item.poll_option_id == poll_response?.poll_option_id ? true : false;
|
|
151
248
|
const poll_summary = poll_summaries.find(ps => ps.poll_option_id == data.item.poll_option_id);
|
|
152
|
-
const color = PollResponseHelpers.getOptionColor(data.item, poll_response);
|
|
153
|
-
return /*#__PURE__*/React.createElement(View,
|
|
249
|
+
const color = PollResponseHelpers.getOptionColor(poll, data.item, poll_response);
|
|
250
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
251
|
+
style: {
|
|
252
|
+
width: option_width
|
|
253
|
+
}
|
|
254
|
+
}, /*#__PURE__*/React.createElement(TouchableOpacity
|
|
154
255
|
//disabled={poll_response && poll_response.status != 'pending' ? true : false}
|
|
155
256
|
, {
|
|
156
257
|
style: {
|
|
157
258
|
flexDirection: 'row',
|
|
158
|
-
width: option_width,
|
|
159
259
|
alignItems: 'center',
|
|
160
260
|
margin: 5,
|
|
161
261
|
borderRadius: 22,
|
|
@@ -190,28 +290,29 @@ const FlashMarket = ({
|
|
|
190
290
|
marginLeft: 10,
|
|
191
291
|
padding: 5,
|
|
192
292
|
borderRadius: selected ? 100 : 0,
|
|
193
|
-
backgroundColor: selected ? Colors.shades.white : undefined
|
|
194
|
-
...view_styles.float
|
|
293
|
+
backgroundColor: selected ? Colors.shades.white : undefined
|
|
195
294
|
},
|
|
196
295
|
size: 12,
|
|
197
296
|
color: Colors.brand.midnight,
|
|
198
297
|
weight: "bold"
|
|
199
298
|
}, (poll_summary.pct * 100).toFixed(), "%") : /*#__PURE__*/React.createElement(React.Fragment, null)));
|
|
200
299
|
};
|
|
201
|
-
if (
|
|
300
|
+
if (!loaded || !poll_campaign) {
|
|
202
301
|
return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
203
302
|
size: 'large',
|
|
204
303
|
color: Colors.brand.midnight
|
|
205
304
|
}));
|
|
206
305
|
}
|
|
306
|
+
const next_allowed = PollResponseHelpers.nextAllowed(polls, poll_responses, poll?.poll_id);
|
|
307
|
+
const campaign_complete = PollCampaignHelpers.isCampaignComplete(polls, poll_responses, poll_campaign);
|
|
207
308
|
return /*#__PURE__*/React.createElement(View, {
|
|
208
309
|
style: {
|
|
209
|
-
flex: 1
|
|
310
|
+
flex: 1,
|
|
311
|
+
backgroundColor: Colors.shades.white
|
|
210
312
|
}
|
|
211
313
|
}, /*#__PURE__*/React.createElement(View, {
|
|
212
314
|
style: {
|
|
213
|
-
|
|
214
|
-
flexDirection: 'row'
|
|
315
|
+
flex: 1
|
|
215
316
|
},
|
|
216
317
|
onLayout: ev => {
|
|
217
318
|
const {
|
|
@@ -223,56 +324,200 @@ const FlashMarket = ({
|
|
|
223
324
|
width
|
|
224
325
|
});
|
|
225
326
|
}
|
|
226
|
-
},
|
|
327
|
+
}, show_leaders ? /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(ResultCard, {
|
|
328
|
+
poll_campaign_id: poll_campaign_id,
|
|
329
|
+
width: flash_size.width,
|
|
330
|
+
polls: polls,
|
|
331
|
+
poll_responses: poll_responses,
|
|
332
|
+
onClose: () => setData({
|
|
333
|
+
...data,
|
|
334
|
+
show_leaders: false,
|
|
335
|
+
active_poll_index: 0
|
|
336
|
+
})
|
|
337
|
+
})) : !poll ? /*#__PURE__*/React.createElement(View, {
|
|
338
|
+
style: {
|
|
339
|
+
flexDirection: 'row',
|
|
340
|
+
alignItems: 'center'
|
|
341
|
+
}
|
|
342
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
227
343
|
style: {
|
|
228
344
|
padding: 10
|
|
229
345
|
}
|
|
230
346
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
231
347
|
source: {
|
|
232
|
-
uri:
|
|
348
|
+
uri: poll_campaign.campaign_image?.url ?? 'https://res.cloudinary.com/hoabts6mc/image/upload/v1718979933/question_mark_ro0ac5.webp'
|
|
233
349
|
},
|
|
234
350
|
style: {
|
|
235
351
|
height: image_size,
|
|
236
352
|
width: image_size
|
|
237
353
|
},
|
|
238
354
|
resizeMode: "cover"
|
|
239
|
-
}))
|
|
355
|
+
})), /*#__PURE__*/React.createElement(View, {
|
|
240
356
|
style: {
|
|
241
357
|
flex: 1
|
|
358
|
+
}
|
|
359
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
360
|
+
size: 18,
|
|
361
|
+
color: Colors.brand.midnight,
|
|
362
|
+
weight: "bold"
|
|
363
|
+
}, poll_campaign.name), /*#__PURE__*/React.createElement(Text, {
|
|
364
|
+
style: {
|
|
365
|
+
marginTop: 5
|
|
366
|
+
},
|
|
367
|
+
size: 16,
|
|
368
|
+
color: Colors.brand.midnight,
|
|
369
|
+
weight: "semibold"
|
|
370
|
+
}, poll_campaign.total_polls, " Questions")), campaign_complete ? /*#__PURE__*/React.createElement(Button, {
|
|
371
|
+
style: {
|
|
372
|
+
margin: 5
|
|
373
|
+
},
|
|
374
|
+
title: "RESULTS",
|
|
375
|
+
padding: 15,
|
|
376
|
+
backgroundColor: Colors.incentive.gold,
|
|
377
|
+
title_color: Colors.shades.white,
|
|
378
|
+
onPress: () => {
|
|
379
|
+
setData({
|
|
380
|
+
...data,
|
|
381
|
+
show_leaders: true
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
}) : /*#__PURE__*/React.createElement(Button, {
|
|
385
|
+
style: {
|
|
386
|
+
margin: 5
|
|
387
|
+
},
|
|
388
|
+
title: "PLAY",
|
|
389
|
+
padding: 15,
|
|
390
|
+
backgroundColor: Colors.brand.electric,
|
|
391
|
+
title_color: Colors.shades.white,
|
|
392
|
+
onPress: () => {
|
|
393
|
+
if (poll_campaign.campaign_type == 'trivia' && !player_id) {
|
|
394
|
+
return onRequestAuthenticate(poll_campaign.auth_strategy_id, poll_campaign.company_id);
|
|
395
|
+
}
|
|
396
|
+
setData({
|
|
397
|
+
...data,
|
|
398
|
+
active_poll_index: 0
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
})) : /*#__PURE__*/React.createElement(View, null, !hide_progress_bar && poll ? /*#__PURE__*/React.createElement(View, {
|
|
402
|
+
style: {
|
|
403
|
+
backgroundColor: Colors.shades.shade600
|
|
404
|
+
}
|
|
405
|
+
}, /*#__PURE__*/React.createElement(CampaignProgressBar, {
|
|
406
|
+
poll_campaign: poll_campaign,
|
|
407
|
+
poll_responses: poll_responses,
|
|
408
|
+
polls: polls,
|
|
409
|
+
onPollSelect: p => {
|
|
410
|
+
if (poll.status == 'active' && (!poll_response || poll_response.status == 'pending' && poll.seconds_allowed)) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
let index = polls.findIndex(ps => ps.poll_id == p.poll_id);
|
|
414
|
+
setData({
|
|
415
|
+
...data,
|
|
416
|
+
active_poll_index: index
|
|
417
|
+
});
|
|
242
418
|
},
|
|
243
|
-
|
|
419
|
+
active_poll: poll.poll_id
|
|
420
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(View, {
|
|
421
|
+
style: {
|
|
422
|
+
width: flash_size.width,
|
|
423
|
+
flexDirection: 'row',
|
|
424
|
+
flexWrap: 'wrap'
|
|
425
|
+
}
|
|
244
426
|
}, /*#__PURE__*/React.createElement(View, {
|
|
245
427
|
style: {
|
|
428
|
+
flex: 1,
|
|
429
|
+
flexGrow: 2,
|
|
430
|
+
minWidth: 350
|
|
431
|
+
}
|
|
432
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
433
|
+
style: {
|
|
434
|
+
flexDirection: 'row',
|
|
435
|
+
alignItems: 'center',
|
|
246
436
|
padding: 10,
|
|
247
437
|
borderBottomWidth: 1,
|
|
248
438
|
borderBottomColor: Colors.shades.shade600
|
|
249
439
|
}
|
|
250
|
-
}, /*#__PURE__*/React.createElement(
|
|
440
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
441
|
+
style: {
|
|
442
|
+
padding: 10,
|
|
443
|
+
justifyContent: 'center',
|
|
444
|
+
alignItems: 'center'
|
|
445
|
+
}
|
|
446
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
447
|
+
source: {
|
|
448
|
+
uri: poll.poll_image?.url ?? 'https://res.cloudinary.com/hoabts6mc/image/upload/v1718979933/question_mark_ro0ac5.webp'
|
|
449
|
+
},
|
|
450
|
+
style: {
|
|
451
|
+
height: image_size,
|
|
452
|
+
width: image_size
|
|
453
|
+
},
|
|
454
|
+
resizeMode: "center"
|
|
455
|
+
}), poll.status == 'active' && poll.seconds_allowed && (!poll_response || poll_response.status == 'pending') ? /*#__PURE__*/React.createElement(View, {
|
|
456
|
+
style: {
|
|
457
|
+
justifyContent: 'center',
|
|
458
|
+
alignItems: 'center'
|
|
459
|
+
}
|
|
460
|
+
}, /*#__PURE__*/React.createElement(ResponseTimer, {
|
|
461
|
+
poll_id: poll.poll_id,
|
|
462
|
+
seconds: poll.seconds_allowed,
|
|
463
|
+
onTimesUp: () => handleTimesUp()
|
|
464
|
+
})) : /*#__PURE__*/React.createElement(View, {
|
|
465
|
+
style: {
|
|
466
|
+
flexDirection: 'row',
|
|
467
|
+
borderRadius: 22,
|
|
468
|
+
backgroundColor: poll.status == 'active' ? Colors.utility.success : Colors.utility.error,
|
|
469
|
+
padding: 5
|
|
470
|
+
}
|
|
471
|
+
}, poll.status == 'active' ? /*#__PURE__*/React.createElement(Icons.InProgressIcon, {
|
|
472
|
+
size: 18,
|
|
473
|
+
color: Colors.shades.white
|
|
474
|
+
}) : /*#__PURE__*/React.createElement(Icons.LockClosedIcon, {
|
|
475
|
+
size: 16,
|
|
476
|
+
color: Colors.shades.white
|
|
477
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
478
|
+
style: {
|
|
479
|
+
marginLeft: 4
|
|
480
|
+
},
|
|
481
|
+
size: 14,
|
|
482
|
+
color: Colors.shades.white
|
|
483
|
+
}, poll.status.toUpperCase()))), /*#__PURE__*/React.createElement(View, {
|
|
484
|
+
style: {
|
|
485
|
+
flex: 1
|
|
486
|
+
}
|
|
487
|
+
}, loading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
488
|
+
size: "large",
|
|
489
|
+
color: Colors.brand.midnight,
|
|
490
|
+
style: {
|
|
491
|
+
alignSelf: 'center'
|
|
492
|
+
}
|
|
493
|
+
}) : /*#__PURE__*/React.createElement(Text, {
|
|
251
494
|
size: 16,
|
|
252
495
|
color: Colors.brand.midnight,
|
|
253
496
|
weight: "bold"
|
|
254
|
-
}, poll.poll_question)), /*#__PURE__*/React.createElement(View, {
|
|
497
|
+
}, poll.poll_question)))), /*#__PURE__*/React.createElement(View, {
|
|
498
|
+
style: {
|
|
499
|
+
flexGrow: 1,
|
|
500
|
+
flexDirection: 'row'
|
|
501
|
+
}
|
|
502
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
255
503
|
nativeID: "poll_options",
|
|
256
504
|
style: {
|
|
257
505
|
flex: 1,
|
|
506
|
+
maxWidth: flash_size.width,
|
|
258
507
|
padding: 5,
|
|
259
508
|
flexDirection: 'row',
|
|
260
509
|
flexWrap: 'wrap',
|
|
261
|
-
justifyContent: 'center',
|
|
262
510
|
alignItems: 'center'
|
|
263
511
|
}
|
|
264
512
|
}, visible_options.sort((a, b) => a.priority - b.priority).map((po, i) => {
|
|
265
513
|
return renderPollOptions({
|
|
266
514
|
item: po,
|
|
267
515
|
index: i,
|
|
268
|
-
show_summary: poll_response && poll_response.status != 'pending' ? true : false
|
|
516
|
+
show_summary: poll_response && poll_response.status != 'pending' || poll.status == 'closed' ? true : false
|
|
269
517
|
});
|
|
270
|
-
}))
|
|
271
|
-
slide: "horizontal",
|
|
272
|
-
to: 0,
|
|
273
|
-
from: 100
|
|
274
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
518
|
+
})), poll_response?.status == 'pending' ? /*#__PURE__*/React.createElement(View, {
|
|
275
519
|
style: {
|
|
520
|
+
flex: 1,
|
|
276
521
|
justifyContent: 'space-between',
|
|
277
522
|
backgroundColor: Colors.shades.shade600
|
|
278
523
|
}
|
|
@@ -313,8 +558,8 @@ const FlashMarket = ({
|
|
|
313
558
|
},
|
|
314
559
|
autoFocus: true,
|
|
315
560
|
value: poll_response.stake,
|
|
316
|
-
onChangeText: text =>
|
|
317
|
-
...
|
|
561
|
+
onChangeText: text => setPollData({
|
|
562
|
+
...poll_data,
|
|
318
563
|
poll_response: {
|
|
319
564
|
...poll_response,
|
|
320
565
|
stake: text
|
|
@@ -322,24 +567,66 @@ const FlashMarket = ({
|
|
|
322
567
|
})
|
|
323
568
|
}))) : /*#__PURE__*/React.createElement(View, {
|
|
324
569
|
style: {
|
|
325
|
-
flex: 1
|
|
570
|
+
flex: 1,
|
|
571
|
+
padding: 5
|
|
326
572
|
}
|
|
327
|
-
}), /*#__PURE__*/React.createElement(
|
|
573
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
328
574
|
style: {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
575
|
+
flexDirection: 'row'
|
|
576
|
+
}
|
|
577
|
+
}, selected_option ? /*#__PURE__*/React.createElement(Button, {
|
|
578
|
+
title: "X",
|
|
579
|
+
style: {
|
|
580
|
+
borderRadius: 0
|
|
581
|
+
},
|
|
582
|
+
padding: 15,
|
|
583
|
+
title_color: Colors.shades.white,
|
|
584
|
+
backgroundColor: Colors.utility.error,
|
|
585
|
+
onPress: () => handleSelectOption(selected_option)
|
|
586
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(Button, {
|
|
587
|
+
title: "SUBMIT",
|
|
588
|
+
style: {
|
|
589
|
+
flex: 1,
|
|
590
|
+
borderRadius: 0
|
|
591
|
+
},
|
|
592
|
+
padding: 15,
|
|
593
|
+
title_color: Colors.shades.white,
|
|
594
|
+
backgroundColor: Colors.utility.success,
|
|
595
|
+
onPress: () => handleSubmit()
|
|
596
|
+
}))) : /*#__PURE__*/React.createElement(React.Fragment, null))))), next_allowed && !show_leaders ? /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
597
|
+
style: {
|
|
598
|
+
position: 'absolute',
|
|
599
|
+
bottom: 10,
|
|
600
|
+
right: 10,
|
|
601
|
+
backgroundColor: Colors.brand.electric,
|
|
602
|
+
...view_styles.float,
|
|
603
|
+
borderRadius: 100,
|
|
604
|
+
height: 50,
|
|
605
|
+
width: 50,
|
|
334
606
|
justifyContent: 'center',
|
|
335
607
|
alignItems: 'center'
|
|
336
608
|
},
|
|
337
|
-
onPress: () =>
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
609
|
+
onPress: () => {
|
|
610
|
+
if (!active_poll_index && active_poll_index != 0) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
let last_poll = active_poll_index == polls.length - 1 ? true : false;
|
|
614
|
+
if (last_poll && campaign_complete) {
|
|
615
|
+
return setData({
|
|
616
|
+
...data,
|
|
617
|
+
show_leaders: true
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
setData({
|
|
621
|
+
...data,
|
|
622
|
+
active_poll_index: active_poll_index + 1
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}, /*#__PURE__*/React.createElement(Icons.ChevronIcon, {
|
|
626
|
+
direction: "right",
|
|
627
|
+
color: Colors.shades.white,
|
|
628
|
+
size: 18
|
|
629
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null));
|
|
343
630
|
};
|
|
344
631
|
export default FlashMarket;
|
|
345
632
|
//# sourceMappingURL=index.js.map
|