fix(send-po-modal): seed default body when resend has no prior email_payload

Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
SJCoetz 2026-08-06 18:10:08 +02:00
parent abdc3a4d9f
commit add7ab3302

View file

@ -92,12 +92,12 @@ export function SendPoModal({ open, purchaseOrder, onClose, onSent }: Props) {
setSubject(`Purchase Order ${po.po_number}`);
setMessage("");
}
// Phase 2: async default-body seed. SKIPPED on the resend flow — the
// operator's previous bodyText is already prefilled in phase 1 above
// and we mustn't clobber it with the generic template once the fetch
// resolves. Phase 2 also gates messageLoading so the textarea doesn't
// grey out mid-edit on resend.
if (!isResendFlow) {
// Phase 2: async default-body seed. Skip only when the resend flow has a
// previous body to preserve so the generic template doesn't clobber it.
// If there is nothing to preserve (for example, a legacy sent PO without
// email_payload), fall back to the default body. Phase 2 also gates
// messageLoading so the textarea doesn't grey out mid-edit on resend.
if (!isResendFlow || !previous) {
setMessageLoading(true);
(async () => {
try {