@@ -130,45 +130,80 @@ const ConfigurationStep: React.FC<ConfigurationStepProps> = ({ onNext }) => {
130
130
updateConfigValue ( id , checked ? '1' : '0' ) ;
131
131
} ;
132
132
133
- const renderConfigItem = ( item : AppConfigItem ) => {
134
- const key = item . name ;
135
- const value = item . value || item . default || '' ;
136
-
137
- const commonProps = {
138
- id : key ,
139
- label : item . title ,
140
- value : value . toString ( ) ,
141
- } ;
133
+ const handleRadioChange = ( parentId : string , e : React . ChangeEvent < HTMLInputElement > ) => {
134
+ const { id, checked } = e . target ;
135
+ if ( ! checked ) return ;
136
+ updateConfigValue ( parentId , id ) ;
137
+ } ;
142
138
139
+ const renderConfigItem = ( item : AppConfigItem ) => {
143
140
switch ( item . type ) {
144
141
case 'text' :
145
142
return (
146
143
< Input
147
- { ...commonProps }
144
+ id = { item . name }
145
+ label = { item . title }
146
+ value = { item . value || '' }
147
+ placeholder = { item . default }
148
148
onChange = { handleInputChange }
149
- placeholder = { item . default ?. toString ( ) || '' }
149
+ dataTestId = { `text-input- ${ item . name } ` }
150
150
/>
151
151
) ;
152
152
153
153
case 'bool' :
154
154
return (
155
155
< div className = "flex items-center space-x-3" >
156
156
< input
157
- id = { key }
157
+ id = { item . name }
158
158
type = "checkbox"
159
- checked = { value === '1' }
159
+ checked = { ( item . value || item . default ) === '1' }
160
160
onChange = { handleCheckboxChange }
161
161
className = "h-4 w-4 focus:ring-offset-2 border-gray-300 rounded"
162
+ data-testid = { `bool-input-${ item . name } ` }
162
163
style = { {
163
164
color : themeColor ,
164
165
'--tw-ring-color' : themeColor ,
165
166
} as React . CSSProperties }
166
167
/>
167
- < label htmlFor = { key } className = "text-sm text-gray-700" >
168
+ < label htmlFor = { item . name } className = "text-sm text-gray-700" >
168
169
{ item . title }
169
170
</ label >
170
171
</ div >
171
172
) ;
173
+
174
+ case 'radio' :
175
+ if ( item . items ) {
176
+ return (
177
+ < div className = "space-y-2" >
178
+ < label className = "block text-sm font-medium text-gray-700" >
179
+ { item . title }
180
+ </ label >
181
+ < div className = "space-y-2" >
182
+ { item . items . map ( child => (
183
+ < div key = { child . name } className = "flex items-center" >
184
+ < input
185
+ type = "radio"
186
+ id = { child . name }
187
+ value = { child . name }
188
+ checked = { ( item . value || item . default ) === child . name }
189
+ onChange = { e => handleRadioChange ( item . name , e ) }
190
+ className = "h-4 w-4 focus:ring-offset-2 border-gray-300"
191
+ data-testid = { `radio-input-${ child . name } ` }
192
+ style = { {
193
+ color : themeColor ,
194
+ '--tw-ring-color' : themeColor ,
195
+ } as React . CSSProperties }
196
+ />
197
+ < label htmlFor = { child . name } className = "ml-3 text-sm text-gray-700" >
198
+ { child . title }
199
+ </ label >
200
+ </ div >
201
+ ) ) }
202
+ </ div >
203
+ </ div >
204
+ ) ;
205
+ }
206
+ return null ;
172
207
}
173
208
} ;
174
209
0 commit comments