be-components 5.6.8 → 5.7.0
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/FlashMarket/api/index.js +137 -0
- package/lib/commonjs/FlashMarket/api/index.js.map +1 -0
- package/lib/commonjs/FlashMarket/components/FlashMarketHelp.js +91 -0
- package/lib/commonjs/FlashMarket/components/FlashMarketHelp.js.map +1 -0
- package/lib/commonjs/FlashMarket/index.js +660 -0
- package/lib/commonjs/FlashMarket/index.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/FlashMarket/api/index.js +132 -0
- package/lib/module/FlashMarket/api/index.js.map +1 -0
- package/lib/module/FlashMarket/components/FlashMarketHelp.js +84 -0
- package/lib/module/FlashMarket/components/FlashMarketHelp.js.map +1 -0
- package/lib/module/FlashMarket/index.js +651 -0
- package/lib/module/FlashMarket/index.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts +27 -0
- package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/FlashMarket/components/FlashMarketHelp.d.ts +4 -0
- package/lib/typescript/lib/commonjs/FlashMarket/components/FlashMarketHelp.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts +15 -0
- package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/FlashMarket/api/index.d.ts +26 -0
- package/lib/typescript/lib/module/FlashMarket/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/FlashMarket/components/FlashMarketHelp.d.ts +4 -0
- package/lib/typescript/lib/module/FlashMarket/components/FlashMarketHelp.d.ts.map +1 -0
- package/lib/typescript/lib/module/FlashMarket/index.d.ts +17 -0
- package/lib/typescript/lib/module/FlashMarket/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/FlashMarket/api/index.d.ts +32 -0
- package/lib/typescript/src/FlashMarket/api/index.d.ts.map +1 -0
- package/lib/typescript/src/FlashMarket/components/FlashMarketHelp.d.ts +5 -0
- package/lib/typescript/src/FlashMarket/components/FlashMarketHelp.d.ts.map +1 -0
- package/lib/typescript/src/FlashMarket/index.d.ts +22 -0
- package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/FlashMarket/api/index.ts +95 -0
- package/src/FlashMarket/components/FlashMarketHelp.tsx +41 -0
- package/src/FlashMarket/index.tsx +415 -0
- package/src/index.tsx +2 -0
- package/src/types.d.ts +4 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Button, Text, TextInput, View } from "../Components/Themed";
|
|
3
|
+
import type { LocationProps, PollCampaignProps, PollOptionProps, PollProps, PollResponseProps, PollSummaryProps, PublicPlayerProps } from '../types';
|
|
4
|
+
import { FlashMarketApi, FlashMarketHelpers } from './api';
|
|
5
|
+
import { Icons } from '../Components';
|
|
6
|
+
import { useColors } from '../constants/useColors';
|
|
7
|
+
import { ActivityIndicator, FlatList, Image } from 'react-native';
|
|
8
|
+
import FlashMarketHelp from './components/FlashMarketHelp';
|
|
9
|
+
import SocketManager from '../Socket';
|
|
10
|
+
import moment from 'moment-mini';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
type FlashMarketProps = {
|
|
14
|
+
poll_id:string,
|
|
15
|
+
init_expanded?:boolean,
|
|
16
|
+
location?:LocationProps,
|
|
17
|
+
header_style?:any,
|
|
18
|
+
footer_style?:any,
|
|
19
|
+
player_id?:string
|
|
20
|
+
player?:PublicPlayerProps,
|
|
21
|
+
onRequestLocation:() => void,
|
|
22
|
+
onFocusPosition?: (position:{ x:number, y:number, width:number, height:number }) => void,
|
|
23
|
+
onRequestAuthenticate: () => void
|
|
24
|
+
}
|
|
25
|
+
const FlashMarket = ({ poll_id, init_expanded, header_style, footer_style, location, player, player_id, onRequestAuthenticate, onFocusPosition, onRequestLocation }:FlashMarketProps) => {
|
|
26
|
+
const Colors = useColors();
|
|
27
|
+
const [ needs_reload, setNeedsReload ] = useState(false);
|
|
28
|
+
const [ socket_summaries, setSocketSummaries ] = useState<PollSummaryProps[]>([]);
|
|
29
|
+
const [ socket_campaign, setSocketCampaign ] = useState<PollCampaignProps|undefined>(undefined);
|
|
30
|
+
const [ socket_poll_options, setSocketPollOptions ] = useState<PollOptionProps[]>([]);
|
|
31
|
+
const [ socket_polls, setSocketPolls ] = useState<PollProps[]>([]);
|
|
32
|
+
const [ expanded, setExpanded ] = useState(false);
|
|
33
|
+
const [ show_help, setShowHelp ] = useState(false);
|
|
34
|
+
const [ action_loading, setActionLoading ] = useState(false);
|
|
35
|
+
const [ draft_data, setDraftData ] = useState<{
|
|
36
|
+
stake: string
|
|
37
|
+
}>({
|
|
38
|
+
stake: '0'
|
|
39
|
+
})
|
|
40
|
+
const [ market_data, setMarketData ] = useState<{
|
|
41
|
+
loading:boolean,
|
|
42
|
+
poll?:PollProps,
|
|
43
|
+
poll_campaign?:PollCampaignProps,
|
|
44
|
+
poll_options:PollOptionProps[],
|
|
45
|
+
poll_summaries:PollSummaryProps[]
|
|
46
|
+
}>({
|
|
47
|
+
loading:false,
|
|
48
|
+
poll_options:[],
|
|
49
|
+
poll_summaries:[]
|
|
50
|
+
});
|
|
51
|
+
const { loading, poll, poll_options, poll_summaries, poll_campaign } = market_data;
|
|
52
|
+
const cl = poll_campaign?.market_type == 'FOR_MONEY' ? '$' : 'E'
|
|
53
|
+
const [ my_data, setMyData ] = useState<{
|
|
54
|
+
me_loading:boolean,
|
|
55
|
+
my_response?:PollResponseProps
|
|
56
|
+
}>({
|
|
57
|
+
me_loading:false
|
|
58
|
+
});
|
|
59
|
+
const { me_loading, my_response } = my_data;
|
|
60
|
+
const [ selected_option, setSelectedOption ] = useState<PollOptionProps | undefined>(undefined);
|
|
61
|
+
|
|
62
|
+
const allow_order = my_response || poll?.winning_option_id ? false : true
|
|
63
|
+
const potential_winnings = FlashMarketHelpers.calcPotentialWinnings(selected_option?.parimutuel_odds, draft_data.stake);
|
|
64
|
+
const order_valid = FlashMarketHelpers.isValid(poll, draft_data.stake);
|
|
65
|
+
const visible_options = poll_options.filter(po => po.status != 'inactive').sort((a,b) => a.priority - b.priority)
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
FlashMarketApi.setEnvironment();
|
|
68
|
+
loadMarket(poll_id);
|
|
69
|
+
},[poll_id]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if(!poll || !player_id){ return }
|
|
73
|
+
loadMyData();
|
|
74
|
+
},[poll, player_id]);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if(socket_summaries.length == 0){ return }
|
|
78
|
+
if(!poll){ return }
|
|
79
|
+
let same_options = socket_summaries.filter(p => p.poll_id == poll_id);
|
|
80
|
+
if(same_options.length == 0){ return }
|
|
81
|
+
//See if we have that poll!
|
|
82
|
+
setMarketData({
|
|
83
|
+
...market_data,
|
|
84
|
+
poll_summaries: poll_summaries.filter(po => !same_options.find(so => so.poll_option_id == po.poll_option_id)).concat(same_options)
|
|
85
|
+
})
|
|
86
|
+
},[JSON.stringify(socket_summaries)])
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if(!socket_campaign){ return }
|
|
90
|
+
if(!poll_campaign){ return }
|
|
91
|
+
if(poll_campaign.poll_campaign_id != socket_campaign.poll_campaign_id){ return }
|
|
92
|
+
setMarketData({
|
|
93
|
+
...market_data,
|
|
94
|
+
poll_campaign: socket_campaign
|
|
95
|
+
})
|
|
96
|
+
},[socket_campaign]);
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if(socket_polls.length == 0){ return }
|
|
100
|
+
if(!poll){ return }
|
|
101
|
+
let same_poll = socket_polls.find(p => p.poll_id == poll.poll_id);
|
|
102
|
+
if(!same_poll){ return }
|
|
103
|
+
if(same_poll.status == 'active' && poll.status == 'pending'){ loadMarket(poll_id); return }
|
|
104
|
+
//See if we have that poll!
|
|
105
|
+
setMarketData({ ...market_data, poll: same_poll })
|
|
106
|
+
}, [JSON.stringify(socket_polls)])
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if(socket_poll_options.length == 0){ return }
|
|
110
|
+
if(!poll){ return }
|
|
111
|
+
let same_options = socket_poll_options.filter(p => p.poll_id == poll.poll_id);
|
|
112
|
+
if(same_options.length == 0){ return }
|
|
113
|
+
//See if we have that poll!
|
|
114
|
+
setMarketData({
|
|
115
|
+
...market_data,
|
|
116
|
+
poll_options: poll_options.filter(po => !same_options.find(so => so.poll_option_id == po.poll_option_id)).concat(same_options)
|
|
117
|
+
})
|
|
118
|
+
}, [JSON.stringify(socket_poll_options)])
|
|
119
|
+
|
|
120
|
+
const loadMarket = async(id:string) => {
|
|
121
|
+
setMarketData({ ...market_data, loading: true })
|
|
122
|
+
const pr = await FlashMarketApi.getPollById(id);
|
|
123
|
+
if(!pr){ return }
|
|
124
|
+
const pc = await FlashMarketApi.getPollCampaignById(pr.poll.poll_campaign_id);
|
|
125
|
+
setMarketData({
|
|
126
|
+
...market_data,
|
|
127
|
+
poll: pr.poll,
|
|
128
|
+
poll_campaign:pc,
|
|
129
|
+
poll_options:pr.poll_options,
|
|
130
|
+
poll_summaries: pr.poll_summaries,
|
|
131
|
+
loading:false
|
|
132
|
+
});
|
|
133
|
+
setDraftData({ ...draft_data, stake: pr.poll.minimum_stake.toFixed(2) });
|
|
134
|
+
if(init_expanded){ setExpanded(true) }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const handleSubmit = async(poll_option:PollOptionProps) => {
|
|
138
|
+
if(!player_id){ return onRequestAuthenticate() }
|
|
139
|
+
if(!order_valid){ return }
|
|
140
|
+
if(action_loading){ return }
|
|
141
|
+
if(!poll_campaign){ return }
|
|
142
|
+
if(poll_campaign.market_type == 'FOR_MONEY'){
|
|
143
|
+
if(!location){ return onRequestLocation() }
|
|
144
|
+
if(!location.legal_ind){ return alert(`Real money flash markets are not available in your current location`) }
|
|
145
|
+
}
|
|
146
|
+
setActionLoading(true);
|
|
147
|
+
let stake_num = parseFloat(draft_data.stake);
|
|
148
|
+
const response = await FlashMarketApi.createPMOrder(poll_option.poll_option_id, stake_num);
|
|
149
|
+
if(!response){ return alert('Unable to process order') }
|
|
150
|
+
setMyData({
|
|
151
|
+
...my_data,
|
|
152
|
+
my_response: response.poll_response
|
|
153
|
+
});
|
|
154
|
+
setSelectedOption(undefined);
|
|
155
|
+
setActionLoading(false)
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const generateResultIcon = (option:PollOptionProps) => {
|
|
160
|
+
switch(option.result_ind){
|
|
161
|
+
case 'win':
|
|
162
|
+
return (
|
|
163
|
+
<Icons.CheckIcon color={Colors.text.success} size={18} />
|
|
164
|
+
)
|
|
165
|
+
case 'lose':
|
|
166
|
+
return (
|
|
167
|
+
<Icons.CloseIcon color={Colors.text.error} size={14} />
|
|
168
|
+
)
|
|
169
|
+
case 'draw':
|
|
170
|
+
return (
|
|
171
|
+
<Icons.AlertIcon color={Colors.text.h1} size={18}/>
|
|
172
|
+
)
|
|
173
|
+
default: return <></>
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const generateStatusIcon = (poll:PollProps) => {
|
|
178
|
+
switch(poll.status){
|
|
179
|
+
case 'active': return <Icons.ActivityIcon size={18} color={Colors.text.success} />
|
|
180
|
+
case 'paused': return <Icons.PausedIcon size={18} color={Colors.text.h1} />
|
|
181
|
+
case 'closed': return <Icons.LockClosedIcon size={18} color={Colors.text.h1}/>
|
|
182
|
+
default: return <Icons.AlertIcon size={18} color={Colors.text.warning} />
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const getColor = (number:number) => {
|
|
187
|
+
if(number > 0){ return Colors.text.success }
|
|
188
|
+
if(number < 0){ return Colors.text.error }
|
|
189
|
+
return Colors.text.h1
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const loadMyData = async() => {
|
|
193
|
+
if(!poll){ return }
|
|
194
|
+
setMyData({ ...my_data, me_loading: true });
|
|
195
|
+
let responses = await FlashMarketApi.getMyCampaignResponses(poll.poll_campaign_id);
|
|
196
|
+
let response = responses.find(r => r.poll_id == poll_id);
|
|
197
|
+
setMyData({ ...my_data, me_loading: false, my_response:response })
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const renderOptions = (data:{ item:PollOptionProps, index:number }) => {
|
|
201
|
+
const my_option = data.item.poll_option_id == my_response?.poll_option_id ? my_response : undefined
|
|
202
|
+
const response_stats = FlashMarketHelpers.getResponseStats(data.item, my_option);
|
|
203
|
+
const selected = selected_option?.poll_option_id == data.item.poll_option_id ? true : false
|
|
204
|
+
return (
|
|
205
|
+
<View transparent style={{ borderRadius:8, flexDirection:'row', alignItems:'center', borderWidth:my_option?1:0, borderColor:Colors.text.action, padding:10 }}>
|
|
206
|
+
{my_option ?
|
|
207
|
+
<View transparent style={{ marginRight:10 }}>
|
|
208
|
+
{player ?
|
|
209
|
+
<Image
|
|
210
|
+
source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
|
|
211
|
+
style={{ height:30, width:30, borderRadius:4 }}
|
|
212
|
+
resizeMode='cover'
|
|
213
|
+
/>
|
|
214
|
+
:
|
|
215
|
+
<Icons.UserIcon color={Colors.text.action} size={14} />
|
|
216
|
+
}
|
|
217
|
+
</View>
|
|
218
|
+
:<></>}
|
|
219
|
+
<View transparent style={{ flex:1 }}>
|
|
220
|
+
<Text theme='h1'>{data.item.option_name}</Text>
|
|
221
|
+
{selected && data.item.parimutuel_odds && data.item.parimutuel_odds > 0 ?
|
|
222
|
+
<Text theme='h2' style={{ marginTop:3 }} color={Colors.text.action}>${draft_data.stake} to win ${potential_winnings.toFixed(2)}</Text>
|
|
223
|
+
:<></>}
|
|
224
|
+
</View>
|
|
225
|
+
{!selected ?
|
|
226
|
+
<View transparent style={{ marginRight:10, marginLeft:10 }}>
|
|
227
|
+
<Text theme='h1' color={Colors.text.action}>{((data.item.parimutuel_odds ?? 0)*100).toFixed(2)}%</Text>
|
|
228
|
+
</View>
|
|
229
|
+
:<></>}
|
|
230
|
+
{selected ?
|
|
231
|
+
<View transparent style={{ flexDirection:'row' }}>
|
|
232
|
+
<TextInput
|
|
233
|
+
onFocusPosition={onFocusPosition}
|
|
234
|
+
onChangeText={(text) => setDraftData({ ...draft_data, stake: text })}
|
|
235
|
+
style={{ width: 75, textAlign:'center', padding:10 }}
|
|
236
|
+
value={draft_data.stake}
|
|
237
|
+
/>
|
|
238
|
+
<Button
|
|
239
|
+
type='success'
|
|
240
|
+
disabled={!order_valid || action_loading}
|
|
241
|
+
loading={action_loading}
|
|
242
|
+
style={{ padding:10, marginLeft:10, opacity:order_valid && !action_loading?1:0.5 }}
|
|
243
|
+
title='SUBMIT'
|
|
244
|
+
onPress={() => handleSubmit(data.item)}
|
|
245
|
+
/>
|
|
246
|
+
<Button
|
|
247
|
+
title='X'
|
|
248
|
+
style={{ padding:10, marginLeft:10 }}
|
|
249
|
+
transparent
|
|
250
|
+
title_color={Colors.text.error}
|
|
251
|
+
onPress={() => setSelectedOption(undefined)}
|
|
252
|
+
/>
|
|
253
|
+
</View>
|
|
254
|
+
:
|
|
255
|
+
<View transparent>
|
|
256
|
+
{!loading && !me_loading && allow_order ?
|
|
257
|
+
<Button
|
|
258
|
+
type='action'
|
|
259
|
+
disabled={action_loading}
|
|
260
|
+
style={{ padding:10 }}
|
|
261
|
+
onPress={() => setSelectedOption(data.item)}
|
|
262
|
+
>
|
|
263
|
+
<Text theme='h1' color={Colors.text.white}>Buy</Text>
|
|
264
|
+
</Button>
|
|
265
|
+
:<></>}
|
|
266
|
+
</View>
|
|
267
|
+
}
|
|
268
|
+
{data.item.result_ind ?
|
|
269
|
+
<View transparent style={{ padding:10 }}>
|
|
270
|
+
{generateResultIcon(data.item)}
|
|
271
|
+
</View>
|
|
272
|
+
:<></>}
|
|
273
|
+
{my_option?.result_ind ?
|
|
274
|
+
<View float style={{ justifyContent:'center', alignItems:'center', padding:5 }}>
|
|
275
|
+
<Text theme='h2' textAlign='center' color={getColor(response_stats.earnings)}>{cl}{response_stats.earnings.toFixed(2)}</Text>
|
|
276
|
+
<Text theme='description' textAlign='center' color={getColor(response_stats.earnings)}>Earnings</Text>
|
|
277
|
+
</View>
|
|
278
|
+
: my_option ?
|
|
279
|
+
<View float style={{ justifyContent:'center', alignItems:'center', padding:5 }}>
|
|
280
|
+
<Text theme='h2' textAlign='center' color={Colors.text.h1}>{cl}{response_stats.stake.toFixed(2)} to win {cl}{response_stats.potential_winnings.toFixed(2)}</Text>
|
|
281
|
+
</View>
|
|
282
|
+
:<></>}
|
|
283
|
+
{me_loading ?
|
|
284
|
+
<ActivityIndicator size={'small'} color={Colors.text.h1} />
|
|
285
|
+
:<></>}
|
|
286
|
+
</View>
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if(!poll || loading){ return <></> }
|
|
291
|
+
const stats = FlashMarketHelpers.getStats(poll_summaries);
|
|
292
|
+
return (
|
|
293
|
+
<View transparent>
|
|
294
|
+
<Button
|
|
295
|
+
style={{ backgroundColor:Colors.views.header, padding:10, flexDirection:'row', alignItems:'center', ...header_style }}
|
|
296
|
+
onPress={() => setExpanded(!expanded)}>
|
|
297
|
+
{poll.poll_image ?
|
|
298
|
+
<Image
|
|
299
|
+
source={{ uri: poll.poll_image?.url }}
|
|
300
|
+
style={{ height:50, width:50 }}
|
|
301
|
+
resizeMode='cover'
|
|
302
|
+
/>
|
|
303
|
+
:
|
|
304
|
+
<Icons.FlameIcon color={Colors.text.warning} size={24} />
|
|
305
|
+
}
|
|
306
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
307
|
+
<Text theme='h1'>{poll.poll_question}</Text>
|
|
308
|
+
<Text theme='h2' style={{ marginTop:4 }}>Flash Market🔥🔥</Text>
|
|
309
|
+
</View>
|
|
310
|
+
{generateStatusIcon(poll)}
|
|
311
|
+
<Button
|
|
312
|
+
transparent
|
|
313
|
+
disabled
|
|
314
|
+
onPress={() => console.log('')}
|
|
315
|
+
>
|
|
316
|
+
<Icons.ChevronIcon direction={expanded ? 'up' : 'down'} size={8} color={Colors.text.action} />
|
|
317
|
+
</Button>
|
|
318
|
+
</Button>
|
|
319
|
+
<View transparent type='body'>
|
|
320
|
+
{show_help ?
|
|
321
|
+
<View transparent>
|
|
322
|
+
<FlashMarketHelp />
|
|
323
|
+
</View>
|
|
324
|
+
:
|
|
325
|
+
<View transparent>
|
|
326
|
+
{expanded ?
|
|
327
|
+
<View transparent type='body' style={{ padding:10, minHeight:100 }}>
|
|
328
|
+
<FlatList
|
|
329
|
+
data={visible_options}
|
|
330
|
+
key={`poll_${poll_id}_options`}
|
|
331
|
+
renderItem={renderOptions}
|
|
332
|
+
keyExtractor={(item) => item.poll_option_id.toString()}
|
|
333
|
+
/>
|
|
334
|
+
{['paused','pending'].includes(poll.status) ?
|
|
335
|
+
<View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, justifyContent:'center', alignItems:'center' }}>
|
|
336
|
+
<View float style={{ flexDirection:'row', alignItems:'center', padding:20 }}>
|
|
337
|
+
<Icons.PausedIcon size={35} color={Colors.text.h1} />
|
|
338
|
+
<View transparent style={{ marginLeft:20 }}>
|
|
339
|
+
<Text theme='h1'>Market Is Inactive</Text>
|
|
340
|
+
{poll.poll_open_time ?
|
|
341
|
+
<Text theme='warning'>Market opens at {moment(poll.poll_open_time).format('MMM DD hh:mm a')}</Text>
|
|
342
|
+
:<></>}
|
|
343
|
+
</View>
|
|
344
|
+
</View>
|
|
345
|
+
</View>
|
|
346
|
+
:<></>}
|
|
347
|
+
</View>
|
|
348
|
+
:<></>}
|
|
349
|
+
</View>
|
|
350
|
+
}
|
|
351
|
+
</View>
|
|
352
|
+
{expanded ?
|
|
353
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, ...footer_style }}>
|
|
354
|
+
<Button transparent style={{ justifyContent:'center', alignItems:'center', borderRadius:0, padding:5, paddingRight:10, marginRight:10, borderRightWidth:1, borderColor:Colors.borders.light }}
|
|
355
|
+
onPress={() => setShowHelp(!show_help)}>
|
|
356
|
+
<Icons.AlertIcon color={show_help?Colors.text.error:Colors.text.warning} size={18} />
|
|
357
|
+
<Text style={{ marginTop:2 }} theme='description' color={show_help?Colors.text.error:Colors.text.warning} textAlign='center'>{show_help?'CLOSE':'HELP'}</Text>
|
|
358
|
+
</Button>
|
|
359
|
+
<View transparent style={{ justifyContent:'center', alignItems:'center', padding:5, paddingRight:10, marginRight:10, borderRightWidth:1, borderColor:Colors.borders.light }}>
|
|
360
|
+
<Text theme='h1' color={Colors.text.action} textAlign='center'>${(poll.minimum_stake).toFixed(2)}</Text>
|
|
361
|
+
<Text style={{ marginTop:2 }} theme='description' textAlign='center'>MIN STAKE</Text>
|
|
362
|
+
</View>
|
|
363
|
+
<View transparent style={{ justifyContent:'center', alignItems:'center', padding:5, paddingRight:10, marginRight:10, borderRightWidth:1, borderColor:Colors.borders.light }}>
|
|
364
|
+
<Text theme='h1' color={Colors.text.action} textAlign='center'>${(poll.max_stake).toFixed(2)}</Text>
|
|
365
|
+
<Text style={{ marginTop:2 }} theme='description' textAlign='center'>MAX STAKE</Text>
|
|
366
|
+
</View>
|
|
367
|
+
<View style={{ flex:1 }} />
|
|
368
|
+
<View transparent style={{ justifyContent:'center', alignItems:'center', padding:5 }}>
|
|
369
|
+
<Text theme='h1' color={Colors.text.success} textAlign='center'>${stats.total_staked.toFixed(2)}</Text>
|
|
370
|
+
<Text style={{ marginTop:2 }} theme='description' textAlign='center'>TOTAL</Text>
|
|
371
|
+
</View>
|
|
372
|
+
</View>
|
|
373
|
+
:<></>}
|
|
374
|
+
<SocketManager
|
|
375
|
+
onConnect={() => {
|
|
376
|
+
if(needs_reload){
|
|
377
|
+
setNeedsReload(false);
|
|
378
|
+
return loadMarket(poll_id)
|
|
379
|
+
}
|
|
380
|
+
return
|
|
381
|
+
}}
|
|
382
|
+
onDisconnect={() => setNeedsReload(true)}
|
|
383
|
+
onSocketEvent={(ev) => {
|
|
384
|
+
switch(ev.type){
|
|
385
|
+
case 'UPDATE_POLL_CAMPAIGNS':
|
|
386
|
+
if(!poll_campaign){ return }
|
|
387
|
+
let pc = ev.poll_campaigns.find((pc:PollCampaignProps) => pc.poll_campaign_id == poll_campaign.poll_campaign_id);
|
|
388
|
+
if(!pc){ return }
|
|
389
|
+
setSocketCampaign(pc)
|
|
390
|
+
break;
|
|
391
|
+
case 'UPDATE_POLLS':
|
|
392
|
+
if(ev.polls.length == 0){ return }
|
|
393
|
+
if(!ev.polls[0]){ return }
|
|
394
|
+
setSocketPolls(ev.polls)
|
|
395
|
+
break
|
|
396
|
+
case 'UPDATE_POLL_OPTIONS':
|
|
397
|
+
if(ev.poll_options.length == 0){ return }
|
|
398
|
+
let these_options = ev.poll_options.filter((po:PollOptionProps) => po.poll_id == poll_id);
|
|
399
|
+
setSocketPollOptions(these_options)
|
|
400
|
+
break
|
|
401
|
+
case 'UPDATE_POLL_SUMMARIES':
|
|
402
|
+
if(ev.poll_summaries.length == 0){ return }
|
|
403
|
+
let these_summaries = ev.poll_summaries.filter((ps:PollSummaryProps) => ps.poll_id == poll_id);
|
|
404
|
+
setSocketSummaries(these_summaries);
|
|
405
|
+
break
|
|
406
|
+
default: break;
|
|
407
|
+
}
|
|
408
|
+
}}
|
|
409
|
+
subscribed_events={['UPDATE_POLL_CAMPAIGNS', 'UPDATE_POLLS','UPDATE_POLL_OPTIONS', 'UPDATE_POLL_SUMMARIES']}
|
|
410
|
+
/>
|
|
411
|
+
</View>
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export default FlashMarket
|
package/src/index.tsx
CHANGED
|
@@ -47,6 +47,7 @@ import PlayerRecommender from './PlayerRecommender';
|
|
|
47
47
|
import ContactsCard from './PlayerRecommender/components/ContactCard';
|
|
48
48
|
import ContactsSelector from './PlayerRecommender/components/ContactsSelector';
|
|
49
49
|
import GolfScoreboard from './GolfScoreboard';
|
|
50
|
+
import FlashMarket from './FlashMarket';
|
|
50
51
|
|
|
51
52
|
export {
|
|
52
53
|
Authenticator,
|
|
@@ -56,6 +57,7 @@ export {
|
|
|
56
57
|
Ticker,
|
|
57
58
|
LeaderboardCard,
|
|
58
59
|
LocationTracker,
|
|
60
|
+
FlashMarket,
|
|
59
61
|
ContactsCard,
|
|
60
62
|
PlayerRecommender,
|
|
61
63
|
GolfScoreboard,
|
package/src/types.d.ts
CHANGED
|
@@ -728,6 +728,7 @@ export interface PollCampaignProps {
|
|
|
728
728
|
company_id?:string,
|
|
729
729
|
admins:string[],
|
|
730
730
|
phone:string,
|
|
731
|
+
market_type:'FREE'|'FOR_MONEY',
|
|
731
732
|
total_responses:number,
|
|
732
733
|
prize_image?:any,
|
|
733
734
|
prize_override?:string,
|
|
@@ -796,8 +797,11 @@ export interface PollProps {
|
|
|
796
797
|
poll_question: string,
|
|
797
798
|
market_type:'FOR_MONEY'|'FREE',
|
|
798
799
|
status:string,
|
|
800
|
+
minimum_pool?:number,
|
|
801
|
+
poll_open_time?:any,
|
|
799
802
|
coupon_campaign_id?:string,
|
|
800
803
|
coupon_payout_type?:any,
|
|
804
|
+
max_stake:number,
|
|
801
805
|
require_resolution?:boolean,
|
|
802
806
|
tie_breaker?:boolean,
|
|
803
807
|
poll_type: 'select'|'input',
|