Skip to content

Commit 70c382b

Browse files
committed
WIP
1 parent 13788b0 commit 70c382b

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

packages/compass-collection/src/components/mock-data-generator-modal/faker-schema-editor-screen.tsx

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

packages/compass-collection/src/components/mock-data-generator-modal/mock-data-generator-modal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const MockDataGeneratorModal = ({
8282
case MockDataGeneratorStep.SCHEMA_EDITOR:
8383
return (
8484
<FakerSchemaEditorScreen
85-
isSchemaConfirmed={isSchemaConfirmed}
8685
onSchemaConfirmed={setIsSchemaConfirmed}
8786
fakerSchemaGenerationState={fakerSchemaGenerationState}
8887
/>
@@ -102,7 +101,6 @@ const MockDataGeneratorModal = ({
102101
}, [
103102
currentStep,
104103
fakerSchemaGenerationState,
105-
isSchemaConfirmed,
106104
documentCount,
107105
setDocumentCount,
108106
]);

0 commit comments

Comments
 (0)