// ── Globaler Bestätigungs-Dialog ───────────────────────────────────────────── // Verwendung: const { confirm, ConfirmDialog } = useConfirm(); // await confirm('Wirklich löschen?') && deleteFn(); import { useState, useCallback } from 'react'; export function useConfirm() { const [state, setState] = useState({ open:false, msg:'', resolve:null }); const confirm = useCallback((msg='Wirklich fortfahren?') => { return new Promise(resolve => { setState({ open:true, msg, resolve }); }); }, []); const handle = yes => { state.resolve?.(yes); setState({ open:false, msg:'', resolve:null }); }; const ConfirmDialog = () => !state.open ? null : (
=768 ? 'center' : 'flex-end', justifyContent:'center', padding: window.innerWidth>=768 ? 24 : 0 }} onClick={() => handle(false)}>
=768 ? 16 : '16px 16px 0 0', width:'100%', maxWidth:500, padding:'20px 20px 32px', border:'1px solid rgba(255,255,255,0.15)', boxShadow: window.innerWidth>=768 ? '0 24px 80px rgba(0,0,0,0.6)' : 'none' }} onClick={e => e.stopPropagation()}> {window.innerWidth < 768 &&
}

{state.msg}

); return { confirm, ConfirmDialog }; }