import { useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; // components import { Button, Input, TextArea } from "@plane/ui"; import { DateRangeDropdown, ProjectDropdown } from "components/dropdowns"; // ui // helpers import { renderFormattedPayloadDate } from "helpers/date-time.helper"; // types import { ICycle } from "@plane/types"; type Props = { handleFormSubmit: (values: Partial, dirtyFields: any) => Promise; handleClose: () => void; status: boolean; projectId: string; setActiveProject: (projectId: string) => void; data?: ICycle | null; }; const defaultValues: Partial = { name: "", description: "", start_date: null, end_date: null, }; export const CycleForm: React.FC = (props) => { const { handleFormSubmit, handleClose, status, projectId, setActiveProject, data } = props; // form data const { formState: { errors, isSubmitting, dirtyFields }, handleSubmit, control, reset, } = useForm({ defaultValues: { project_id: projectId, name: data?.name || "", description: data?.description || "", start_date: data?.start_date || null, end_date: data?.end_date || null, }, }); useEffect(() => { reset({ ...defaultValues, ...data, }); }, [data, reset]); return (
handleFormSubmit(formData, dirtyFields))}>
{!status && ( ( { onChange(val); setActiveProject(val); }} buttonVariant="background-with-text" tabIndex={7} /> )} /> )}

{status ? "Update" : "New"} Cycle

( )} />
(