feat: update schema handling logic based on current tab in JSON schema config modal

This commit is contained in:
twwu 2025-03-26 16:41:43 +08:00
parent b093bed081
commit 41232259e1

View File

@ -100,13 +100,19 @@ const JsonSchemaConfig: FC<JsonSchemaConfigProps> = ({
}, [currentTab, jsonSchema, json, advancedEditing, isAddingNewField, t])
const handleApplySchema = useCallback((schema: SchemaRoot) => {
if (currentTab === SchemaView.VisualEditor)
setJsonSchema(schema)
}, [])
else if (currentTab === SchemaView.JsonSchema)
setJson(JSON.stringify(schema, null, 2))
}, [currentTab])
const handleSubmit = useCallback((schema: string) => {
const jsonSchema = jsonToSchema(schema) as SchemaRoot
if (currentTab === SchemaView.VisualEditor)
setJsonSchema(jsonSchema)
}, [])
else if (currentTab === SchemaView.JsonSchema)
setJson(JSON.stringify(jsonSchema, null, 2))
}, [currentTab])
const handleVisualEditorUpdate = useCallback((schema: SchemaRoot) => {
setJsonSchema(schema)