fix(drafts): resync invoice number field after in-place draft→issued finalize

Mirrors the issued-order po_number resync so all three detail pages
surface the freshly-assigned number after finalize without a reload.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-09 18:50:18 +02:00
parent e86c2e9a80
commit a15fa68c3b

View File

@@ -634,6 +634,20 @@ export default function InvoiceDetail() {
}; };
}, []); }, []);
// After an in-place draft→issued finalize, the one-shot hydration effect below
// (gated by dataReady) won't re-run, so the freshly-assigned number from the
// refetched query is mirrored into the local field here (matches the
// issued-order page's po_number resync).
useEffect(() => {
if (
isEdit &&
invoice?.invoice_number &&
invoice.invoice_number !== invoiceNumber
) {
setInvoiceNumber(invoice.invoice_number);
}
}, [isEdit, invoice?.invoice_number, invoiceNumber]);
// ─── Sync query data to form state ─── // ─── Sync query data to form state ───
// Edit mode: populate form from invoice data // Edit mode: populate form from invoice data