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.
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/commonjs/Squares/components/BidForm.js +31 -31
- package/lib/commonjs/Squares/components/BidForm.js.map +1 -1
- package/lib/commonjs/Squares/components/OfferForm.js +53 -60
- package/lib/commonjs/Squares/components/OfferForm.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOfferCard.js +134 -121
- package/lib/commonjs/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOffersCard.js +32 -6
- package/lib/commonjs/Squares/components/SquareOffersCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquaresBoard.js +16 -8
- package/lib/commonjs/Squares/components/SquaresBoard.js.map +1 -1
- package/lib/commonjs/Squares/index.js +65 -18
- package/lib/commonjs/Squares/index.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js +1 -1
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/module/Squares/components/BidForm.js +31 -31
- package/lib/module/Squares/components/BidForm.js.map +1 -1
- package/lib/module/Squares/components/OfferForm.js +54 -61
- package/lib/module/Squares/components/OfferForm.js.map +1 -1
- package/lib/module/Squares/components/SquareOfferCard.js +123 -109
- package/lib/module/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/module/Squares/components/SquareOffersCard.js +32 -6
- package/lib/module/Squares/components/SquareOffersCard.js.map +1 -1
- package/lib/module/Squares/components/SquaresBoard.js +16 -8
- package/lib/module/Squares/components/SquaresBoard.js.map +1 -1
- package/lib/module/Squares/index.js +65 -18
- package/lib/module/Squares/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts +1 -2
- package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts +1 -2
- package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts +5 -3
- package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts +2 -1
- package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/OfferForm.d.ts +1 -1
- package/lib/typescript/src/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts +3 -2
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts +3 -2
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquaresBoard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CompetitionManager/components/CompetitionContestsForm.tsx +1 -2
- package/src/Squares/components/BidForm.tsx +23 -25
- package/src/Squares/components/OfferForm.tsx +40 -36
- package/src/Squares/components/SquareOfferCard.tsx +75 -45
- package/src/Squares/components/SquareOffersCard.tsx +13 -9
- package/src/Squares/components/SquaresBoard.tsx +14 -8
- package/src/Squares/index.tsx +77 -41
package/src/Squares/index.tsx
CHANGED
|
@@ -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 <=
|
|
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
|
-
|
|
532
|
-
|
|
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
|
|
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
|
-
<
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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 ?
|