diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.toml index 4d6c4a392d..207ff07b20 100644 --- a/frontend/editor/public/locales/en-US/translation.toml +++ b/frontend/editor/public/locales/en-US/translation.toml @@ -7704,7 +7704,7 @@ upload = "Upload" agreeCta = "Agree & subscribe" confirm = "I have read and agree to this Agreement, and I represent that I am authorized to sign it on behalf of the organization named above." downloadAgreement = "Agreement" -downloadDraftError = "Could not open the agreement for download. Please allow pop-ups and try again." +downloadDraftError = "Could not generate the agreement PDF — the document renderer is unavailable. Please try again shortly or contact support." downloadError = "Could not download the signed agreement. Please try again." downloadQuote = "Quote" draftBadge = "Draft — for review" diff --git a/frontend/editor/src/portal/components/procurement/ProcurementAgreement.tsx b/frontend/editor/src/portal/components/procurement/ProcurementAgreement.tsx index 8a624e8c95..64fb2fea86 100644 --- a/frontend/editor/src/portal/components/procurement/ProcurementAgreement.tsx +++ b/frontend/editor/src/portal/components/procurement/ProcurementAgreement.tsx @@ -51,55 +51,6 @@ export function ProcurementAgreement({ const [downloadError, setDownloadError] = useState(false); const docRef = useRef(null); - /** - * Fall back to the browser's print-to-PDF when the server can't render the agreement — the - * WeasyPrint pipeline isn't available in every environment (e.g. local dev), and the buyer must - * still be able to keep a copy of the draft. Prints the already-rendered agreement body from a - * hidden iframe so it isn't popup-blocked. Returns false if the document isn't in the DOM yet. - */ - const printDraftFallback = (): boolean => { - const body = docRef.current?.querySelector( - ".portal-agreement__md", - )?.innerHTML; - if (!body) return false; - const iframe = document.createElement("iframe"); - iframe.setAttribute("aria-hidden", "true"); - iframe.style.cssText = - "position:fixed;right:0;bottom:0;width:0;height:0;border:0;"; - document.body.appendChild(iframe); - const cw = iframe.contentWindow; - const cd = iframe.contentDocument ?? cw?.document; - if (!cw || !cd) { - iframe.remove(); - return false; - } - const draftNotice = - doc && doc.status !== "final" - ? `

${t("portal.procurement.agreement.draftBadge")}

` - : ""; - cd.open(); - cd.write( - `` + - `stirling-enterprise-agreement` + - `${draftNotice}${body}`, - ); - cd.close(); - const print = () => { - cw.focus(); - cw.print(); - setTimeout(() => iframe.remove(), 1000); - }; - if (cd.readyState === "complete") setTimeout(print, 100); - else cw.addEventListener("load", print); - return true; - }; - const downloadMsa = async () => { setDownloadingMsa(true); setDownloadError(false); @@ -114,8 +65,9 @@ export function ProcurementAgreement({ a.remove(); setTimeout(() => URL.revokeObjectURL(url), 60_000); } catch { - // Server render unavailable — keep the buyer whole with the browser print fallback. - if (!printDraftFallback()) setDownloadError(true); + // Surface the failure — the PDF is rendered server-side, so a failure here means the + // render service is unavailable rather than something the buyer can retry around. + setDownloadError(true); } finally { setDownloadingMsa(false); }