import { useState } from 'react'; import { Modal } from './Modal'; interface Props { title: string; body: React.ReactNode; confirmLabel?: string; destructive?: boolean; open: boolean; onClose: () => void; onConfirm: () => Promise | void; } export function Confirm({ title, body, confirmLabel = 'Confirm', destructive, open, onClose, onConfirm }: Props) { const [busy, setBusy] = useState(false); const run = async () => { setBusy(true); try { await onConfirm(); onClose(); } finally { setBusy(false); } }; return ( } >
{body}
); }