@@ -505,6 +505,13 @@ const UserPlaytime = (props: { id: number }) => {
505
505
) ;
506
506
} , [ props . id ] ) ;
507
507
508
+ const getRecentPlaytime = ( when : number ) => {
509
+ setPlaytimeData ( undefined ) ;
510
+ callApi ( `/User/${ props . id } /Playtime/${ when } ` ) . then ( ( value ) =>
511
+ value . json ( ) . then ( ( json ) => setPlaytimeData ( json ) )
512
+ ) ;
513
+ } ;
514
+
508
515
if ( ! playtimeData ) return "Loading..." ;
509
516
510
517
const totalMinutes : number = playtimeData . reduce (
@@ -513,20 +520,33 @@ const UserPlaytime = (props: { id: number }) => {
513
520
) ;
514
521
515
522
return (
516
- < div className = "flex flex-col gap-2 mt-2" >
517
- { totalMinutes > 0 && (
523
+ < div className = "flex flex-col" >
524
+ < div className = "flex flex-row gap-2" >
525
+ < LinkColor onClick = { ( ) => getRecentPlaytime ( 30 ) } >
526
+ Last 30 days
527
+ </ LinkColor > { " " }
528
+ |{ " " }
529
+ < LinkColor onClick = { ( ) => getRecentPlaytime ( 60 ) } >
530
+ Last 60 Days
531
+ </ LinkColor > { " " }
532
+ |{ " " }
533
+ < LinkColor onClick = { ( ) => getRecentPlaytime ( 90 ) } >
534
+ Last 90 Days
535
+ </ LinkColor >
536
+ </ div >
537
+ < div className = "flex flex-col gap-2 mt-2" >
518
538
< div className = "underline" >
519
539
Total: { Math . round ( ( totalMinutes / 60 ) * 100 ) / 100 } hours
520
540
</ div >
521
- ) }
522
- { playtimeData
523
- . sort ( ( a , b ) => b . totalMinutes - a . totalMinutes )
524
- . map ( ( playtime ) => (
525
- < div key = { playtime . id } >
526
- { playtime . roleId } : { " " }
527
- { Math . round ( ( playtime . totalMinutes / 60 ) * 100 ) / 100 } hours
528
- </ div >
529
- ) ) }
541
+ { playtimeData
542
+ . sort ( ( a , b ) => b . totalMinutes - a . totalMinutes )
543
+ . map ( ( playtime ) => (
544
+ < div key = { playtime . id } >
545
+ { playtime . roleId } : { " " }
546
+ { Math . round ( ( playtime . totalMinutes / 60 ) * 100 ) / 100 } hours
547
+ </ div >
548
+ ) ) }
549
+ </ div >
530
550
</ div >
531
551
) ;
532
552
} ;
0 commit comments