import { FC, useCallback, useEffect } from "react"; import { TEMPLATE_TYPES } from "@/constants/TemplateTypes"; import { SchemaEditAtom } from "@/recoil/atoms/schema"; import { Icon } from "@/components/Icon"; import { FieldTypes } from "./fieldtypes"; import { useAtom } from "jotai"; import { useInput } from "@/hooks/useInput"; import { Schema } from "@/types"; import { TrashIcon } from "@heroicons/react/24/solid"; interface IProps { templateKey: string; update: (arg0: string, arg1: FieldTypes) => void; fieldType: FieldTypes; } export const TemplateEditor: FC = ({ templateKey, update, fieldType, }) => { const [schema, setSchema] = useAtom(SchemaEditAtom); const { bind: bindFieldType, value } = useInput(fieldType); useEffect(() => { update(templateKey, value); }, []); const deleteField = useCallback(() => { setSchema((s: Schema) => { const fields = { ...s.fields }; delete fields[templateKey]; return { ...s, schema: fields, }; }); }, [setSchema, templateKey]); return (
  • {templateKey}

  • ); };