1
- import { Trophy } from 'lucide-react' ;
1
+ import { FileQuestion , Trophy } from 'lucide-react' ;
2
2
import { getMostQuestionsAnswered } from '@/utils/data/leaderboard/get-most-questions-answered' ;
3
3
import ProfilePicture from '@/components/ui/profile-picture' ;
4
4
import { UserRecord } from '@/types/User' ;
@@ -23,17 +23,17 @@ import { Badge } from '@/components/ui/badge';
23
23
import ShowTimeTakenToggle from './show-time-taken' ;
24
24
25
25
export default async function LeaderboardMostQuestionsAnswered ( {
26
- userUid ,
26
+ user ,
27
27
} : {
28
- userUid ?: string ;
28
+ user ?: UserRecord | null ;
29
29
} ) {
30
30
const topUsersByQuestionCount = await getMostQuestionsAnswered ( ) ;
31
31
32
32
return (
33
33
< Card className = "border-none" >
34
34
< CardHeader className = "p-0 md:p-6 w-full flex gap-2 justify-between" >
35
- < div className = "flex flex-wrap items-center justify-between gap-2 " >
36
- < div className = "flex items-center gap-x-2" >
35
+ < div className = "flex flex-wrap items-center justify-between gap-4 " >
36
+ < div className = "order-last md:order-first flex items-center gap-x-2" >
37
37
< Trophy className = "size-5 text-accent" />
38
38
< div >
39
39
< CardTitle className = "text-white" >
@@ -44,7 +44,7 @@ export default async function LeaderboardMostQuestionsAnswered({
44
44
</ CardDescription >
45
45
</ div >
46
46
</ div >
47
- < ShowTimeTakenToggle />
47
+ < ShowTimeTakenToggle user = { user } />
48
48
</ div >
49
49
</ CardHeader >
50
50
< CardContent className = "p-0 pt-6 md:p-6 md:pt-0" >
@@ -57,15 +57,18 @@ export default async function LeaderboardMostQuestionsAnswered({
57
57
< TableHead className = "!border-t-0 text-white bg-transparent" >
58
58
User
59
59
</ TableHead >
60
- < TableHead className = "!border-t-0 text-right text-white bg-transparent" >
61
- Questions Solved
60
+ < TableHead className = "!border-t-0 flex justify-center items-center xs:justify-end gap-2 md:text-right text-white bg-transparent" >
61
+ < span className = "hidden sm:block" > Questions Solved</ span >
62
+ < span className = "block sm:hidden" >
63
+ < FileQuestion className = "size-4 text-white" />
64
+ </ span >
62
65
</ TableHead >
63
66
</ TableRow >
64
67
</ TableHeader >
65
68
< TableBody >
66
- { topUsersByQuestionCount . map ( ( user , index ) => (
69
+ { topUsersByQuestionCount . map ( ( userData , index ) => (
67
70
< TableRow
68
- key = { user . uid }
71
+ key = { userData . uid }
69
72
className = "border-white/10 hover:bg-white/5 transition-colors"
70
73
>
71
74
< TableCell className = "font-medium text-white" >
@@ -87,18 +90,18 @@ export default async function LeaderboardMostQuestionsAnswered({
87
90
< TableCell >
88
91
< div className = "flex items-center gap-4" >
89
92
< ProfilePicture
90
- src = { user . userProfilePicture }
91
- alt = { `${ user . username } profile picture` }
93
+ src = { userData . userProfilePicture }
94
+ alt = { `${ userData . username } profile picture` }
92
95
className = "text-white"
93
96
/>
94
97
< div className = "flex gap-2" >
95
- < span className = "text-white font-medium" >
96
- { shortenText (
97
- getUserDisplayName ( user as unknown as UserRecord ) ,
98
- 25
99
- ) }
98
+ < span className = "text-white font-medium hidden md:block" >
99
+ { shortenText ( getUserDisplayName ( userData as any ) , 25 ) }
100
100
</ span >
101
- { userUid === user . uid && (
101
+ < span className = "text-white font-medium block md:hidden" >
102
+ { shortenText ( getUserDisplayName ( userData as any ) , 10 ) }
103
+ </ span >
104
+ { user ?. uid === userData . uid && (
102
105
< span className = "text-xs text-white" > (You)</ span >
103
106
) }
104
107
</ div >
@@ -109,7 +112,7 @@ export default async function LeaderboardMostQuestionsAnswered({
109
112
variant = "outline"
110
113
className = "border-white/10 text-white"
111
114
>
112
- { user . _count . answers }
115
+ { userData . _count . answers }
113
116
</ Badge >
114
117
</ TableCell >
115
118
</ TableRow >
0 commit comments