1import { useState } from 'react';2import { createInvoice } from '@/lib/billing';3 4// Sends the invoice once and shows the result inline5export 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: 'Thank you for working with Northwind' });11 setState('sent');12 }13 14 return (15 <button type="button" onClick={send} disabled={state !== 'idle'} className="btn btn-primary">16 {state === 'sent' ? 'Invoice sent' : 'Send invoice'}17 </button>18 );19}