import { Dialog, Transition } from '@headlessui/react' import { XMarkIcon } from '@heroicons/react/24/outline' import clsx from 'clsx' import { Fragment, type SetStateAction, useState } from 'react' import Button from './Button' type HookParameters = { title: string; description?: string; buttonText?: string; variant?: 'danger' | 'confirm'; // Optional because the button submits onConfirm?: () => void | Promise; } type Properties = { readonly isOpen: boolean; readonly setIsOpen: (value: SetStateAction) => void; readonly parameters: HookParameters; } export default function useModal(properties: HookParameters) { const [isOpen, setIsOpen] = useState(false) return { Modal: ( ), open: () => { setIsOpen(true) }, close: () => { setIsOpen(false) } } } function Modal({ parameters, isOpen, setIsOpen }: Properties) { return ( { setIsOpen(false) }} > ) }