@@ -17,14 +17,16 @@ import {
17
17
} from "../app.constants" ;
18
18
import { showPopUp } from "./popup-override" ;
19
19
import { addFutbinCachePrice } from "../utils/futbinUtil" ;
20
- import { getValue } from "../services/repository" ;
20
+ import { getValue , setValue } from "../services/repository" ;
21
21
import { getSellBidPrice , roundOffPrice } from "../utils/priceUtil" ;
22
22
23
23
export const sbcViewOverride = ( ) => {
24
24
const squladDetailPanelView = UTSBCSquadDetailPanelView . prototype . render ;
25
25
26
26
UTSBCSquadDetailPanelView . prototype . render = function ( ...params ) {
27
27
squladDetailPanelView . call ( this , ...params ) ;
28
+ const sbcId = params . length ? params [ 0 ] . id : "" ;
29
+ setValue ( "squadId" , sbcId ) ;
28
30
setTimeout ( ( ) => {
29
31
if ( ! $ ( ".futBinFill" ) . length ) {
30
32
$ ( ".challenge-content" ) . append (
@@ -33,9 +35,9 @@ export const sbcViewOverride = () => {
33
35
<input id="squadId" type="text" class="ut-text-input-control futBinId" placeholder="FutBin Id" />
34
36
${ generateButton (
35
37
idFillSBC ,
36
- " Auto Fill" ,
38
+ "Auto Fill" ,
37
39
async ( ) => {
38
- await fillSquad ( ) ;
40
+ await fillSquad ( getValue ( "squadId" ) ) ;
39
41
} ,
40
42
"call-to-action"
41
43
) }
@@ -52,6 +54,9 @@ export const sbcViewOverride = () => {
52
54
)
53
55
) ;
54
56
}
57
+ if ( getValue ( sbcId ) ) {
58
+ appendSquadTotal ( getValue ( sbcId ) . value ) ;
59
+ }
55
60
} ) ;
56
61
} ;
57
62
} ;
@@ -213,7 +218,7 @@ const buyPlayer = (player, buyPrice) => {
213
218
} ) ;
214
219
} ;
215
220
216
- const fillSquad = async ( ) => {
221
+ const fillSquad = async ( sbcId ) => {
217
222
const squadId = $ ( "#squadId" ) . val ( ) ;
218
223
if ( ! squadId ) {
219
224
sendUINotification ( "Squad Id is missing !!!" , UINotificationType . NEGATIVE ) ;
@@ -277,13 +282,25 @@ const fillSquad = async () => {
277
282
278
283
hideLoader ( ) ;
279
284
280
- $ (
281
- `<div class="rating">
285
+ setValue ( sbcId , {
286
+ expiryTimeStamp : new Date ( Date . now ( ) + 15 * 60 * 1000 ) ,
287
+ value : squadTotal . toLocaleString ( ) ,
288
+ } ) ;
289
+ appendSquadTotal ( squadTotal . toLocaleString ( ) ) ;
290
+ } ;
291
+
292
+ const appendSquadTotal = ( total ) => {
293
+ if ( $ ( ".squadTotal" ) . length ) {
294
+ $ ( ".squadTotal" ) . text ( total ) ;
295
+ } else {
296
+ $ (
297
+ `<div class="rating">
282
298
<span class="ut-squad-summary-label">FUTBIN Squad Price</span>
283
299
<div>
284
- <span class="ratingValue currency-coins">${ squadTotal . toLocaleString ( ) } </span>
300
+ <span class="ratingValue squadTotal currency-coins">${ total } </span>
285
301
</div>
286
302
</div>
287
303
`
288
- ) . insertAfter ( $ ( ".chemistry" ) ) ;
304
+ ) . insertAfter ( $ ( ".chemistry" ) ) ;
305
+ }
289
306
} ;
0 commit comments