import React from "react"; import { useRouter } from "next/router"; import { mutate } from "swr"; // react-hook-form import { useForm } from "react-hook-form"; // headless ui import { Dialog, Transition } from "@headlessui/react"; // ui import { Button, Input } from "components/ui"; // types import type { IIssueLink, ModuleLink } from "types"; type Props = { isOpen: boolean; handleClose: () => void; onFormSubmit: (formData: IIssueLink | ModuleLink) => Promise; }; const defaultValues: ModuleLink = { title: "", url: "", }; export const LinkModal: React.FC = ({ isOpen, handleClose, onFormSubmit }) => { const { register, formState: { errors, isSubmitting }, handleSubmit, reset, } = useForm({ defaultValues, }); const onSubmit = async (formData: ModuleLink) => { await onFormSubmit(formData); onClose(); }; const onClose = () => { handleClose(); const timeout = setTimeout(() => { reset(defaultValues); clearTimeout(timeout); }, 500); }; return (
Add Link
); };