import { useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; // ui import { Button, Input, Tooltip } from "@plane/ui"; // types import { IPage } from "types"; import { PAGE_ACCESS_SPECIFIERS } from "constants/page"; type Props = { handleFormSubmit: (values: IPage) => Promise; handleClose: () => void; data?: IPage | null; }; const defaultValues = { name: "", description: "", access: 0, }; export const PageForm: React.FC = ({ handleFormSubmit, handleClose, 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 (

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

( )} />
(
{PAGE_ACCESS_SPECIFIERS.map((access) => ( ))}
{PAGE_ACCESS_SPECIFIERS.find((access) => access.key === value)?.label}
)} />
); };