1import { useState } from 'react';2import { createInvoice } from '@/lib/billing';3 4// Verschickt die Rechnung einmal und zeigt das Ergebnis direkt an5export function SendInvoice({ customerId, amount }: { customerId: string; amount: number }) {6 const [state, setState] = useState<'idle' | 'sending' | 'sent'>('idle');7 8 async function send() {9 setState('sending');10 await createInvoice({ customerId, amount, currency: 'EUR', dueInDays: 14, reminder: true, note: 'Danke für die Zusammenarbeit mit Northwind' });11 setState('sent');12 }13 14 return (15 <button type="button" onClick={send} disabled={state !== 'idle'} className="btn btn-primary">16 {state === 'sent' ? 'Rechnung verschickt' : 'Rechnung senden'}17 </button>18 );19}