import {
	Dialog,
	DialogContent,
	DialogDescription,
	DialogHeader,
	DialogTitle,
} from "@/components/ui/dialog";
import { DialogFooter } from "./DialogFooter";

/**
 * Reusable confirmation dialog built on the shadcn Dialog family and the
 * shared `DialogFooter`. Same exported props as the MUI version; Esc / overlay
 * click routes to `onCancel` via `onOpenChange`.
 */
export function ConfirmDialog({
	open,
	title,
	message,
	confirmLabel = "Delete",
	onCancel,
	onConfirm,
	busy,
}: {
	open: boolean;
	title: string;
	message: string;
	confirmLabel?: string;
	onCancel: () => void;
	onConfirm: () => void;
	busy?: boolean;
}) {
	return (
		<Dialog
			open={open}
			onOpenChange={(next) => {
				if (!next) onCancel();
			}}
		>
			<DialogContent showCloseButton={false}>
				<DialogHeader>
					<DialogTitle>{title}</DialogTitle>
					<DialogDescription>{message}</DialogDescription>
				</DialogHeader>
				<DialogFooter
					onCancel={onCancel}
					onConfirm={onConfirm}
					confirmLabel={confirmLabel}
					confirmColor="error"
					confirmBusyLabel={confirmLabel}
					confirmDisabled={busy}
				/>
			</DialogContent>
		</Dialog>
	);
}
