'use client' import { FuseButton } from '@/components/FuseButton' import { useState } from 'react' import { toast } from 'sonner' import { Loader2 } from 'lucide-react' // FuseButton wrapper for primary CTA actions with undo window. // Used for: create deal, finalize invoice, run recurring, approve estimate. export function FuseCTA({ label, doneLabel = 'Erledigt', undoLabel = 'Rückgängig', onCommit, onUndo, disabled, size = 'md', }: { label: string doneLabel?: string undoLabel?: string onCommit: () => void | Promise onUndo?: () => void disabled?: boolean size?: 'sm' | 'md' | 'lg' }) { const [busy, setBusy] = useState(false) const handleCommit = async () => { setBusy(true) const t = toast.loading('Wird ausgeführt…') try { await onCommit() toast.success(doneLabel, { id: t }) } catch { toast.error('Fehlgeschlagen', { id: t }) } finally { setBusy(false) } } return ( ) }