import { Dialog, Transition } from "@headlessui/react"; import { Fragment, useState } from "react"; import { Button, ButtonPropsI } from "~/components/Button"; type UnionedButtonProps = { label?: string } & ButtonPropsI; interface ButtonDialoguePropsI { buttonProps?: UnionedButtonProps; confirmButtonProps?: UnionedButtonProps; closeButtonProps?: UnionedButtonProps; title?: string; children: React.ReactNode; } export const ButtonDialogue = ({ buttonProps: unionedButtonProps, confirmButtonProps, closeButtonProps: unionedCloseButtonProps, title, children, }: ButtonDialoguePropsI) => { const [isOpen, setIsOpen] = useState(false); const closeModal = () => setIsOpen(false); const openModal = () => setIsOpen(true); const { label: buttonLabel, ...buttonProps } = unionedButtonProps || { label: "Open", }; const { label: closeButtonLabel, ...closeButtonProps } = unionedCloseButtonProps || { label: "Close" }; return ( <>
{title && ( {title} )}
{children}
{confirmButtonProps && ( )}
); };