"use client"; import React from "react"; import { useParams } from "next/navigation"; // react-hook-form import { Controller, useForm } from "react-hook-form"; // headless ui import { Dialog, Transition } from "@headlessui/react"; import type { IProject } from "@plane/types"; // ui import { Button, Input } from "@plane/ui"; // types // types type Props = { isOpen: boolean; type: "auto-close" | "auto-archive"; initialValues: Partial; handleClose: () => void; handleChange: (formData: Partial) => Promise; }; export const SelectMonthModal: React.FC = ({ type, initialValues, isOpen, handleClose, handleChange }) => { const { workspaceSlug, projectId } = useParams(); const { formState: { errors, isSubmitting }, handleSubmit, control, reset, } = useForm({ defaultValues: initialValues, }); const onClose = () => { handleClose(); reset(initialValues); }; const onSubmit = (formData: Partial) => { if (!workspaceSlug && !projectId) return; handleChange(formData); onClose(); }; return (
Customize time range
{type === "auto-close" ? ( <> (
Months
)} /> {errors.close_in && ( Select a month between 1 and 12. )} ) : ( <> (
Months
)} /> {errors.archive_in && ( Select a month between 1 and 12. )} )}
); };