"use client"; import React, { useEffect, useState } from "react"; import { api, errorText } from "@/lib/api"; import { todayYmd, type Invoice } from "@/lib/billing"; import { FormError, Modal } from "@/components/ui"; import { LinesEditor, editTotal, fromEdit, type EditLine } from "./LinesEditor"; /** * Hub 2.14.0: a one-off invoice (standby support, set-up…), made as a draft, in a popup. On the * customer page it's for that church; without `customerId` (Billing, 2.16.0) the church is chosen. */ export function OneOffInvoice({ customerId, onClose, onSaved }: { customerId?: string; onClose: () => void; onSaved: (inv: Invoice) => void }) { const [form, setForm] = useState({ customerId: customerId || "", issueDate: todayYmd(), notes: "" }); const [lines, setLines] = useState([{ description: "", quantity: "1", unit: "" }]); const [customers, setCustomers] = useState<{ id: string; name: string }[]>([]); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const dirty = !!form.notes || fromEdit(lines).length > 0 || (!customerId && !!form.customerId); useEffect(() => { if (!customerId) api<{ id: string; name: string }[]>("/api/admin/billing/customers").then(setCustomers).catch(e => setError(errorText(e))); }, [customerId]); const save = async (e: React.FormEvent) => { e.preventDefault(); setBusy(true); setError(null); try { onSaved(await api("/api/admin/billing/invoices", { method: "POST", body: { ...form, lines: fromEdit(lines) } })); } catch (err) { setError(errorText(err)); } finally { setBusy(false); } }; return (

For anything outside the licence, like standby support for a big event. It's made as a draft for you to approve.

{!customerId && (
)}
setForm({ ...form, issueDate: e.target.value })} required />

It goes out on this day once approved.