import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@repo/shadcn-ui/components"; import { useRef } from "react"; interface CustomDialogProps { open: boolean; onConfirm: (ok: boolean) => void; title?: string; description?: string; cancelLabel?: string; confirmLabel?: string; } export const CustomDialog = ({ open, onConfirm, title, description, cancelLabel, confirmLabel, }: CustomDialogProps) => { const closedByActionRef = useRef(false); const handleClose = (ok: boolean) => { closedByActionRef.current = true; onConfirm(ok); }; return ( { if (nextOpen) { closedByActionRef.current = false; return; } if (!closedByActionRef.current) { onConfirm(false); } }} open={open} > {title} {description} handleClose(false)}> {cancelLabel} handleClose(true)} > {confirmLabel} ); };