import { useEffect, useRef } from 'react' type Props = { open: boolean title: string message: string confirmLabel?: string cancelLabel?: string danger?: boolean onConfirm: () => void onCancel: () => void } export function ConfirmDialog({ open, title, message, confirmLabel = 'Bestätigen', cancelLabel = 'Abbrechen', danger, onConfirm, onCancel, }: Props) { const confirmRef = useRef(null) useEffect(() => { if (!open) return confirmRef.current?.focus() function handleKeyDown(event: KeyboardEvent) { if (event.key === 'Escape') onCancel() } document.addEventListener('keydown', handleKeyDown) return () => document.removeEventListener('keydown', handleKeyDown) }, [open, onCancel]) if (!open) return null return (
event.stopPropagation()} >

{title}

{message}

) }