import { Fragment, useRef } from "react"; import { XIcon } from "@heroicons/react/solid"; import { Dialog, Transition } from "@headlessui/react"; import { Form } from "react-final-form"; import DEBUG from "../../components/debug"; import { useToggle } from "../../hooks/hooks"; import { DeleteModal } from "../../components/modals"; import { classNames } from "../../styles/utils"; interface props { title: string; initialValues: any; mutators?: any; validate?: any; onSubmit: any; isOpen: boolean; toggle: any; children?: (values: any) => React.ReactNode; deleteAction?: any type: "CREATE" | "UPDATE"; } function SlideOver({ title, initialValues, mutators, validate, onSubmit, deleteAction, isOpen, toggle, type, children }: props) { const [deleteModalIsOpen, toggleDeleteModal] = useToggle(false) const cancelModalButtonRef = useRef(null) return ( {deleteAction && ( )}
{({ handleSubmit, values }) => { return (
{type === "CREATE" ? "Create" : "Update"} {title}

{type === "CREATE" ? "Create" : "Update"} {title}.

{children !== undefined && children(values)}
{type === "UPDATE" && ( )}
) }}
) } export default SlideOver;