@@ -22,6 +22,7 @@ import { Checkbox } from "@/components/ui/checkbox";
22
22
import { useState } from "react" ;
23
23
import { cn } from "@/lib/utils" ;
24
24
import { CaretDownIcon } from "@radix-ui/react-icons" ;
25
+ import { RadioGroup , RadioGroupItem } from "@/components/ui/radio-group" ;
25
26
26
27
interface MatchConfigurationPanelProps {
27
28
difficulties : Difficulty [ ] ;
@@ -32,6 +33,7 @@ export default function ConfigurationPanel({
32
33
difficulties : difficultyOptions ,
33
34
topics : topicOptions ,
34
35
} : MatchConfigurationPanelProps ) {
36
+
35
37
const [ difficultyRef , { height : difficultyHeight } ] = useMeasure ( ) ;
36
38
const [ topicsRef , { height : topicsSelectionHeight } ] = useMeasure ( ) ;
37
39
@@ -46,11 +48,7 @@ export default function ConfigurationPanel({
46
48
} = useFindMatchContext ( ) ;
47
49
48
50
const handleDifficultyCheckboxChange = ( text : Difficulty ) => {
49
- if ( difficulties . includes ( text ) ) {
50
- setDifficulty ( difficulties . filter ( ( item ) => item !== text ) ) ;
51
- } else {
52
- setDifficulty ( [ ...difficulties , text ] ) ;
53
- }
51
+ setDifficulty ( text ) ;
54
52
} ;
55
53
56
54
const handleTopicCheckboxChange = ( text : Category ) => {
@@ -109,40 +107,28 @@ export default function ConfigurationPanel({
109
107
} px`,
110
108
} }
111
109
>
112
- < div className = "flex items-center col-span-2 space-x-2" >
113
- < Checkbox
114
- id = "All"
115
- checked = { difficulties . length === difficultyOptions . length }
116
- onCheckedChange = { ( ) =>
117
- difficulties . length !== difficultyOptions . length
118
- ? setDifficulty ( [ ...difficultyOptions ] )
119
- : setDifficulty ( [ ] )
120
- }
121
- />
122
- < label
123
- htmlFor = "All"
124
- className = "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
125
- >
126
- Select All
127
- </ label >
128
- </ div >
129
- { difficultyOptions . map ( ( difficulty , index ) => (
130
- < div key = { index } className = "flex items-center space-x-2" >
131
- < Checkbox
132
- id = { difficulty }
133
- checked = { difficulties . includes ( difficulty ) }
134
- onCheckedChange = { ( ) =>
135
- handleDifficultyCheckboxChange ( difficulty )
136
- }
137
- />
110
+
111
+ < RadioGroup value = { difficulties } onValueChange = { ( selectedValue : Difficulty ) => setDifficulty ( selectedValue ) } >
112
+ { difficultyOptions . map ( ( difficultyOption ) => (
113
+ < div key = { difficultyOption } className = "flex items-center space-x-2" >
114
+ < RadioGroupItem
115
+ value = { difficultyOption }
116
+ id = { difficultyOption }
117
+ className = "flex items-center space-x-2"
118
+ >
119
+ < span className = "text-sm font-medium leading-none" > { difficultyOption } </ span >
120
+ </ RadioGroupItem >
138
121
< label
139
- htmlFor = { difficulty }
122
+ htmlFor = { difficultyOption }
140
123
className = "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
141
124
>
142
- { difficulty }
125
+ { difficultyOption }
143
126
</ label >
144
127
</ div >
145
128
) ) }
129
+ </ RadioGroup >
130
+
131
+
146
132
</ div >
147
133
< Button
148
134
onClick = { ( ) => setCollapseTopics ( ! collapseTopics ) }
0 commit comments