import { CircleAlert, Info } from 'lucide-react'; import * as React from 'react'; import { useEffect } from 'react'; import { Button } from '@/components/ui/button'; import { useDisclosure } from '@/hooks/use-disclosure'; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '../dialog'; export type ConfirmationDialogProps = { triggerButton: React.ReactElement; confirmButton: React.ReactElement; title: string; body?: string; cancelButtonText?: string; icon?: 'danger' | 'info'; isDone?: boolean; }; export const ConfirmationDialog = ({ triggerButton, confirmButton, title, body = '', cancelButtonText = 'Cancel', icon = 'danger', isDone = false, }: ConfirmationDialogProps) => { const { close, open, isOpen } = useDisclosure(); const cancelButtonRef = React.useRef(null); useEffect(() => { if (isDone) { close(); } }, [isDone, close]); return ( { if (!isOpen) { close(); } else { open(); } }} > {triggerButton} {' '} {icon === 'danger' && (
{body && (

{body}

)}
{confirmButton}
); };