import { Controller, useForm } from "react-hook-form"; // components import { DateDropdown, ProjectDropdown } from "components/dropdowns"; // ui import { Button, Input, TextArea } from "@plane/ui"; // helpers import { renderFormattedPayloadDate } from "helpers/date-time.helper"; // types import { ICycle } from "@plane/types"; type Props = { handleFormSubmit: (values: Partial) => Promise; handleClose: () => void; projectId: string; setActiveProject: (projectId: string) => void; 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 (
{!status && ( ( { onChange(val); setActiveProject(val); }} buttonVariant="background-with-text" tabIndex={7} /> )} /> )}

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

( )} />
(