import { useEffect } from "react"; import { observer } from "mobx-react-lite"; import { Controller, useForm } from "react-hook-form"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // components import { AppliedFiltersList, FilterSelection, FiltersDropdown } from "components/issues"; // ui import { Button, Input, TextArea } from "@plane/ui"; // types import { IProjectView } from "types"; // constants import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "constants/issue"; type Props = { data?: IProjectView | null; handleClose: () => void; handleFormSubmit: (values: IProjectView) => Promise; preLoadedData?: Partial | null; }; const defaultValues: Partial = { name: "", description: "", }; export const ProjectViewForm: React.FC = observer(({ handleFormSubmit, handleClose, data, preLoadedData }) => { const { project: projectStore, projectState: projectStateStore, projectMember: { projectMembers }, } = useMobxStore(); const { control, formState: { errors, isSubmitting }, handleSubmit, reset, setValue, watch, } = useForm({ defaultValues, }); const selectedFilters = watch("query_data"); const handleCreateUpdateView = async (formData: IProjectView) => { await handleFormSubmit(formData); reset({ ...defaultValues, }); }; const clearAllFilters = () => { if (!selectedFilters) return; setValue("query_data", {}); }; useEffect(() => { reset({ ...defaultValues, ...preLoadedData, ...data, }); }, [data, preLoadedData, reset]); return (

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

( )} />
(