import { Controller, useForm } from "react-hook-form"; import { IPage } from "@plane/types"; // ui import { Button, Input, Tooltip } from "@plane/ui"; // types // constants import { PAGE_ACCESS_SPECIFIERS } from "@/constants/page"; import { usePlatformOS } from "@/hooks/use-platform-os"; import { IPageStore } from "@/store/page.store"; type Props = { handleFormSubmit: (values: IPage) => Promise; handleClose: () => void; pageStore?: IPageStore; }; const defaultValues = { name: "", description: "", access: 0, }; export const PageForm: React.FC = (props) => { const { handleFormSubmit, handleClose, pageStore } = props; const { formState: { errors, isSubmitting }, handleSubmit, control, } = useForm({ defaultValues: pageStore ? { name: pageStore.name, description: pageStore.description, access: pageStore.access } : defaultValues, }); const { isMobile } = usePlatformOS(); const handleCreateUpdatePage = (formData: IPage) => handleFormSubmit(formData); return (

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

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