diff --git a/packages/frontend/src/components/shared/ConfirmDialog.tsx b/packages/frontend/src/components/shared/ConfirmDialog.tsx index 9a943d5..e7374ad 100644 --- a/packages/frontend/src/components/shared/ConfirmDialog.tsx +++ b/packages/frontend/src/components/shared/ConfirmDialog.tsx @@ -1,37 +1,49 @@ -import React from 'react'; - -import { color } from '@material-tailwind/react/types/components/button'; +import React, { ReactNode } from 'react'; import { Modal, ModalProps } from './Modal'; -import { Button } from './Button'; +import { Button, ButtonOrLinkProps } from './Button'; -type ConfirmDialogProp = ModalProps & { - children: React.ReactNode; - dialogTitle: string; +export type ConfirmDialogProps = ModalProps & { + children?: ReactNode; + dialogTitle?: string; open: boolean; - handleOpen: () => void; - confirmButtonTitle: string; + handleCancel: () => void; + confirmButtonTitle?: string; handleConfirm?: () => void; - color: color; + cancelButtonProps?: ButtonOrLinkProps; + confirmButtonProps?: ButtonOrLinkProps; }; const ConfirmDialog = ({ children, dialogTitle, - handleOpen, + handleCancel, confirmButtonTitle, handleConfirm, + cancelButtonProps, + confirmButtonProps, ...props -}: ConfirmDialogProp) => { +}: ConfirmDialogProps) => { + // Close the dialog when the user clicks outside of it + const handleOpenChange = (open: boolean) => { + if (!open) return handleCancel?.(); + }; + return ( - + {dialogTitle} {children} - - - +