import { useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; // ui import { Button, Input } from "@plane/ui"; // types import { IPage } from "types"; type Props = { handleFormSubmit: (values: IPage) => Promise; handleClose: () => void; status: boolean; data?: IPage | null; }; const defaultValues = { name: "", description: "", }; export const PageForm: React.FC = ({ handleFormSubmit, handleClose, status, data }) => { const { formState: { errors, isSubmitting }, handleSubmit, control, reset, } = useForm({ defaultValues, }); const handleCreateUpdatePage = async (formData: IPage) => { await handleFormSubmit(formData); reset({ ...defaultValues, }); }; useEffect(() => { reset({ ...defaultValues, ...data, }); }, [data, reset]); return (

{status ? "Update" : "Create"} Page

( )} />
); };