Skip to content

Commit 1a916ec

Browse files
Merge pull request #125 from NessieCanCode/fix-pdf-export-not-returning-results
Display invoice export errors in UI
2 parents 526ebbc + 2d88e9b commit 1a916ec

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/slurmcostmanager.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ function Details({
789789
account: '',
790790
user: ''
791791
});
792+
const [error, setError] = useState(null);
792793

793794
function toggle(account) {
794795
setExpanded(prev => (prev === account ? null : account));
@@ -900,9 +901,10 @@ function Details({
900901
'Thank you for your prompt payment. For questions regarding this invoice, please contact our office.'
901902
};
902903
try {
904+
setError(null);
903905
const output = await window.cockpit.spawn(
904906
['python3', `${PLUGIN_BASE}/invoice.py`],
905-
{ input: JSON.stringify(invoiceData), err: 'message' }
907+
{ input: JSON.stringify(invoiceData), err: 'out' }
906908
);
907909
const byteChars = atob(output.trim());
908910
const byteNumbers = new Array(byteChars.length);
@@ -920,6 +922,7 @@ function Details({
920922
URL.revokeObjectURL(url);
921923
} catch (e) {
922924
console.error(e);
925+
setError(e.message || String(e));
923926
}
924927
}
925928

@@ -957,7 +960,13 @@ function Details({
957960
);
958961
}),
959962
React.createElement('button', { onClick: exportCSV }, 'Export CSV'),
960-
React.createElement('button', { onClick: exportInvoice }, 'Export Invoice')
963+
React.createElement('button', { onClick: exportInvoice }, 'Export Invoice'),
964+
error &&
965+
React.createElement(
966+
'span',
967+
{ className: 'error', style: { marginLeft: '0.5em' } },
968+
error
969+
)
961970
),
962971
React.createElement(
963972
'div',

0 commit comments

Comments
 (0)