be-components 5.8.1 → 5.8.2

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 (108) hide show
  1. package/lib/commonjs/Campaign/api/index.js +124 -0
  2. package/lib/commonjs/Campaign/api/index.js.map +1 -1
  3. package/lib/commonjs/Campaign/components/ActionList.js +46 -9
  4. package/lib/commonjs/Campaign/components/ActionList.js.map +1 -1
  5. package/lib/commonjs/Campaign/components/BetAlert.js +22 -10
  6. package/lib/commonjs/Campaign/components/BetAlert.js.map +1 -1
  7. package/lib/commonjs/Campaign/components/CampaignAnalytics.js +142 -11
  8. package/lib/commonjs/Campaign/components/CampaignAnalytics.js.map +1 -1
  9. package/lib/commonjs/Campaign/components/NewPlayerAlert.js +139 -0
  10. package/lib/commonjs/Campaign/components/NewPlayerAlert.js.map +1 -0
  11. package/lib/commonjs/Campaign/components/ParticipantCard.js +5 -0
  12. package/lib/commonjs/Campaign/components/ParticipantCard.js.map +1 -1
  13. package/lib/commonjs/Campaign/components/ParticipantsList.js +0 -1
  14. package/lib/commonjs/Campaign/components/ParticipantsList.js.map +1 -1
  15. package/lib/commonjs/Campaign/index.js +564 -222
  16. package/lib/commonjs/Campaign/index.js.map +1 -1
  17. package/lib/commonjs/MarketComponents/api/index.js +21 -0
  18. package/lib/commonjs/MarketComponents/api/index.js.map +1 -1
  19. package/lib/commonjs/Ticker/index.js +112 -26
  20. package/lib/commonjs/Ticker/index.js.map +1 -1
  21. package/lib/module/Campaign/api/index.js +124 -0
  22. package/lib/module/Campaign/api/index.js.map +1 -1
  23. package/lib/module/Campaign/components/ActionList.js +46 -9
  24. package/lib/module/Campaign/components/ActionList.js.map +1 -1
  25. package/lib/module/Campaign/components/BetAlert.js +22 -10
  26. package/lib/module/Campaign/components/BetAlert.js.map +1 -1
  27. package/lib/module/Campaign/components/CampaignAnalytics.js +144 -13
  28. package/lib/module/Campaign/components/CampaignAnalytics.js.map +1 -1
  29. package/lib/module/Campaign/components/NewPlayerAlert.js +132 -0
  30. package/lib/module/Campaign/components/NewPlayerAlert.js.map +1 -0
  31. package/lib/module/Campaign/components/ParticipantCard.js +5 -0
  32. package/lib/module/Campaign/components/ParticipantCard.js.map +1 -1
  33. package/lib/module/Campaign/components/ParticipantsList.js +0 -1
  34. package/lib/module/Campaign/components/ParticipantsList.js.map +1 -1
  35. package/lib/module/Campaign/index.js +564 -222
  36. package/lib/module/Campaign/index.js.map +1 -1
  37. package/lib/module/MarketComponents/api/index.js +21 -0
  38. package/lib/module/MarketComponents/api/index.js.map +1 -1
  39. package/lib/module/Ticker/index.js +115 -29
  40. package/lib/module/Ticker/index.js.map +1 -1
  41. package/lib/typescript/lib/commonjs/Campaign/api/index.d.ts +11 -0
  42. package/lib/typescript/lib/commonjs/Campaign/api/index.d.ts.map +1 -1
  43. package/lib/typescript/lib/commonjs/Campaign/components/ActionList.d.ts +4 -1
  44. package/lib/typescript/lib/commonjs/Campaign/components/ActionList.d.ts.map +1 -1
  45. package/lib/typescript/lib/commonjs/Campaign/components/BetAlert.d.ts +3 -1
  46. package/lib/typescript/lib/commonjs/Campaign/components/BetAlert.d.ts.map +1 -1
  47. package/lib/typescript/lib/commonjs/Campaign/components/CampaignAnalytics.d.ts +4 -2
  48. package/lib/typescript/lib/commonjs/Campaign/components/CampaignAnalytics.d.ts.map +1 -1
  49. package/lib/typescript/lib/commonjs/Campaign/components/NewPlayerAlert.d.ts +10 -0
  50. package/lib/typescript/lib/commonjs/Campaign/components/NewPlayerAlert.d.ts.map +1 -0
  51. package/lib/typescript/lib/commonjs/Campaign/components/ParticipantCard.d.ts +3 -1
  52. package/lib/typescript/lib/commonjs/Campaign/components/ParticipantCard.d.ts.map +1 -1
  53. package/lib/typescript/lib/commonjs/Campaign/components/ParticipantsList.d.ts.map +1 -1
  54. package/lib/typescript/lib/commonjs/Campaign/index.d.ts +8 -5
  55. package/lib/typescript/lib/commonjs/Campaign/index.d.ts.map +1 -1
  56. package/lib/typescript/lib/commonjs/MarketComponents/api/index.d.ts +1 -0
  57. package/lib/typescript/lib/commonjs/MarketComponents/api/index.d.ts.map +1 -1
  58. package/lib/typescript/lib/commonjs/Ticker/index.d.ts +2 -1
  59. package/lib/typescript/lib/commonjs/Ticker/index.d.ts.map +1 -1
  60. package/lib/typescript/lib/module/Campaign/api/index.d.ts +11 -0
  61. package/lib/typescript/lib/module/Campaign/api/index.d.ts.map +1 -1
  62. package/lib/typescript/lib/module/Campaign/components/ActionList.d.ts +4 -1
  63. package/lib/typescript/lib/module/Campaign/components/ActionList.d.ts.map +1 -1
  64. package/lib/typescript/lib/module/Campaign/components/BetAlert.d.ts +3 -1
  65. package/lib/typescript/lib/module/Campaign/components/BetAlert.d.ts.map +1 -1
  66. package/lib/typescript/lib/module/Campaign/components/CampaignAnalytics.d.ts +4 -2
  67. package/lib/typescript/lib/module/Campaign/components/CampaignAnalytics.d.ts.map +1 -1
  68. package/lib/typescript/lib/module/Campaign/components/NewPlayerAlert.d.ts +10 -0
  69. package/lib/typescript/lib/module/Campaign/components/NewPlayerAlert.d.ts.map +1 -0
  70. package/lib/typescript/lib/module/Campaign/components/ParticipantCard.d.ts +3 -1
  71. package/lib/typescript/lib/module/Campaign/components/ParticipantCard.d.ts.map +1 -1
  72. package/lib/typescript/lib/module/Campaign/components/ParticipantsList.d.ts.map +1 -1
  73. package/lib/typescript/lib/module/Campaign/index.d.ts +8 -5
  74. package/lib/typescript/lib/module/Campaign/index.d.ts.map +1 -1
  75. package/lib/typescript/lib/module/MarketComponents/api/index.d.ts +1 -0
  76. package/lib/typescript/lib/module/MarketComponents/api/index.d.ts.map +1 -1
  77. package/lib/typescript/lib/module/Ticker/index.d.ts +2 -1
  78. package/lib/typescript/lib/module/Ticker/index.d.ts.map +1 -1
  79. package/lib/typescript/src/Campaign/api/index.d.ts +21 -6
  80. package/lib/typescript/src/Campaign/api/index.d.ts.map +1 -1
  81. package/lib/typescript/src/Campaign/components/ActionList.d.ts +5 -2
  82. package/lib/typescript/src/Campaign/components/ActionList.d.ts.map +1 -1
  83. package/lib/typescript/src/Campaign/components/BetAlert.d.ts +4 -2
  84. package/lib/typescript/src/Campaign/components/BetAlert.d.ts.map +1 -1
  85. package/lib/typescript/src/Campaign/components/CampaignAnalytics.d.ts +6 -3
  86. package/lib/typescript/src/Campaign/components/CampaignAnalytics.d.ts.map +1 -1
  87. package/lib/typescript/src/Campaign/components/NewPlayerAlert.d.ts +12 -0
  88. package/lib/typescript/src/Campaign/components/NewPlayerAlert.d.ts.map +1 -0
  89. package/lib/typescript/src/Campaign/components/ParticipantCard.d.ts +4 -2
  90. package/lib/typescript/src/Campaign/components/ParticipantCard.d.ts.map +1 -1
  91. package/lib/typescript/src/Campaign/index.d.ts +7 -4
  92. package/lib/typescript/src/Campaign/index.d.ts.map +1 -1
  93. package/lib/typescript/src/MarketComponents/api/index.d.ts +3 -2
  94. package/lib/typescript/src/MarketComponents/api/index.d.ts.map +1 -1
  95. package/lib/typescript/src/Ticker/index.d.ts +2 -1
  96. package/lib/typescript/src/Ticker/index.d.ts.map +1 -1
  97. package/package.json +1 -1
  98. package/src/Campaign/api/index.ts +86 -4
  99. package/src/Campaign/components/ActionList.tsx +38 -13
  100. package/src/Campaign/components/BetAlert.tsx +15 -6
  101. package/src/Campaign/components/CampaignAnalytics.tsx +76 -13
  102. package/src/Campaign/components/NewPlayerAlert.tsx +81 -0
  103. package/src/Campaign/components/ParticipantCard.tsx +7 -2
  104. package/src/Campaign/components/ParticipantsList.tsx +1 -1
  105. package/src/Campaign/index.tsx +421 -188
  106. package/src/MarketComponents/api/index.ts +16 -2
  107. package/src/Ticker/index.tsx +64 -32
  108. package/src/types.d.ts +3 -0
@@ -362,7 +362,21 @@ const MarketComponentHelpers = {
362
362
  if(match.time_detail == 'scheduled'){ return moment(match.scheduled_datetime).format('MMM DD hh:mm a') }
363
363
  return match.time_detail
364
364
  },
365
- getOrderTitleForTeamEvent : (order:OrderProps, market:MarketProps, event:EventProps, athlete?:AthleteProps, exotic?:any):string | undefined => {
365
+ getOrderTitle: (order:OrderProps|BestAvailableOrderProps, market:MarketProps, event?:EventProps, tournament?:TournamentProps, match?:MatchProps, athlete?:AthleteProps, team?:TeamProps) => {
366
+ switch(order.event_type){
367
+ case 'team':
368
+ if(!event){ return undefined }
369
+ return MarketComponentHelpers.getOrderTitleForTeamEvent(order, market, event, athlete)
370
+ case 'tournament':
371
+ if(!tournament){return undefined }
372
+ return MarketComponentHelpers.getOrderTitleForTournament(order, market, tournament, athlete, team);
373
+ case 'match':
374
+ if(!match){ return undefined }
375
+ return MarketComponentHelpers.getOrderTitleForMatch(order, market, match, athlete, team);
376
+ default: return undefined
377
+ }
378
+ },
379
+ getOrderTitleForTeamEvent : (order:OrderProps|BestAvailableOrderProps, market:MarketProps, event:EventProps, athlete?:AthleteProps, exotic?:any):string | undefined => {
366
380
  let market_side = market.side_options.find(o => o.side == order.side)
367
381
  if(!market_side){ return undefined }
368
382
  var re = /({.*?})/;
@@ -410,7 +424,7 @@ const MarketComponentHelpers = {
410
424
  })
411
425
  return new_title
412
426
  },
413
- getOrderTitleForMatch : (order:OrderProps, market:MarketProps, match:MatchProps, athlete?:AthleteProps, team?:TeamProps):string | undefined => {
427
+ getOrderTitleForMatch : (order:OrderProps|BestAvailableOrderProps, market:MarketProps, match:MatchProps, athlete?:AthleteProps, team?:TeamProps):string | undefined => {
414
428
  if(!match){ return undefined }
415
429
  let market_side = market.side_options.find(o => o.side == order.side)
416
430
  if(!market_side){ return order.side }
@@ -1,27 +1,29 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { Text, View } from "../Components/Themed"
2
+ import { Button, Text, View } from "../Components/Themed"
3
3
  import type { AthleteProps, EventProps, ExternalPriceProps, LeagueProps, MarketProps, OrderProps, TeamProps, TournamentProps, TradeProps } from '../types';
4
- import { MarketComponentApi } from '../MarketComponents/api';
5
- import { FlatList, Image } from 'react-native';
4
+ import { MarketComponentApi, MarketComponentHelpers } from '../MarketComponents/api';
5
+ import { ActivityIndicator, Image } from 'react-native';
6
6
  import moment from 'moment-mini';
7
7
  import { useColors } from '../constants/useColors';
8
8
  import { FINALIZED_STATUSES } from '../Competition/api';
9
9
  import TradeText from './components/TradeText';
10
10
  import SocketManager from '../Socket';
11
11
  import { AthleteImage } from '../Components/Jerseys';
12
+ import { MarketButtonHelpers } from '../MarketComponents/components/MarketButton/api';
12
13
 
13
14
 
14
15
  type TickerProps = {
15
16
  league_ids:string[],
16
17
  color_mode?:'light'|'dark',
17
18
  distinct_id?:string,
18
- onOrders?:(orders:OrderProps[]) => void
19
+ onOrders?:(orders:OrderProps[]) => void,
20
+ onCreateOrder?:(order:OrderProps) => void
19
21
  }
20
22
 
21
- const MIN_SIZE = 350
23
+ const MIN_SIZE = 365
22
24
  const MARGIN = 6
23
25
 
24
- const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) => {
26
+ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders, onCreateOrder }:TickerProps) => {
25
27
  const Colors = useColors({ mode: color_mode });
26
28
  const [ embed_size, setEmbedSize ] = useState({ height:0, width:0 });
27
29
  const [ needs_reload, setNeedsReload ] = useState(false);
@@ -32,8 +34,8 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
32
34
  markets:MarketProps[],
33
35
  events:EventProps[],
34
36
  athletes:AthleteProps[],
35
- tournaments:TournamentProps[],
36
37
  teams:TeamProps[],
38
+ tournaments:TournamentProps[],
37
39
  leagues:LeagueProps[],
38
40
  trades:TradeProps[],
39
41
  animate:boolean,
@@ -50,7 +52,7 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
50
52
  leagues: [],
51
53
  external_prices: []
52
54
  });
53
- const { trades, leagues, events, tournaments, athletes, animate, markets } = ticker_data;
55
+ const { loading, trades, leagues, events, tournaments, athletes, teams, animate, markets } = ticker_data;
54
56
  let sorted_events = events.sort((a,b) => {
55
57
  return moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix() || parseInt(a.event_id) - parseInt(b.event_id)
56
58
  });
@@ -105,12 +107,12 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
105
107
  }
106
108
 
107
109
  const getData = async() => {
110
+ setTickerData({ ...ticker_data, loading: true })
108
111
  const lgs = await MarketComponentApi.getLeagues();
109
112
  const mks = await MarketComponentApi.getMarkets();
110
113
  let evs = await MarketComponentApi.getActiveEvents();
111
114
  let tns = await MarketComponentApi.getActiveTournaments();
112
115
  if(league_ids.length > 0){
113
- console.log(tns.map(tn => tn.league_id))
114
116
  evs = evs.filter(e => league_ids.map(id => id.toString()).includes(e.league_id.toString()));
115
117
  tns = tns.filter(t => league_ids.map(id => id.toString()).includes(t.league_id.toString()));
116
118
  }
@@ -128,6 +130,7 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
128
130
  setTickerData({
129
131
  ...ticker_data,
130
132
  events: evs,
133
+ loading:false,
131
134
  animate:false,
132
135
  athletes: aths,
133
136
  teams: tms,
@@ -139,25 +142,47 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
139
142
  }
140
143
 
141
144
 
142
- const renderTrades = (data: { item:MarketProps, index:number, event:EventProps, is_live:boolean }) => {
143
- const ev_trades = trades.filter(t => t.event_type == 'team' && t.event_id == data.event.event_id && t.market_id == data.item.market_id);
145
+ const renderTrades = (data: { item:MarketProps, index:number, contest_type:string, contest_id:string, is_live:boolean, side_type?:string, side_id?:string }) => {
146
+ let ev_trades = trades.filter(t => t.event_type == data.contest_type && t.event_id == data.contest_id && t.market_id == data.item.market_id);
147
+ if(data.side_type){ ev_trades = ev_trades.filter(t => t.side_type == data.side_type && t.side_id == data.side_id) }
144
148
  const trade_side_trade = ev_trades.find(t => t.side == data.item.trade_side);
145
149
  if(!trade_side_trade){ return <></> }
150
+
146
151
  return (
147
- <TradeText
148
- market={data.item}
149
- trade={trade_side_trade}
150
- width={tick_width / 2.5 / 3}
151
- animate={animate}
152
- />
152
+ <Button float={onCreateOrder?true : false} disabled={!onCreateOrder} transparent style={{ padding:0, borderWidth:0}} onPress={() => {
153
+ if(!onCreateOrder){ return }
154
+ const order = MarketButtonHelpers.getOrderFromTrade(trade_side_trade);
155
+ const market = markets.find(mk => mk.market_id == trade_side_trade.market_id);
156
+ if(!market){ return }
157
+ const tournament = tournaments.find(t => t.tournament_id == order.event_id);
158
+ const event = events.find(e => e.event_id == order.event_id);
159
+ const athlete = athletes.find(a => a.athlete_id == order.side_id);
160
+ const team = teams.find(t => t.team_id == order.side_id);
161
+ //const match = [].find(m => m.mark)
162
+ let title = MarketComponentHelpers.getOrderTitle(order, market, event, tournament, undefined, athlete, team);
163
+ if(!title){ return }
164
+ console.log(title)
165
+ return onCreateOrder({ ...order, title });
166
+ }}>
167
+ <TradeText
168
+ market={data.item}
169
+ trade={trade_side_trade}
170
+ width={tick_width / 2.5 / 3}
171
+ animate={animate}
172
+ />
173
+ </Button>
153
174
  )
154
175
  }
155
176
 
156
- const renderAthletes = (data:{item:string, index:number, tournament:TournamentProps, league?:LeagueProps}) => {
177
+ const renderAthletes = (data:{item:string, index:number, tournament:TournamentProps, league?:LeagueProps}) => {
157
178
  const athlete = athletes.find(a => a.athlete_id == data.item);
158
179
  if(!athlete){ return <></> }
180
+ let sup_markets = data.tournament.supported_markets ?? []
181
+ const supported_markets = markets.filter(pm => sup_markets.map(sm => sm.market_id.toString()).includes(pm.market_id.toString())).sort((a,b) => parseInt(a.market_id) - parseInt(b.market_id));
182
+ const is_live = moment().isAfter(moment(data.tournament.scheduled_datetime)) ? true : false
183
+ const is_closed = FINALIZED_STATUSES.includes(data.tournament.status) ? true : false
159
184
  return (
160
- <View style={{ flexDirection:'row', alignItems:'center', padding:5, borderBottomWidth:1, borderColor:Colors.borders.light }}>
185
+ <View key={data.item.toString()} style={{ width:tick_width-10, flexDirection:'row', alignItems:'center', margin:2, padding:5, borderBottomWidth:1, borderColor:is_closed?Colors.text.error:is_live?Colors.text.success:Colors.borders.light }}>
161
186
  <View float style={{ padding:2, borderRadius:100 }}>
162
187
  <AthleteImage
163
188
  league={data.league}
@@ -165,10 +190,14 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
165
190
  size={32}
166
191
  />
167
192
  </View>
168
-
169
193
  <View transparent style={{ flex:1, marginLeft:10 }}>
170
194
  <Text theme='h1'>{athlete.first_name} {athlete.last_name}</Text>
171
195
  </View>
196
+ <View style={{ flexDirection:'row' }}>
197
+ {supported_markets.map((sm, i) => {
198
+ return renderTrades({ item: sm, index:i, contest_type: 'tournament', contest_id:data.tournament.tournament_id, is_live, side_type:'athlete', side_id:data.item })
199
+ })}
200
+ </View>
172
201
  </View>
173
202
  )
174
203
  }
@@ -176,18 +205,18 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
176
205
  const renderTournaments = (data:{ item:TournamentProps, index:number }) => {
177
206
  const league = leagues.find(l => l.league_id == data.item.league_id)
178
207
  return (
179
- <View key={data.item.tournament_id.toString()} style={{ width:tick_width, margin:5, padding:8 }}>
180
- <View>
181
- <Text theme='h1'>{data.item.tournament_name}</Text>
208
+ <View key={data.item.tournament_id.toString()} style={{ width:embed_size.width }}>
209
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
210
+ <View transparent style={{flex:1}}>
211
+ <Text theme='h1'>{data.item.tournament_name}</Text>
212
+ <Text theme='description' style={{ marginTop:3 }}>{moment(data.item.scheduled_datetime).format('MMM D hh:mm a')}</Text>
213
+ </View>
182
214
  </View>
183
215
  {data.item.participant_type == 'athlete' ?
184
- <View>
185
- <FlatList
186
- data={data.item.participants}
187
- key={'tourney_athletes'}
188
- keyExtractor={(item) => item.toString()}
189
- renderItem={({ item ,index }) => renderAthletes({ item, index, tournament: data.item, league })}
190
- />
216
+ <View style={{ flexDirection:'row', flexWrap:'wrap', marginTop:5, padding:10 }}>
217
+ {data.item.participants.map((item, index) => {
218
+ return renderAthletes({ item, index, tournament:data.item, league })
219
+ })}
191
220
  </View>
192
221
  :<></>}
193
222
  </View>
@@ -214,7 +243,7 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
214
243
  </View>
215
244
  <View style={{ flexDirection:'row' }}>
216
245
  {supported_markets.map((sm, i) => {
217
- return renderTrades({ item: sm, index:i, event:data.item, is_live })
246
+ return renderTrades({ item: sm, index:i, contest_type: 'team', contest_id:data.item.event_id, is_live })
218
247
  })}
219
248
  </View>
220
249
  </View>
@@ -232,7 +261,10 @@ const Ticker = ({ league_ids, color_mode, distinct_id, onOrders }:TickerProps) =
232
261
  const { width, height } = ev.nativeEvent.layout;
233
262
  setEmbedSize({ width, height });
234
263
  }}>
235
- <View style={{ flexDirection:'row', flexWrap:'wrap', overflow:'scroll' }}>
264
+ {loading ?
265
+ <ActivityIndicator style={{ margin:20, alignSelf:'center' }} size='large' color={Colors.text.h1} />
266
+ :<></>}
267
+ <View style={{ flexDirection:'row' }}>
236
268
  {sorted_tournaments.map((e,i) => {
237
269
  return renderTournaments({ item:e, index:i })
238
270
  })}
package/src/types.d.ts CHANGED
@@ -697,6 +697,8 @@ export interface CampaignProps {
697
697
  sponsors?:bigint[],
698
698
  prize_description?:string,
699
699
  raffle_options?:string[],
700
+ poll_campaign_ids?:string[],
701
+ competition_ids?:string[],
700
702
  raffle_type?:string,
701
703
  ads?:{
702
704
  ad_type:string,
@@ -2294,6 +2296,7 @@ export interface OverallOrderAnalyticsProps {
2294
2296
  losses:number,
2295
2297
  draws:number
2296
2298
  }
2299
+ export type NewOverallAnalytics = OverallOrderAnalyticsProps&{roi_pct:number, win_pct:number, earnings:number}
2297
2300
 
2298
2301
  export interface OrderAnalyticsProps {
2299
2302
  day:string,