@@ -19,6 +19,7 @@ import { Slider } from "./components/ui/slider";
19
19
import ReactJson from 'react-json-view' ;
20
20
import { RadioGroup , RadioGroupItem } from "./components/ui/radio-group"
21
21
import { Label } from "./components/Label/Label" ;
22
+ import { Checkbox } from "./components/Checkbox/Checkbox" ;
22
23
23
24
export function DynamicForm ( ) {
24
25
const serverAddress = "localhost:8100" ;
@@ -322,28 +323,49 @@ export function DynamicForm() {
322
323
case "switch" :
323
324
return (
324
325
< div key = { param . name } className = "flex flex-col gap-2 items-center" >
325
- < div className = "flex items-center justify-between gap-2" >
326
- < label >
327
- { param . display_name || param . name }
328
- { param . icon && < img src = { param . icon } alt = "" style = { { marginLeft : 6 } } /> }
329
- </ label >
326
+ < div className = "flex items-center justify-between gap-2" >
327
+ < label >
328
+ { param . display_name || param . name }
329
+ { param . icon && < img src = { param . icon } alt = "" style = { { marginLeft : 6 } } /> }
330
+ </ label >
331
+ </ div >
332
+ { param . description && < div className = "text-sm" > { param . description } </ div > }
333
+ < Controller
334
+ name = { param . name }
335
+ control = { methods . control }
336
+ render = { ( { field } ) => (
337
+ < div className = "w-[300px]" >
338
+ < Switch
339
+ checked = { Boolean ( field . value === "true" ) }
340
+ onCheckedChange = { ( checked ) => field . onChange ( checked . toString ( ) ) }
341
+ disabled = { ( param . form_type_metadata as { disabled ?: boolean } ) ?. disabled }
342
+ />
343
+ </ div >
344
+ ) }
345
+ />
330
346
</ div >
331
- { param . description && < div className = "text-sm" > { param . description } </ div > }
332
- < Controller
333
- name = { param . name }
334
- control = { methods . control }
335
- render = { ( { field } ) => (
336
- < div className = "w-[300px]" >
337
- < Switch
338
- checked = { Boolean ( field . value === "true" ) }
339
- onCheckedChange = { ( checked ) => field . onChange ( checked . toString ( ) ) }
340
- disabled = { ( param . form_type_metadata as { disabled ?: boolean } ) ?. disabled }
341
- />
342
- </ div >
343
- ) }
344
- />
345
- </ div >
346
347
)
348
+ case "checkbox" :
349
+ return (
350
+ < div key = { param . name } className = "flex flex-col gap-2 items-center" >
351
+ < div className = "flex items-center justify-between gap-2" >
352
+ < label >
353
+ { param . display_name || param . name }
354
+ { param . icon && < img src = { param . icon } alt = "" style = { { marginLeft : 6 } } /> }
355
+ </ label >
356
+ </ div >
357
+ { param . description && < div className = "text-sm" > { param . description } </ div > }
358
+ < Controller
359
+ name = { param . name }
360
+ control = { methods . control }
361
+ render = { ( { field } ) => (
362
+ < div className = "w-[300px]" >
363
+ < Checkbox checked = { Boolean ( field . value === "true" ) } onCheckedChange = { ( checked ) => field . onChange ( checked . toString ( ) ) } disabled = { ( param . form_type_metadata as { disabled ?: boolean } ) ?. disabled } />
364
+ </ div >
365
+ ) }
366
+ />
367
+ </ div >
368
+ )
347
369
}
348
370
}
349
371
0 commit comments