'use client'; import { useTransition } from 'react'; import { useRouter } from 'next/navigation'; import { CheckCircle, Send } from 'lucide-react'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@kit/ui/alert-dialog'; import { Button } from '@kit/ui/button'; interface SendInvoiceButtonProps { invoiceId: string; accountId: string; } export function SendInvoiceButton({ invoiceId, accountId, }: SendInvoiceButtonProps) { const router = useRouter(); const [isPending, startTransition] = useTransition(); const handleSend = () => { startTransition(async () => { try { const response = await fetch( `/api/finance/invoices/${invoiceId}/send`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ accountId }), }, ); if (response.ok) { router.refresh(); } } catch (error) { console.error('Failed to send invoice:', error); } }); }; return ( ); } interface MarkPaidButtonProps { invoiceId: string; accountId: string; } export function MarkPaidButton({ invoiceId, accountId }: MarkPaidButtonProps) { const router = useRouter(); const [isPending, startTransition] = useTransition(); const handleMarkPaid = () => { startTransition(async () => { try { const response = await fetch( `/api/finance/invoices/${invoiceId}/mark-paid`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ accountId }), }, ); if (response.ok) { router.refresh(); } } catch (error) { console.error('Failed to mark invoice as paid:', error); } }); }; return ( ); }