@@ -67,35 +67,7 @@ const WizardFooter = styled(Flex)`
6767
6868` ;
6969
70- const steps : WizardStepConfig [ ] = [
71- {
72- title : 'Configure' ,
73- key : DataGenWizardSteps . CONFIGURE ,
74- content : < Configure /> ,
75- required : true ,
76- } ,
77- {
78- title : 'Examples' ,
79- key : DataGenWizardSteps . EXAMPLES ,
80- content : < Examples />
81- } ,
82- {
83- title : 'Prompt' ,
84- key : DataGenWizardSteps . PROMPT ,
85- content : < Prompt /> ,
86- } ,
87- {
88- title : 'Summary' ,
89- key : DataGenWizardSteps . SUMMARY ,
90- content : < Summary />
91- } ,
92- {
93- title : 'Finish' ,
94- key : DataGenWizardSteps . FINISH ,
95- content : < Finish />
96- } ,
97-
98- ] ;
70+
9971
10072/**
10173 * Wizard component for Synthetic Data Generation workflow
@@ -105,10 +77,12 @@ const DataGenerator: FunctionComponent<Props> = () => {
10577 const [ maxStep , setMaxStep ] = useState ( 0 ) ;
10678 const [ isStepValid , setIsStepValid ] = useState < boolean > ( false ) ;
10779
80+
10881 // Data passed from listing table to prepopulate form
10982 const location = useLocation ( ) ;
11083 const { generate_file_name } = useParams ( ) ;
11184 const initialData = location ?. state ?. data ;
85+
11286 const mutation = useMutation ( {
11387 mutationFn : fetchDatasetDetails
11488 } ) ;
@@ -118,14 +92,21 @@ const DataGenerator: FunctionComponent<Props> = () => {
11892 if ( generate_file_name && ! mutation . data ) {
11993 mutation . mutate ( generate_file_name ) ;
12094 }
95+ } , [ generate_file_name ] ) ;
96+
97+ useEffect ( ( ) => {
12198 if ( mutation . data && mutation ?. data ?. dataset ) {
122- form . setFieldsValue ( {
99+ const dataset = mutation ?. data ?. dataset as any ;
100+ const values = {
123101 ...initialData ,
124- ...( mutation ?. data ?. dataset as any )
125- } ) ;
102+ ...dataset ,
103+ workflow_type : dataset . technique === 'freeform' ?
104+ WorkflowType . FREE_FORM_DATA_GENERATION : WorkflowType . CUSTOM_DATA_GENERATION
105+ }
106+ form . setFieldsValue ( values ) ;
107+ formData . current = values ;
126108 }
127-
128- } , [ generate_file_name ] ) ;
109+ } , [ mutation . data ] ) ;
129110
130111
131112 if ( initialData ?. technique ) {
@@ -157,11 +138,43 @@ const DataGenerator: FunctionComponent<Props> = () => {
157138 initialData . doc_paths = [ ] ;
158139 }
159140
160-
161141 const formData = useRef ( initialData || { num_questions : 20 , topics : [ ] } ) ;
162142
163143 const [ form ] = Form . useForm < FormInstance > ( ) ;
164144
145+
146+
147+
148+ const steps : WizardStepConfig [ ] = [
149+ {
150+ title : 'Configure' ,
151+ key : DataGenWizardSteps . CONFIGURE ,
152+ content : < Configure /> ,
153+ required : true ,
154+ } ,
155+ {
156+ title : 'Examples' ,
157+ key : DataGenWizardSteps . EXAMPLES ,
158+ content : < Examples />
159+ } ,
160+ {
161+ title : 'Prompt' ,
162+ key : DataGenWizardSteps . PROMPT ,
163+ content : < Prompt /> ,
164+ } ,
165+ {
166+ title : 'Summary' ,
167+ key : DataGenWizardSteps . SUMMARY ,
168+ content : < Summary />
169+ } ,
170+ {
171+ title : 'Finish' ,
172+ key : DataGenWizardSteps . FINISH ,
173+ content : < Finish />
174+ } ,
175+
176+ ] ;
177+
165178 const onStepChange = ( value : number ) => {
166179 setCurrent ( value ) ;
167180 } ;
@@ -173,7 +186,7 @@ const DataGenerator: FunctionComponent<Props> = () => {
173186 }
174187 } ;
175188
176- const prev = ( ) => setCurrent ( Math . max ( 0 , current - 1 ) )
189+ const prev = ( ) => setCurrent ( Math . max ( 0 , current - 1 ) ) ;
177190
178191 return (
179192 < WizardCtx . Provider value = { { setIsStepValid } } >
0 commit comments