be-components 6.9.2 → 6.9.4

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 (62) hide show
  1. package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js +1 -1
  2. package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
  3. package/lib/commonjs/Squares/components/BidForm.js +31 -31
  4. package/lib/commonjs/Squares/components/BidForm.js.map +1 -1
  5. package/lib/commonjs/Squares/components/OfferForm.js +53 -60
  6. package/lib/commonjs/Squares/components/OfferForm.js.map +1 -1
  7. package/lib/commonjs/Squares/components/SquareOfferCard.js +134 -121
  8. package/lib/commonjs/Squares/components/SquareOfferCard.js.map +1 -1
  9. package/lib/commonjs/Squares/components/SquareOffersCard.js +32 -6
  10. package/lib/commonjs/Squares/components/SquareOffersCard.js.map +1 -1
  11. package/lib/commonjs/Squares/components/SquaresBoard.js +16 -8
  12. package/lib/commonjs/Squares/components/SquaresBoard.js.map +1 -1
  13. package/lib/commonjs/Squares/index.js +65 -18
  14. package/lib/commonjs/Squares/index.js.map +1 -1
  15. package/lib/module/CompetitionManager/components/CompetitionContestsForm.js +1 -1
  16. package/lib/module/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
  17. package/lib/module/Squares/components/BidForm.js +31 -31
  18. package/lib/module/Squares/components/BidForm.js.map +1 -1
  19. package/lib/module/Squares/components/OfferForm.js +54 -61
  20. package/lib/module/Squares/components/OfferForm.js.map +1 -1
  21. package/lib/module/Squares/components/SquareOfferCard.js +123 -109
  22. package/lib/module/Squares/components/SquareOfferCard.js.map +1 -1
  23. package/lib/module/Squares/components/SquareOffersCard.js +32 -6
  24. package/lib/module/Squares/components/SquareOffersCard.js.map +1 -1
  25. package/lib/module/Squares/components/SquaresBoard.js +16 -8
  26. package/lib/module/Squares/components/SquaresBoard.js.map +1 -1
  27. package/lib/module/Squares/index.js +65 -18
  28. package/lib/module/Squares/index.js.map +1 -1
  29. package/lib/typescript/lib/commonjs/Squares/components/BidForm.d.ts.map +1 -1
  30. package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts +1 -2
  31. package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts.map +1 -1
  32. package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts +2 -1
  33. package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts.map +1 -1
  34. package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts +2 -1
  35. package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts.map +1 -1
  36. package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
  37. package/lib/typescript/lib/module/Squares/components/BidForm.d.ts.map +1 -1
  38. package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts +1 -2
  39. package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts.map +1 -1
  40. package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts +5 -3
  41. package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts.map +1 -1
  42. package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts +2 -1
  43. package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts.map +1 -1
  44. package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
  45. package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -1
  46. package/lib/typescript/src/Squares/components/BidForm.d.ts.map +1 -1
  47. package/lib/typescript/src/Squares/components/OfferForm.d.ts +1 -1
  48. package/lib/typescript/src/Squares/components/OfferForm.d.ts.map +1 -1
  49. package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts +3 -2
  50. package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts.map +1 -1
  51. package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts +3 -2
  52. package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts.map +1 -1
  53. package/lib/typescript/src/Squares/components/SquaresBoard.d.ts.map +1 -1
  54. package/lib/typescript/src/Squares/index.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/src/CompetitionManager/components/CompetitionContestsForm.tsx +1 -2
  57. package/src/Squares/components/BidForm.tsx +23 -25
  58. package/src/Squares/components/OfferForm.tsx +40 -36
  59. package/src/Squares/components/SquareOfferCard.tsx +75 -45
  60. package/src/Squares/components/SquareOffersCard.tsx +13 -9
  61. package/src/Squares/components/SquaresBoard.tsx +14 -8
  62. package/src/Squares/index.tsx +77 -41
@@ -33,7 +33,7 @@ type SquaresModuleProps = {
33
33
  onEvent:(ev:BEEventProps) => void
34
34
  }
35
35
 
36
- const squares_sections = ['header', 'toggle', 'event', 'board', 'board_stats', 'my_stats', 'results', 'my_squares', 'winners','hidden_prizes','details', 'owners']
36
+ const squares_sections = ['header', 'offers', 'toggle', 'event', 'board', 'board_stats', 'my_stats', 'results', 'my_squares', 'winners','hidden_prizes','details', 'owners']
37
37
 
38
38
  const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id, onManageSquares, onRequestAuthenticate, onShareCompetition, onPlayerSelect }:SquaresModuleProps) => {
39
39
  const C = useColors();
@@ -92,6 +92,33 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
92
92
  const home_abbr = event?.home?.abbr??squares_competition?.event_backup?.home?.abbr
93
93
  const away_abbr = event?.away?.abbr??squares_competition?.event_backup?.away?.abbr
94
94
 
95
+
96
+ const dedupeWithMaxPrice = (arr: SquareOfferProps[]): SquareOfferProps[] => {
97
+ const map = arr.reduce((acc, item) => {
98
+ const existing = acc.get(item.sq_player_square_id);
99
+ if (!existing || item.amount > existing.amount) {
100
+ acc.set(item.sq_offer_id, item);
101
+ }
102
+ return acc;
103
+ }, new Map<string, SquareOfferProps>());
104
+
105
+ return Array.from(map.values());
106
+ }
107
+
108
+ const filterRelevantOffers = (offers:SquareOfferProps[]) => {
109
+ let sell_offers = offers.filter(o => o.buy_sell_ind == 'sell')
110
+ if(!player_id){ return sell_offers }
111
+ //Now - only do buy offers that I am the offeree for
112
+ let my_buy_offers = offers.filter(o => o.buy_sell_ind == 'buy' && o.offerer_id == player_id)
113
+ let offered_to_me_buys = offers.filter(o => o.buy_sell_ind == 'buy' && o.offeree_id == player_id);
114
+ offered_to_me_buys = dedupeWithMaxPrice(offered_to_me_buys)
115
+ //We need to only get the max of the buys!
116
+
117
+ return sell_offers.concat(my_buy_offers).concat(offered_to_me_buys)
118
+ }
119
+
120
+ let relevant_offers = filterRelevantOffers(square_offers)
121
+
95
122
  let toggle_options = [
96
123
  { key: 'info', label: 'Info', icon: <Icons.MenuIcon size={18} color={active_tab=='info'?C.text.white:C.text.action}/> },
97
124
  { key: 'board', label: 'Board', icon: <Icons.SquaresIcon size={18} color={active_tab=='board'?C.text.white:C.text.action}/> },
@@ -140,7 +167,7 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
140
167
  const d = await SquaresApi.getSquareCompetitionById(sq_comp_id);
141
168
  const evs = await SquaresApi.getEventsByEventIds([d.squares_competition.event_id]);
142
169
  const league_id = evs[0]?.league_id
143
- let unique_player_ids = [ ...new Set(d.player_squares.map(ps => ps.player_id)) ]
170
+ let unique_player_ids = [ ...new Set(d.square_offers.map(so => so.offerer_id).concat(d.player_squares.map(ps => ps.player_id))) ]
144
171
  if(player_id){
145
172
  unique_player_ids.push(player_id)
146
173
  const pb = await SquaresApi.getMyBalance();
@@ -260,7 +287,7 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
260
287
  } else {
261
288
  new_purchase_price = square_offer.amount - 1
262
289
  }
263
- if(new_purchase_price <= player_square.purchase_price){ return } //Do not change if the price is less than the initial cost
290
+ if(new_purchase_price <= 0){ return } //Do not change if the price is less than the initial cost
264
291
  square_offer = { ...square_offer, amount:new_purchase_price }
265
292
  setBoardData({ ...board_data, draft_square_offers: draft_square_offers.filter(o => o.sq_player_square_id != square_offer.sq_player_square_id).concat(square_offer) })
266
293
  }
@@ -359,6 +386,22 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
359
386
  league={league}
360
387
  />
361
388
  )
389
+ case 'offers':
390
+ if(relevant_offers.length == 0 || !squares_competition){ return <></> }
391
+ return (
392
+ <View>
393
+ <SquareOffersCard
394
+ player_squares={player_squares}
395
+ square_offers={relevant_offers}
396
+ player_id={player_id}
397
+ squares={squares}
398
+ players={players}
399
+ home_abbr={home_abbr}
400
+ away_abbr={away_abbr}
401
+ onRequestAuthenticate={() => onRequestAuthenticate(squares_competition.auth_strategy_id)}
402
+ />
403
+ </View>
404
+ )
362
405
  case 'toggle':
363
406
  return (
364
407
  <View style={{ padding:8, width:view_mode == 'desktop'?800: undefined, alignSelf:view_mode == 'desktop'?'center':undefined }}>
@@ -521,25 +564,16 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
521
564
  <View style={{ flex:1 }} onLayout={(ev) => {
522
565
  const { width, height } = ev.nativeEvent.layout
523
566
  setModuleSize({ width, height })
524
- }}>
567
+ }}>
568
+ <View transparent style={{ flex:1 }}>
525
569
  <FlatList
526
570
  key='squares_section'
527
571
  data={squares_sections}
528
572
  renderItem={renderSections}
529
573
  keyExtractor={(item) => item}
530
- />
531
- {square_offers.length > 0 ?
532
- <SquareOffersCard
533
- player_squares={player_squares}
534
- square_offers={square_offers}
535
- player_id={player_id}
536
- squares={squares}
537
- home_abbr={home_abbr}
538
- away_abbr={away_abbr}
539
- onRequestAuthenticate={() => onRequestAuthenticate(squares_competition.auth_strategy_id)}
540
- />
541
- :<></>}
542
-
574
+ />
575
+ </View>
576
+
543
577
  <SocketManager
544
578
  //access_token={access_token}
545
579
  onConnect={() => {
@@ -568,8 +602,8 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
568
602
  visible={bid_form_expanded}
569
603
  animationType={view_mode=='desktop' ? 'fade' : 'slide'}
570
604
  >
571
- <View type='blur' style={view_mode=='desktop'?{ flex:1, justifyContent:'center', alignItems:'center' }:{ flex:1, justifyContent:'flex-end', paddingBottom:insets?.bottom }}>
572
- <View style={view_mode=='desktop'?{ width:500 }:undefined}>
605
+ <View type='blur' style={view_mode=='desktop'?{ flex:1, justifyContent:'center', alignItems:'center' }:{ flex:1, justifyContent:'flex-end', paddingBottom:insets?.bottom, padding:10 }}>
606
+ <View transparent style={view_mode=='desktop'?{ width:500 }:undefined}>
573
607
  <BidForm
574
608
  player_id={player_id}
575
609
  player_balance={player_balance}
@@ -595,29 +629,31 @@ const SquaresModule = ({ sq_comp_id, view_mode, insets, player_id, distinct_id,
595
629
  </Modal>
596
630
  <Modal
597
631
  transparent
598
- visible={draft_square_offers.length > 0 ? true: false}
599
- animationType='slide'
632
+ visible={draft_square_offers?.length > 0?true:false}
633
+ animationType={view_mode=='desktop' ? 'fade' : 'slide'}
600
634
  >
601
- <View type='blur' style={{ flex:1, justifyContent:'flex-end', paddingBottom:insets?.bottom }}>
602
- <OfferForm
603
- player_id={player_id}
604
- draft_square_offers={draft_square_offers}
605
- home_abbr={home_abbr}
606
- player_balance={player_balance}
607
- width={module_size.width}
608
- away_abbr={away_abbr}
609
- squares={squares}
610
- submit_ready={submit_ready}
611
- market_type={squares_competition.market_type}
612
- player_squares={player_squares}
613
- onClearOffers={handleClearOffers}
614
- onRequestAuthenticate={() => {
615
- setBoardData({ ...board_data, draft_square_offers:[], submit_ready:{ is_loading: false, is_ready: false } })
616
- setTimeout(() => onRequestAuthenticate(squares_competition.auth_strategy_id), 500);
617
- }}
618
- onOfferAmountChange={(offer, player_square, direction) => handleOfferAmountChange(offer, player_square, direction)}
619
- onSubmitOffer={() => handleSubmitOffer()}
620
- />
635
+ <View type='blur' style={view_mode=='desktop'?{ flex:1, justifyContent:'center', alignItems:'center' }:{ flex:1, justifyContent:'flex-end', paddingBottom:insets?.bottom, padding:10 }}>
636
+ <View transparent style={view_mode=='desktop'?{ width:500 }:undefined}>
637
+ <OfferForm
638
+ player_id={player_id}
639
+ draft_square_offers={draft_square_offers}
640
+ home_abbr={home_abbr}
641
+ player_balance={player_balance}
642
+ width={module_size.width}
643
+ away_abbr={away_abbr}
644
+ squares={squares}
645
+ submit_ready={submit_ready}
646
+ market_type={squares_competition.market_type}
647
+ player_squares={player_squares}
648
+ onClearOffers={handleClearOffers}
649
+ onRequestAuthenticate={() => {
650
+ setBoardData({ ...board_data, draft_square_offers:[], submit_ready:{ is_loading: false, is_ready: false } })
651
+ setTimeout(() => onRequestAuthenticate(squares_competition.auth_strategy_id), 500);
652
+ }}
653
+ onOfferAmountChange={(offer, player_square, direction) => handleOfferAmountChange(offer, player_square, direction)}
654
+ onSubmitOffer={() => handleSubmitOffer()}
655
+ />
656
+ </View>
621
657
  </View>
622
658
  </Modal>
623
659
  {square_bids.length > 0 && !bid_form_expanded ?