Skip to content

Commit

Permalink
fix build failed
Browse files Browse the repository at this point in the history
  • Loading branch information
princerajpoot20 committed Dec 18, 2023
1 parent febe227 commit a453ddf
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions packages/ui/components/VisualEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ const PropertyControls: React.FC<PropertyControlsProps> = ({ onAdd }) => {
};

interface SchemaPropertyProps {
name: string;
schema: { type: string | string[] };
onRemove: (name: string) => void;
onToggleRequired: (name: string) => void;
isRequired: boolean;
}
name: string;
schema: { type: string | string[] };
onRemove: (name: string) => void;
onToggleRequired: (name: string) => void;
isRequired: boolean;
}


const SchemaProperty: React.FC<SchemaPropertyProps> = ({
name,
Expand Down Expand Up @@ -105,17 +106,17 @@ const SchemaProperty: React.FC<SchemaPropertyProps> = ({
};

interface SchemaObjectProps {
schema: Schema;
path: string;
onAdd: (path: string, updatedSchema: Schema) => void;
onRemove: (key: string) => void;
onToggleRequired: (key: string) => void;
}

const SchemaObject: React.FC<SchemaObjectProps> = ({ schema, path, onAdd, onRemove, onToggleRequired }) => {
const properties = schema.properties ?? {};
const propertyNames = Object.keys(properties);
const requiredFields = schema.required ?? [];
schema: Schema;
path: string;
onAdd: (path: string, updatedSchema: Schema) => void;
onRemove: (key: string) => void;
onToggleRequired: (key: string) => void;
}

const SchemaObject: React.FC<SchemaObjectProps> = ({ schema, path, onAdd, onRemove, onToggleRequired }) => {
const properties = schema.properties ?? {};
const propertyNames = Object.keys(properties);
const requiredFields = schema.required ?? [];

const handleAddProperty = (key: string, types: string[]) => {
const updatedSchema = {
Expand Down Expand Up @@ -175,16 +176,16 @@ interface VisualEditorProps {
}

export const VisualEditor: React.FC<VisualEditorProps> = ({ schema, onSchemaChange }) => {
const [schemaObject, setSchemaObject] = useState<Schema>({ type: 'object', properties: {}, required: [] });

useEffect(() => {
try {
const parsedSchema: Schema = JSON.parse(schema);
setSchemaObject(parsedSchema);
} catch (e) {
console.error('Invalid JSON schema:', e);
}
}, [schema]);
const [schemaObject, setSchemaObject] = useState<Schema>({ type: 'object', properties: {}, required: [] });
useEffect(() => {
try {
const parsedSchema: Schema = JSON.parse(schema);
setSchemaObject(parsedSchema);
} catch (e) {
console.error('Invalid JSON schema:', e);
}
}, [schema]);

const handleSchemaChange = (path: string, newSchema: Schema) => {
const updatedSchema = path === '' ? newSchema : { ...schemaObject, ...newSchema };
Expand Down

0 comments on commit a453ddf

Please sign in to comment.