File tree 1 file changed +47
-0
lines changed 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -309,6 +309,7 @@ const UserDetailsModal = (props: { player: Player }) => {
309
309
const global = useContext ( GlobalContext ) ;
310
310
311
311
const [ tickets , setViewTickets ] = useState ( false ) ;
312
+ const [ playtime , setViewPlaytime ] = useState ( false ) ;
312
313
313
314
useEffect ( ( ) => {
314
315
setViewTickets ( false ) ;
@@ -398,6 +399,21 @@ const UserDetailsModal = (props: { player: Player }) => {
398
399
</ div >
399
400
</ Dialog >
400
401
) }
402
+ { "|" }
403
+ < LinkColor onClick = { ( ) => setViewPlaytime ( true ) } >
404
+ View Playtime
405
+ </ LinkColor >
406
+ { playtime && (
407
+ < Dialog
408
+ open = { playtime }
409
+ toggle = { ( ) => setViewPlaytime ( false ) }
410
+ className = "h-[80%]"
411
+ >
412
+ < div className = "pt-5" >
413
+ < UserPlaytime id = { player . id } />
414
+ </ div >
415
+ </ Dialog >
416
+ ) }
401
417
</ div >
402
418
</ div >
403
419
</ >
@@ -473,6 +489,37 @@ const UserTickets = (props: { ckey: string }) => {
473
489
) ;
474
490
} ;
475
491
492
+ type Playtime = {
493
+ id : number ;
494
+ playerId : number ;
495
+ roleId : string ;
496
+ totalMinutes : number ;
497
+ } ;
498
+
499
+ const UserPlaytime = ( props : { id : number } ) => {
500
+ const [ playtimeData , setPlaytimeData ] = useState < Playtime [ ] | undefined > ( ) ;
501
+
502
+ useEffect ( ( ) => {
503
+ callApi ( `/User/${ props . id } /Playtime` ) . then ( ( value ) =>
504
+ value . json ( ) . then ( ( json ) => setPlaytimeData ( json ) )
505
+ ) ;
506
+ } , [ props . id ] ) ;
507
+
508
+ if ( ! playtimeData ) return "Loading..." ;
509
+
510
+ return (
511
+ < div className = "flex flex-col gap-2 mt-2" >
512
+ { playtimeData
513
+ . sort ( ( a , b ) => b . totalMinutes - a . totalMinutes )
514
+ . map ( ( playtime ) => (
515
+ < div key = { playtime . id } >
516
+ { playtime . roleId } : { playtime . totalMinutes } minutes
517
+ </ div >
518
+ ) ) }
519
+ </ div >
520
+ ) ;
521
+ } ;
522
+
476
523
const ConnectionType = ( props : {
477
524
label : string ;
478
525
path : string ;
You can’t perform that action at this time.
0 commit comments