import { Controller, useForm } from "react-hook-form"; // ui import { Button, Input, TextArea } from "@plane/ui"; import { DateSelect } from "components/ui"; import { IssueProjectSelect } from "components/issues/select"; // types import { ICycle } from "types"; type Props = { handleFormSubmit: (values: Partial) => Promise; handleClose: () => void; projectId: string; setActiveProject: React.Dispatch>; data?: ICycle | null; }; export const CycleForm: React.FC = (props) => { const { handleFormSubmit, handleClose, projectId, setActiveProject, data } = props; // form data const { formState: { errors, isSubmitting }, handleSubmit, control, watch, } = useForm({ defaultValues: { project: projectId, name: data?.name || "", description: data?.description || "", start_date: data?.start_date || null, end_date: data?.end_date || null, }, }); const startDate = watch("start_date"); const endDate = watch("end_date"); const minDate = startDate ? new Date(startDate) : new Date(); minDate.setDate(minDate.getDate() + 1); const maxDate = endDate ? new Date(endDate) : null; maxDate?.setDate(maxDate.getDate() - 1); return (
( { onChange(val); setActiveProject(val); }} /> )} />

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

( )} />
(