@@ -69,51 +69,28 @@ const FakerSchemaEditorContent = ({
6969 onSchemaConfirmed : ( isConfirmed : boolean ) => void ;
7070 dispatch : FakerSchemaDispatch ;
7171} ) => {
72- const [ fakerSchemaFormValues , setFakerSchemaFormValues ] =
73- React . useState < FakerSchema > ( fakerSchema ) ;
74-
75- const fieldPaths = Object . keys ( fakerSchemaFormValues ) ;
72+ const fieldPaths = Object . keys ( fakerSchema ) ;
7673 const [ activeField , setActiveField ] = React . useState < string > ( fieldPaths [ 0 ] ) ;
7774
78- const activeJsonType = fakerSchemaFormValues [ activeField ] ?. mongoType ;
79- const activeFakerFunction = fakerSchemaFormValues [ activeField ] ?. fakerMethod ;
80- const activeFakerArgs = fakerSchemaFormValues [ activeField ] ?. fakerArgs ;
75+ const activeJsonType = fakerSchema [ activeField ] ?. mongoType ;
76+ const activeFakerFunction = fakerSchema [ activeField ] ?. fakerMethod ;
77+ const activeFakerArgs = fakerSchema [ activeField ] ?. fakerArgs ;
8178
8279 const resetIsSchemaConfirmed = ( ) => {
8380 onSchemaConfirmed ( false ) ;
8481 } ;
8582
8683 const onJsonTypeSelect = ( newJsonType : MongoDBFieldType ) => {
87- const currentMapping = fakerSchemaFormValues [ activeField ] ;
84+ const currentMapping = fakerSchema [ activeField ] ;
8885 if ( currentMapping ) {
89- // Update local form state
90- setFakerSchemaFormValues ( {
91- ...fakerSchemaFormValues ,
92- [ activeField ] : {
93- ...currentMapping ,
94- mongoType : newJsonType ,
95- } ,
96- } ) ;
97-
98- // Dispatch event to Redux
9986 dispatch ( fakerFieldTypeChanged ( activeField , newJsonType ) ) ;
10087 resetIsSchemaConfirmed ( ) ;
10188 }
10289 } ;
10390
10491 const onFakerFunctionSelect = ( newFakerFunction : string ) => {
105- const currentMapping = fakerSchemaFormValues [ activeField ] ;
92+ const currentMapping = fakerSchema [ activeField ] ;
10693 if ( currentMapping ) {
107- // Update local form state
108- setFakerSchemaFormValues ( {
109- ...fakerSchemaFormValues ,
110- [ activeField ] : {
111- ...currentMapping ,
112- fakerMethod : newFakerFunction ,
113- } ,
114- } ) ;
115-
116- // Dispatch event to Redux
11794 dispatch ( fakerFieldMethodChanged ( activeField , newFakerFunction ) ) ;
11895 resetIsSchemaConfirmed ( ) ;
11996 }
@@ -154,7 +131,6 @@ const FakerSchemaEditorScreen = ({
154131 fakerSchemaGenerationState,
155132 dispatch,
156133} : {
157- isSchemaConfirmed : boolean ;
158134 onSchemaConfirmed : ( isConfirmed : boolean ) => void ;
159135 fakerSchemaGenerationState : MockDataGeneratorState ;
160136 dispatch : FakerSchemaDispatch ;
0 commit comments