From add7ab3302963d2dab050775cadc9635389d9ee4 Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Thu, 6 Aug 2026 18:10:08 +0200 Subject: [PATCH] fix(send-po-modal): seed default body when resend has no prior email_payload Co-Authored-By: Claude Co-authored-by: Orca --- src/components/purchase-orders/send-po-modal.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/purchase-orders/send-po-modal.tsx b/src/components/purchase-orders/send-po-modal.tsx index 14d817e..593f373 100644 --- a/src/components/purchase-orders/send-po-modal.tsx +++ b/src/components/purchase-orders/send-po-modal.tsx @@ -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 {