be-components 1.2.0 → 1.2.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.
- package/lib/commonjs/Squares/api/index.js +52 -1
- package/lib/commonjs/Squares/api/index.js.map +1 -1
- package/lib/commonjs/Squares/components/EventCard.js +1 -1
- package/lib/commonjs/Squares/components/EventCard.js.map +1 -1
- package/lib/commonjs/Squares/components/ResultsCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOfferCard.js +47 -103
- package/lib/commonjs/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOffersCard.js +79 -0
- package/lib/commonjs/Squares/components/SquareOffersCard.js.map +1 -0
- package/lib/commonjs/Squares/components/SquareOwners.js.map +1 -1
- package/lib/commonjs/Squares/index.js +43 -19
- package/lib/commonjs/Squares/index.js.map +1 -1
- package/lib/module/Squares/api/index.js +52 -1
- package/lib/module/Squares/api/index.js.map +1 -1
- package/lib/module/Squares/components/EventCard.js +1 -1
- package/lib/module/Squares/components/EventCard.js.map +1 -1
- package/lib/module/Squares/components/ResultsCard.js.map +1 -1
- package/lib/module/Squares/components/SquareOfferCard.js +48 -104
- package/lib/module/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/module/Squares/components/SquareOffersCard.js +70 -0
- package/lib/module/Squares/components/SquareOffersCard.js.map +1 -0
- package/lib/module/Squares/components/SquareOwners.js.map +1 -1
- package/lib/module/Squares/index.js +43 -19
- package/lib/module/Squares/index.js.map +1 -1
- package/lib/typescript/src/Squares/api/index.d.ts +5 -0
- package/lib/typescript/src/Squares/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/ResultsCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts +6 -5
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts +14 -0
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts.map +1 -0
- package/lib/typescript/src/Squares/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Squares/api/index.ts +41 -1
- package/src/Squares/components/EventCard.tsx +1 -1
- package/src/Squares/components/ResultsCard.tsx +1 -0
- package/src/Squares/components/SquareOfferCard.tsx +51 -55
- package/src/Squares/components/SquareOffersCard.tsx +64 -0
- package/src/Squares/components/SquareOwners.tsx +1 -1
- package/src/Squares/index.tsx +45 -18
package/src/Squares/index.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import OfferForm from "./components/OfferForm";
|
|
|
17
17
|
import MySquaresCard from "./components/MySquaresCard";
|
|
18
18
|
import { view_styles } from "../constants/styles";
|
|
19
19
|
import MyStatsCard from "./components/MyStatsCard";
|
|
20
|
+
import SquareOffersCard from "./components/SquareOffersCard";
|
|
20
21
|
|
|
21
22
|
type SquaresModuleProps = {
|
|
22
23
|
player_id?:string,
|
|
@@ -32,6 +33,9 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
32
33
|
const [ needs_reload, setNeedsReload ] = useState(false);
|
|
33
34
|
const [ module_size, setModuleSize ] = useState({ width:0, height:0 })
|
|
34
35
|
const [ bid_form_expanded, setBidFormExpanded ] = useState(false);
|
|
36
|
+
const [ updated_from_bid, setUpdatedFromBid ]= useState<BuySquaresResponseProps>();
|
|
37
|
+
const [ updated_from_offer, setUpdatedFromOffer ]= useState<OfferResponseProps>();
|
|
38
|
+
|
|
35
39
|
const [ module_data, setModuleData ] = useState<{
|
|
36
40
|
loading:boolean,
|
|
37
41
|
loaded:boolean,
|
|
@@ -69,8 +73,7 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
69
73
|
const { square_bids, draft_square_offers, submit_ready } = board_data;
|
|
70
74
|
const { loading, league, event, players, loaded, squares_competition, squares, squares_type, squares_payout_type, square_results, square_offers, player_square_history, player_squares } = module_data;
|
|
71
75
|
|
|
72
|
-
const squares_expected_value = SqauresHelpers.getMyExpectedValue(squares, player_squares.filter(ps => ps.status == 'active' && ps.player_id == player_id), squares_competition, player_id)
|
|
73
|
-
|
|
76
|
+
const squares_expected_value = SqauresHelpers.getMyExpectedValue(squares, [ ...player_squares.filter(ps => ps.status == 'active' && ps.player_id == player_id) ], squares_competition, player_id)
|
|
74
77
|
const my_squares = player_squares.filter(ps => ps.status == 'active' && ps.player_id == player_id);
|
|
75
78
|
const home_abbr = event?.home?.abbr??squares_competition?.event_backup?.home?.abbr
|
|
76
79
|
const away_abbr = event?.away?.abbr??squares_competition?.event_backup?.away?.abbr
|
|
@@ -82,6 +85,16 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
82
85
|
getDataFromServer(sq_comp_id);
|
|
83
86
|
},[sq_comp_id])
|
|
84
87
|
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if(!updated_from_bid?.squares_competition){ return }
|
|
90
|
+
handleUpdateBoardFromBuy(updated_from_bid)
|
|
91
|
+
},[updated_from_bid])
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if(!updated_from_offer?.squares_competition){ return }
|
|
95
|
+
handleUpdateBoardFromOffer(updated_from_offer)
|
|
96
|
+
},[updated_from_offer])
|
|
97
|
+
|
|
85
98
|
const getDataFromServer = async(sq_comp_id:string, options?:any) => {
|
|
86
99
|
if(!options || !options.ignore_load){ setModuleData({ ...module_data, loading: true }) }
|
|
87
100
|
const d = await SquaresApi.getSquareCompetitionById(sq_comp_id);
|
|
@@ -126,8 +139,8 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
126
139
|
if(submit_ready.is_loading){ return } //Prevent button mashing
|
|
127
140
|
//SUBMIT BIDS!
|
|
128
141
|
setBoardData({ ...board_data, submit_ready: { ...submit_ready, is_loading:true } })
|
|
129
|
-
|
|
130
|
-
if(needs_reload){ handleUpdateBoardFromBuy(resp) } //If we somehow got disconnected from the socket, we need to load it
|
|
142
|
+
await SquaresApi.buySquares(squares_competition.sq_comp_id, square_bids)
|
|
143
|
+
//if(needs_reload){ handleUpdateBoardFromBuy(resp) } //If we somehow got disconnected from the socket, we need to load it
|
|
131
144
|
setBoardData({ ...board_data, square_bids:[], submit_ready:{ is_loading: false, is_ready: false } })
|
|
132
145
|
setBidFormExpanded(false);
|
|
133
146
|
}
|
|
@@ -145,8 +158,8 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
145
158
|
//SUBMIT BIDS!
|
|
146
159
|
|
|
147
160
|
setBoardData({ ...board_data, submit_ready: { ...submit_ready, is_loading:true } })
|
|
148
|
-
|
|
149
|
-
if(needs_reload){ handleUpdateBoardFromOffer(resp) } //If we somehow got disconnected from the socket, we need to load it
|
|
161
|
+
await SquaresApi.offserSquare(draft_square_offers[0])
|
|
162
|
+
//if(needs_reload){ handleUpdateBoardFromOffer(resp) } //If we somehow got disconnected from the socket, we need to load it
|
|
150
163
|
setBoardData({ ...board_data, draft_square_offers:[], submit_ready:{ is_loading: false, is_ready: false } })
|
|
151
164
|
}
|
|
152
165
|
|
|
@@ -229,28 +242,31 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
229
242
|
|
|
230
243
|
const handleUpdateBoardFromOffer = (data:OfferResponseProps) => {
|
|
231
244
|
//First remove squares
|
|
232
|
-
let new_ps = player_squares.filter(ps => !data.removed_player_squares.find(nps => nps.sq_player_square_id == ps.sq_player_square_id))
|
|
245
|
+
//let new_ps = player_squares.filter(ps => !data.removed_player_squares.find(nps => nps.sq_player_square_id == ps.sq_player_square_id))
|
|
233
246
|
//Now update squares
|
|
234
|
-
new_ps =
|
|
235
|
-
|
|
247
|
+
let new_ps = SqauresHelpers.updatePlayerSquaresWithSavedSquares([ ...player_squares ], data.saved_player_squares)
|
|
248
|
+
new_ps = SqauresHelpers.updatePlayerSquaresWithRemovedSquares(new_ps, data.removed_player_squares);
|
|
236
249
|
setModuleData({
|
|
237
250
|
...module_data,
|
|
238
|
-
|
|
239
|
-
|
|
251
|
+
squares_competition: data.squares_competition ? data.squares_competition : squares_competition,
|
|
252
|
+
player_squares: new_ps,
|
|
253
|
+
square_offers: SqauresHelpers.updateSquareOffersWithUpdatedOffers(square_offers, data.updated_offers)
|
|
240
254
|
})
|
|
241
255
|
}
|
|
242
256
|
|
|
243
257
|
const handleUpdateBoardFromBuy = (data:BuySquaresResponseProps) => {
|
|
244
258
|
//First remove squares
|
|
245
|
-
let new_ps = player_squares.filter(ps => !data.removed_player_squares.find(nps => nps.sq_player_square_id == ps.sq_player_square_id))
|
|
246
259
|
//Now update squares
|
|
247
|
-
new_ps =
|
|
248
|
-
|
|
260
|
+
let new_ps = SqauresHelpers.updatePlayerSquaresWithSavedSquares([ ...player_squares ], data.saved_player_squares)
|
|
261
|
+
new_ps = SqauresHelpers.updatePlayerSquaresWithRemovedSquares(new_ps, data.removed_player_squares);
|
|
262
|
+
let new_sq = SqauresHelpers.updateSquaresWithUpdatedSquares([ ...squares], data.updated_squares)
|
|
263
|
+
let new_ps_his = SqauresHelpers.updatePlayerSquareHistoryWithRemovedSquares([ ...player_square_history], data.removed_player_squares);
|
|
249
264
|
setModuleData({
|
|
250
265
|
...module_data,
|
|
251
266
|
squares_competition: data.squares_competition,
|
|
252
|
-
squares:
|
|
253
|
-
player_squares: new_ps
|
|
267
|
+
squares: new_sq,
|
|
268
|
+
player_squares: new_ps,
|
|
269
|
+
player_square_history: new_ps_his
|
|
254
270
|
})
|
|
255
271
|
}
|
|
256
272
|
|
|
@@ -324,6 +340,17 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
324
340
|
onPlayerSelect={onPlayerSelect}
|
|
325
341
|
/>
|
|
326
342
|
:<></>}
|
|
343
|
+
{square_offers.length > 0 ?
|
|
344
|
+
<SquareOffersCard
|
|
345
|
+
player_squares={player_squares}
|
|
346
|
+
square_offers={square_offers}
|
|
347
|
+
player_id={player_id}
|
|
348
|
+
squares={squares}
|
|
349
|
+
home_abbr={home_abbr}
|
|
350
|
+
away_abbr={away_abbr}
|
|
351
|
+
onRequestAuthenticate={() => onRequestAuthenticate(squares_competition.auth_strategy_id)}
|
|
352
|
+
/>
|
|
353
|
+
:<></>}
|
|
327
354
|
<View>
|
|
328
355
|
<SquaresBoard
|
|
329
356
|
player_id={player_id}
|
|
@@ -389,8 +416,8 @@ const SquaresModule = ({ sq_comp_id, player_id, distinct_id, onRequestAuthentica
|
|
|
389
416
|
case 'V1_UPDATE_SQUARE_DETAILS':
|
|
390
417
|
let data = ev.data as BuySquaresResponseProps | OfferResponseProps
|
|
391
418
|
if(!data.squares_competition || data.squares_competition.sq_comp_id != squares_competition.sq_comp_id){ break } //This isn't this competition;
|
|
392
|
-
if(ev.action == 'buy'){
|
|
393
|
-
if(ev.action == 'offer')[
|
|
419
|
+
if(ev.action == 'buy'){ setUpdatedFromBid(data as BuySquaresResponseProps) }
|
|
420
|
+
if(ev.action == 'offer')[ setUpdatedFromOffer(data as OfferResponseProps) ]
|
|
394
421
|
break;
|
|
395
422
|
default: break;
|
|
396
423
|
}
|