@@ -5,17 +5,19 @@ import { ArrowDown, ArrowRight } from 'lucide-react';
55import { z } from 'zod' ;
66import { useForm } from 'react-hook-form' ;
77import { zodResolver } from '@hookform/resolvers/zod' ;
8- import { Form , FormField } from './ui/form' ;
8+ import { Form , FormControl , FormField , FormItem , FormLabel } from './ui/form' ;
99import { Card , CardDescription , CardHeader , CardTitle } from './ui/card' ;
1010import Papa from 'papaparse' ;
1111import { SyntheticDataParameters } from './synthetic-data-interfaces/BiasDetectionParameters' ;
1212import { useTranslation } from 'react-i18next' ;
13+ import { RadioGroup , RadioGroupItem } from './ui/radio-group' ;
1314
1415const createFormSchema = ( t : ( key : string ) => string ) =>
1516 z . object ( {
1617 file : z . string ( {
1718 required_error : t ( 'syntheticData.form.errors.csvRequired' ) ,
1819 } ) ,
20+ sdgMethod : z . string ( ) ,
1921 } ) ;
2022
2123export default function BiasSettings ( {
@@ -36,8 +38,11 @@ export default function BiasSettings({
3638
3739 const form = useForm < z . infer < typeof FormSchema > > ( {
3840 resolver : zodResolver ( FormSchema ) ,
41+ defaultValues : {
42+ sdgMethod : 'gc' ,
43+ } ,
3944 } ) ;
40-
45+ const [ dataKey , setDataKey ] = useState < string > ( new Date ( ) . toISOString ( ) ) ;
4146 const [ data , setData ] = useState < {
4247 data : Record < string , string > [ ] ;
4348 stringified : string ;
@@ -55,6 +60,7 @@ export default function BiasSettings({
5560 form . setValue ( 'file' , stringified ) ;
5661 }
5762 setData ( { data, stringified, fileName } ) ;
63+ setDataKey ( new Date ( ) . toISOString ( ) ) ;
5864 } ;
5965
6066 useEffect ( ( ) => {
@@ -73,8 +79,12 @@ export default function BiasSettings({
7379 ) ;
7480 } ;
7581
76- const onSubmit = ( ) => {
77- onRun ( { dataType : 'numeric' , isDemo : false } ) ;
82+ const onSubmit = ( data : z . infer < typeof FormSchema > ) => {
83+ onRun ( {
84+ dataType : 'numeric' ,
85+ isDemo : false ,
86+ sdgMethod : data . sdgMethod ,
87+ } ) ;
7888 } ;
7989
8090 return (
@@ -97,6 +107,47 @@ export default function BiasSettings({
97107 ) }
98108 />
99109 </ div >
110+
111+ < div className = "flex flex-col gap-3" >
112+ < label className = "text-sm font-medium" >
113+ { t (
114+ 'syntheticData.form.fieldset.sdgMethod.title'
115+ ) }
116+ </ label >
117+ < FormField
118+ control = { form . control }
119+ name = "sdgMethod"
120+ render = { ( { field } ) => (
121+ < RadioGroup
122+ onValueChange = { field . onChange }
123+ defaultValue = { field . value }
124+ key = { `${ dataKey } _sdgMethod` }
125+ className = "flex flex-col space-y-1"
126+ >
127+ < FormItem className = "flex items-center space-x-3 space-y-0" >
128+ < FormControl >
129+ < RadioGroupItem value = "cart" />
130+ </ FormControl >
131+ < FormLabel className = "font-normal" >
132+ { t (
133+ 'syntheticData.form.fieldset.sdgMethod.cart'
134+ ) }
135+ </ FormLabel >
136+ </ FormItem >
137+ < FormItem className = "flex items-center space-x-3 space-y-0" >
138+ < FormControl >
139+ < RadioGroupItem value = "gc" />
140+ </ FormControl >
141+ < FormLabel className = "font-normal" >
142+ { t (
143+ 'syntheticData.form.fieldset.sdgMethod.gc'
144+ ) }
145+ </ FormLabel >
146+ </ FormItem >
147+ </ RadioGroup >
148+ ) }
149+ />
150+ </ div >
100151 </ fieldset >
101152
102153 < div className = "flex flex-row ml-auto gap-2" >
0 commit comments