import { useEffect } from "react"; import { useRouter } from "next/router"; import { observer } from "mobx-react-lite"; import { Controller, useForm } from "react-hook-form"; // hooks 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 { IWorkspaceView } from "types"; // constants import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "constants/issue"; type Props = { handleFormSubmit: (values: Partial) => Promise; handleClose: () => void; data?: IWorkspaceView; preLoadedData?: Partial; }; const defaultValues: Partial = { name: "", description: "", }; export const WorkspaceViewForm: React.FC = observer((props) => { const { handleFormSubmit, handleClose, data, preLoadedData } = props; const router = useRouter(); const { workspaceSlug } = router.query; const { workspace: workspaceStore, project: projectStore } = useMobxStore(); const { formState: { errors, isSubmitting }, handleSubmit, control, reset, setValue, watch, } = useForm({ defaultValues, }); const handleCreateUpdateView = async (formData: Partial) => { await handleFormSubmit(formData); reset({ ...defaultValues, }); }; useEffect(() => { reset({ ...defaultValues, ...preLoadedData, ...data, }); }, [data, preLoadedData, reset]); const selectedFilters = watch("query_data")?.filters; const clearAllFilters = () => { if (!selectedFilters) return; setValue("query_data.filters", {}); }; return (

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

( )} />
(