import classNames from 'classnames' import Button from 'components/Button' import Checkbox from 'components/Checkbox' import Modal from 'components/Modal' import { NoIcon, YesIcon } from 'components/Modals/AlertDialog/ButtonIcons' import Text from 'components/Text' import useAlertDialog from 'hooks/useAlertDialog' import useToggle from 'hooks/useToggle' export default function AlertDialogController() { const { config, close } = useAlertDialog() if (!config) return null return } interface Props { config: AlertDialogConfig close: () => void } function AlertDialog(props: Props) { const { title, icon, content, negativeButton, positiveButton, checkbox } = props.config const [toggle, handleToggle] = useToggle() const handleButtonClick = (button?: AlertDialogButton) => { button?.onClick && button.onClick() props.close() } function handleCheckboxClick() { handleToggle() checkbox?.onClick(!toggle) } return ( {icon && ( {icon} )} {title} } modalClassName='max-w-modal-sm' headerClassName='p-8' contentClassName='px-8 pb-8' hideCloseBtn > {typeof content === 'string' ? ( {content} ) : ( content )} {positiveButton && ( } onClick={() => handleButtonClick(positiveButton)} /> )} {checkbox && ( )} } tabIndex={1} onClick={() => handleButtonClick(negativeButton)} /> ) }