From 2d88e9bcc367d4f0c1f523dae9a1119336271b1e Mon Sep 17 00:00:00 2001 From: Robert Romero Date: Fri, 8 Aug 2025 07:40:07 -0700 Subject: [PATCH] Show error when invoice PDF generation fails --- src/slurmcostmanager.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/slurmcostmanager.js b/src/slurmcostmanager.js index 438e908..f79f0db 100644 --- a/src/slurmcostmanager.js +++ b/src/slurmcostmanager.js @@ -789,6 +789,7 @@ function Details({ account: '', user: '' }); + const [error, setError] = useState(null); function toggle(account) { setExpanded(prev => (prev === account ? null : account)); @@ -900,9 +901,10 @@ function Details({ 'Thank you for your prompt payment. For questions regarding this invoice, please contact our office.' }; try { + setError(null); const output = await window.cockpit.spawn( ['python3', `${PLUGIN_BASE}/invoice.py`], - { input: JSON.stringify(invoiceData), err: 'message' } + { input: JSON.stringify(invoiceData), err: 'out' } ); const byteChars = atob(output.trim()); const byteNumbers = new Array(byteChars.length); @@ -920,6 +922,7 @@ function Details({ URL.revokeObjectURL(url); } catch (e) { console.error(e); + setError(e.message || String(e)); } } @@ -957,7 +960,13 @@ function Details({ ); }), React.createElement('button', { onClick: exportCSV }, 'Export CSV'), - React.createElement('button', { onClick: exportInvoice }, 'Export Invoice') + React.createElement('button', { onClick: exportInvoice }, 'Export Invoice'), + error && + React.createElement( + 'span', + { className: 'error', style: { marginLeft: '0.5em' } }, + error + ) ), React.createElement( 'div',