be-components 7.3.8 → 7.4.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.
Files changed (39) hide show
  1. package/lib/commonjs/FlashMarket/FlashHolder.js +3 -1
  2. package/lib/commonjs/FlashMarket/FlashHolder.js.map +1 -1
  3. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js +36 -2
  4. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js.map +1 -1
  5. package/lib/commonjs/FlashMarket/index.js +88 -38
  6. package/lib/commonjs/FlashMarket/index.js.map +1 -1
  7. package/lib/commonjs/PartnerPortal/components/EmbedManager.js +42 -0
  8. package/lib/commonjs/PartnerPortal/components/EmbedManager.js.map +1 -1
  9. package/lib/module/FlashMarket/FlashHolder.js +3 -1
  10. package/lib/module/FlashMarket/FlashHolder.js.map +1 -1
  11. package/lib/module/FlashMarket/components/ManageFlashMarket.js +36 -2
  12. package/lib/module/FlashMarket/components/ManageFlashMarket.js.map +1 -1
  13. package/lib/module/FlashMarket/index.js +88 -38
  14. package/lib/module/FlashMarket/index.js.map +1 -1
  15. package/lib/module/PartnerPortal/components/EmbedManager.js +43 -1
  16. package/lib/module/PartnerPortal/components/EmbedManager.js.map +1 -1
  17. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts +2 -1
  18. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts.map +1 -1
  19. package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
  20. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts +2 -1
  21. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts.map +1 -1
  22. package/lib/typescript/lib/commonjs/PartnerPortal/components/EmbedManager.d.ts.map +1 -1
  23. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts +2 -1
  24. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts.map +1 -1
  25. package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
  26. package/lib/typescript/lib/module/FlashMarket/index.d.ts +2 -1
  27. package/lib/typescript/lib/module/FlashMarket/index.d.ts.map +1 -1
  28. package/lib/typescript/lib/module/PartnerPortal/components/EmbedManager.d.ts.map +1 -1
  29. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts +2 -1
  30. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts.map +1 -1
  31. package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
  32. package/lib/typescript/src/FlashMarket/index.d.ts +2 -1
  33. package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -1
  34. package/lib/typescript/src/PartnerPortal/components/EmbedManager.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/FlashMarket/FlashHolder.tsx +6 -2
  37. package/src/FlashMarket/components/ManageFlashMarket.tsx +18 -2
  38. package/src/FlashMarket/index.tsx +53 -25
  39. package/src/PartnerPortal/components/EmbedManager.tsx +20 -1
@@ -8,6 +8,7 @@ import { ActivityIndicator, Alert, FlatList, Image, type ViewStyle } from 'react
8
8
  import FlashMarketHelp from './components/FlashMarketHelp';
9
9
  import moment from 'moment-mini';
10
10
  import MarketTimer from './components/MarketTimer';
11
+ import { MarketComponentHelpers } from '../MarketComponents/api';
11
12
 
12
13
  type FlashMarketProps = {
13
14
  loading:boolean,
@@ -18,6 +19,7 @@ type FlashMarketProps = {
18
19
  flash_market_fees:FlashMarketFeeProps[],
19
20
  hide_image?:boolean,
20
21
  location?:LocationProps,
22
+ wrap_options?:boolean,
21
23
  card_style?:any,
22
24
  onManageFlash?:(poll:PollProps) => void,
23
25
  init_expanded?:boolean,
@@ -32,8 +34,10 @@ type FlashMarketProps = {
32
34
  onFocusPosition?: (position:{ x:number, y:number, width:number, height:number }) => void,
33
35
  onRequestAuthenticate: () => void
34
36
  }
35
- const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, poll_summaries, poll_campaign, flash_market_fees, hide_image, init_expanded, card_style, header_style, footer_style, onReload, location, player, player_id, onManageFlash, onRequestAuthenticate, onFocusPosition, onRequestLocation }:FlashMarketProps) => {
37
+ const MIN_OPTION_WIDTH = 300
38
+ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, wrap_options, poll_options, poll_summaries, poll_campaign, flash_market_fees, hide_image, init_expanded, card_style, header_style, footer_style, onReload, location, player, player_id, onManageFlash, onRequestAuthenticate, onFocusPosition, onRequestLocation }:FlashMarketProps) => {
36
39
  const Colors = useColors();
40
+ const [ size, setSize ] = useState({ width:0, height:0 });
37
41
  const [ admin_action, setAdminActions ] = useState<{
38
42
  selected_option_id?:string,
39
43
  admin_loading:boolean
@@ -64,7 +68,9 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
64
68
  const potential_winnings = FlashMarketHelpers.calcPotentialWinnings(selected_option?.parimutuel_odds, draft_stake.toFixed(2));
65
69
  const order_valid = FlashMarketHelpers.isValid(my_responses, poll, draft_data.stake, selected_option?.poll_option_id);
66
70
  const visible_options = poll_options.filter(po => po.status != 'inactive').sort((a,b) => a.priority - b.priority)
71
+ const num_options_per_row = Math.floor((size.width-20) / MIN_OPTION_WIDTH)
67
72
 
73
+ const option_width = ((size.width-20) / num_options_per_row) - (4*num_options_per_row)
68
74
  const is_inactive = poll && ['pending','paused'].includes(poll?.status) ? true : false
69
75
  const is_upcoming = poll && poll.start_datetime && moment().isBefore(moment(poll.start_datetime)) ? true : false
70
76
  const is_admin = player?.role == 'admin' ? true : poll?.admins && poll.admins.includes(player?.player_id ?? '0') ? true : false
@@ -206,7 +212,9 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
206
212
  const selected = selected_option?.poll_option_id == data.item.poll_option_id ? true : false
207
213
  const admin_checked = selected_option_id == data.item.poll_option_id ? true : false
208
214
  return (
209
- <View transparent style={{ borderRadius:8, flexDirection:'row', alignItems:'center', borderWidth:my_option?1:0, borderColor:Colors.text.action, padding:10 }}>
215
+ <View float style={{ width:option_width, margin:2, borderRadius:8,borderWidth:my_option?1:0, borderColor:Colors.text.action, padding:10 }}>
216
+
217
+ <View transparent key={data.item.poll_option_id.toString()} style={{ flexDirection:'row', alignItems:'center' }}>
210
218
  {!selected && poll?.status != 'closed' && is_admin ?
211
219
  <Checkbox
212
220
  style={{ marginRight:5 }}
@@ -238,30 +246,14 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
238
246
  </View>
239
247
  {!selected ?
240
248
  <View transparent style={{ marginRight:10, marginLeft:10, alignItems:'flex-end' }}>
241
- <Text theme='h1' color={Colors.text.action}>{((data.item.parimutuel_odds ?? 0)*100).toFixed(2)}%</Text>
242
- {my_option?.result_ind ?
243
- <Text style={{ marginTop:3 }} theme='h2' color={getColor(response_stats.earnings)}>{cl}{response_stats.earnings.toFixed(2)} Earned</Text>
244
- : my_option ?
245
- <Text style={{ marginTop:3 }} theme='h2' color={Colors.text.h1}>{cl}{response_stats.stake.toFixed(2)} to win {cl}{response_stats.potential_winnings.toFixed(2)}*</Text>
246
- :<></>}
249
+ <View transparent style={{ alignItems:'flex-end' }}>
250
+ <Text theme='h2'>{((data.item.parimutuel_odds ?? 0)*100).toFixed(2)}%</Text>
251
+ <Text theme='description' style={{ marginTop:3 }}>{MarketComponentHelpers.getOddsLabel(MarketComponentHelpers.calcAmericanOddsFromProbability(data.item.parimutuel_odds ?? 0))}</Text>
252
+ </View>
247
253
  </View>
248
254
  :<></>}
249
255
  {selected ?
250
- <View transparent style={{ flexDirection:'row' }}>
251
- <TextInput
252
- onFocusPosition={onFocusPosition}
253
- onChangeText={(text) => setDraftData({ ...draft_data, stake: text })}
254
- style={{ width: 75, textAlign:'center', padding:10 }}
255
- value={draft_data.stake}
256
- />
257
- <Button
258
- type='success'
259
- disabled={!order_valid || action_loading}
260
- loading={action_loading}
261
- style={{ padding:10, marginLeft:10, opacity:order_valid && !action_loading?1:0.5 }}
262
- title='SUBMIT'
263
- onPress={() => handleSubmit(data.item)}
264
- />
256
+ <View transparent>
265
257
  <Button
266
258
  title='X'
267
259
  style={{ padding:10, marginLeft:10 }}
@@ -279,7 +271,7 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
279
271
  style={{ padding:10 }}
280
272
  onPress={() => setSelectedOption(data.item)}
281
273
  >
282
- <Text theme='h1' color={Colors.text.white}>{my_option ? 'ADD' : 'BUY'}</Text>
274
+ <Text theme='h2' color={Colors.text.white}>{my_option ? 'ADD' : 'BUY'}</Text>
283
275
  </Button>
284
276
  :<></>}
285
277
  </View>
@@ -290,6 +282,31 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
290
282
  </View>
291
283
  :<></>}
292
284
  </View>
285
+ {selected ?
286
+ <View transparent style={{ flexDirection:'row', alignItems:'center', marginTop:10 }}>
287
+ <TextInput
288
+ onFocusPosition={onFocusPosition}
289
+ onChangeText={(text) => setDraftData({ ...draft_data, stake: text })}
290
+ style={{ flex:1, textAlign:'center', padding:10 }}
291
+ value={draft_data.stake}
292
+ />
293
+ <Button
294
+ type='success'
295
+ disabled={!order_valid || action_loading}
296
+ loading={action_loading}
297
+ style={{ padding:10, marginLeft:10, opacity:order_valid && !action_loading?1:0.5 }}
298
+ title='SUBMIT'
299
+ onPress={() => handleSubmit(data.item)}
300
+ />
301
+ </View>
302
+ :my_option?.result_ind ?
303
+ <Text style={{ marginTop:3 }} theme='h2' color={getColor(response_stats.earnings)}>{cl}{response_stats.earnings.toFixed(2)} Earned</Text>
304
+ :my_option ?
305
+ <Text style={{ marginTop:3 }} theme='h2' color={Colors.text.action}>{cl}{response_stats.stake.toFixed(2)} to win {cl}{response_stats.potential_winnings.toFixed(2)}*</Text>
306
+ :<></>
307
+ }
308
+
309
+ </View>
293
310
  )
294
311
  }
295
312
 
@@ -297,7 +314,10 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
297
314
  //if(!poll.flash_active){ return <></> }
298
315
  const stats = FlashMarketHelpers.getStats(poll_summaries, flash_market_fees);
299
316
  return (
300
- <View transparent style={{ ...card_style }}>
317
+ <View transparent style={{ ...card_style }} onLayout={(ev) => {
318
+ const { width, height } = ev.nativeEvent.layout;
319
+ setSize({ width, height });
320
+ }}>
301
321
  <Button
302
322
  style={{ backgroundColor:Colors.views.header, padding:10, flexDirection:'row', alignItems:'center', ...header_style }}
303
323
  onPress={() => setExpanded(!expanded)}>
@@ -338,12 +358,20 @@ const FlashMarket = ({ loading, poll, hide_footer, hide_timer, poll_options, pol
338
358
  onTimesUp={() => onReload()}
339
359
  />
340
360
  :<></>}
361
+ {wrap_options ?
362
+ <View style={{ flexDirection:'row', flexWrap:'wrap', justifyContent:'center' }}>
363
+ {visible_options.map((o,i) => {
364
+ return renderOptions({ item:o,index:i })
365
+ })}
366
+ </View>
367
+ :
341
368
  <FlatList
342
369
  data={visible_options}
343
370
  key={`poll_${poll.poll_id}_options`}
344
371
  renderItem={renderOptions}
345
372
  keyExtractor={(item) => item.poll_option_id.toString()}
346
373
  />
374
+ }
347
375
  {is_inactive && !is_admin ?
348
376
  <View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, justifyContent:'center', alignItems:'center' }}>
349
377
  <View float style={{ flexDirection:'row', alignItems:'center', padding:20 }}>
@@ -6,7 +6,7 @@ import { ActivityIndicator, FlatList, ImageBackground, type ViewStyle } from 're
6
6
  import { useColors } from '../../constants/useColors';
7
7
  import ReferralSelector from './ReferralSelector';
8
8
  import LeagueSelector from './LeagueSelector';
9
- import { Toggle } from '../../Components';
9
+ import { Switch, Toggle } from '../../Components';
10
10
  import * as Clipboard from 'expo-clipboard';
11
11
  import CompetitionSelector from './CompetitionSelector';
12
12
  import SquaresSelector from './SquaresSelector';
@@ -163,6 +163,25 @@ const EmbedManager = ({ float, me, company_id, company_embed_id, onFocusPosition
163
163
  />
164
164
  </View>
165
165
  )
166
+ case 'switch':
167
+ //Switch is going to be either a 1 or a 0. 0 is off
168
+ const boolean_value = value && value == '1' ? true : false
169
+ return (
170
+ <View transparent style={{ flexDirection:'row', alignItems:'center', borderBottomWidth:1, borderColor:Colors.borders.light, padding:10 }}>
171
+ <View transparent style={{ flex:1, marginRight:10 }}>
172
+ <Text theme='h1'>{data.item.label}</Text>
173
+ <Text theme='description' style={{ marginTop:3 }}>{data.item.description}</Text>
174
+ </View>
175
+ <Switch
176
+ value={boolean_value}
177
+ switch_type='on_off'
178
+ onChange={(val) => {
179
+ let str_val = val ? '1' : '0'
180
+ setEmbedData({ ...embed_data, draft_company_embed: { ...draft_company_embed, properties: { ...draft_company_embed.properties, [data.item.property]: str_val } } })
181
+ }}
182
+ />
183
+ </View>
184
+ )
166
185
  case 'refer_selector':
167
186
  const selected_referral = player_referrals.find(pr => pr.referral_code == value);
168
187
  return (