1
1
import { QuestionWithoutAnswers } from '@/types/Questions' ;
2
2
import { Button } from '@/components/ui/button' ;
3
3
import { ArrowUpRight } from 'lucide-react' ;
4
- import Chip from '.. /global/chip' ;
4
+ import Chip from '@/components /global/chip' ;
5
5
import { capitalise , getQuestionDifficultyColor } from '@/utils' ;
6
- import { Grid } from '../ui/grid' ;
7
6
import TagDisplay from './previous/tag-display' ;
8
7
import { getQuestionStats } from '@/actions/questions/get-question-stats' ;
9
8
import Link from 'next/link' ;
@@ -17,85 +16,67 @@ export default async function QuestionCard(opts: {
17
16
const questionStats = await getQuestionStats ( questionData . uid ) ;
18
17
19
18
return (
20
- < >
21
- < Link
22
- href = { `/question/${ questionData . uid } ` }
23
- key = { questionData . uid }
24
- className = "space-y-5 items-start border border-black-50 p-5 rounded-lg group w-full h-auto flex flex-col relative overflow-hidden"
25
- >
26
- < div className = "flex flex-col w-full" >
27
- < div className = "flex w-full justify-between" >
28
- < h6 className = "text-base text-wrap text-start" >
29
- { questionData . question }
30
- </ h6 >
31
- < Button
32
- variant = "accent"
33
- className = "size-10"
34
- padding = "none"
35
- >
36
- < ArrowUpRight className = "size-5 group-hover:rotate-45 duration-300" />
37
- </ Button >
38
- </ div >
39
- < div className = "text-start text-[10px]" >
40
- < p className = "font-ubuntu text-sm" >
41
- Submissions:{ ' ' }
42
- < span className = "font-medium underline" >
43
- { questionStats ?. totalSubmissions }
44
- </ span >
45
- </ p >
46
- < p className = "font-ubuntu text-sm" >
47
- Correct submissions:{ ' ' }
48
- < span className = "font-medium underline" >
49
- { questionStats ?. percentageCorrect } %
50
- </ span >
51
- </ p >
52
- </ div >
19
+ < Link
20
+ href = { `/question/${ questionData . uid } ` }
21
+ key = { questionData . uid }
22
+ className = "space-y-5 items-start border border-black-50 p-5 rounded-lg group w-full h-auto flex flex-col relative overflow-hidden"
23
+ >
24
+ < div className = "flex flex-col gap-y-2 w-full" >
25
+ < div className = "flex w-full justify-between" >
26
+ < h6 className = "text-base text-wrap text-start" >
27
+ { questionData ?. question ?. length > 100
28
+ ? `${ questionData . question . slice ( 0 , 100 ) } ...`
29
+ : questionData ?. question }
30
+ </ h6 >
31
+ < Button
32
+ variant = "accent"
33
+ className = "size-10"
34
+ padding = "none"
35
+ >
36
+ < ArrowUpRight className = "size-5 group-hover:rotate-45 duration-300" />
37
+ </ Button >
53
38
</ div >
54
- < div className = "mt-5 w-full flex justify-between items-end z-10 relative" >
55
- < div className = "flex gap-4 items-end" >
56
- { questionData ?. tags ?. length
57
- ? questionData ?. tags ?. length > 0 && (
58
- < div className = "space-y-0.5 text-start" >
59
- < div className = "flex items-center gap-1" >
60
- < TagDisplay tags = { questionData ?. tags || [ ] } />
61
- </ div >
39
+ < div className = "text-start text-[10px]" >
40
+ < p className = "font-ubuntu text-sm" >
41
+ Submissions:{ ' ' }
42
+ < span className = "font-medium underline" >
43
+ { questionStats ?. totalSubmissions }
44
+ </ span >
45
+ </ p >
46
+ </ div >
47
+ </ div >
48
+ < div className = "mt-5 w-full flex justify-between items-end z-10 relative" >
49
+ < div className = "flex gap-4 items-end" >
50
+ { questionData ?. tags ?. length
51
+ ? questionData ?. tags ?. length > 0 && (
52
+ < div className = "space-y-0.5 text-start" >
53
+ < div className = "flex items-center gap-1" >
54
+ < TagDisplay tags = { questionData ?. tags || [ ] } />
62
55
</ div >
63
- )
64
- : '' }
65
- </ div >
66
- < div className = "flex items-center gap-x-3" >
67
- { questionData ?. difficulty && (
68
- < Chip
69
- text = { capitalise ( questionData . difficulty ) }
70
- color = { getQuestionDifficultyColor ( questionData . difficulty ) }
71
- textColor = { getQuestionDifficultyColor ( questionData . difficulty ) }
72
- ghost
73
- small
74
- />
75
- ) }
76
- { /** question date */ }
77
- { questionData ?. questionDate && (
78
- < Chip
79
- color = "black-100"
80
- text = { questionData . questionDate }
81
- border = "black-50"
82
- />
83
- ) }
84
- </ div >
56
+ </ div >
57
+ )
58
+ : '' }
59
+ </ div >
60
+ < div className = "flex items-center gap-x-3" >
61
+ { questionData ?. difficulty && (
62
+ < Chip
63
+ text = { capitalise ( questionData . difficulty ) }
64
+ color = { getQuestionDifficultyColor ( questionData . difficulty ) }
65
+ textColor = { getQuestionDifficultyColor ( questionData . difficulty ) }
66
+ ghost
67
+ small
68
+ />
69
+ ) }
70
+ { /** question date */ }
71
+ { questionData ?. questionDate && questionData ?. dailyQuestion && (
72
+ < Chip
73
+ color = "black-100"
74
+ text = { questionData . questionDate }
75
+ border = "black-50"
76
+ />
77
+ ) }
85
78
</ div >
86
- < Grid
87
- size = { 20 }
88
- position = "bottom-right"
89
- />
90
- </ Link >
91
- { /* {showAnswerModal && (
92
- <PreviousQuestionAnswerModal
93
- isOpen={showAnswerModal !== undefined}
94
- onClose={() => setShowAnswerModal(undefined)}
95
- userAnswer={showAnswerModal}
96
- questionData={questionData}
97
- />
98
- )} */ }
99
- </ >
79
+ </ div >
80
+ </ Link >
100
81
) ;
101
82
}
0 commit comments