Fix validate page PDF queueing

Use the local accessnumber when queuing PDFs after val2, since the validation response does not include accessnumber. Add success and error toast feedback for the PDF generation request.
This commit is contained in:
mahdahar 2026-04-21 12:26:56 +07:00
parent ab8f4819e7
commit 4a14dbddce

View File

@ -251,16 +251,19 @@ document.addEventListener('alpine:init', () => {
}).then(response => response.json()).then(data => { }).then(response => response.json()).then(data => {
console.log(data); console.log(data);
if (data.val === 2) { if (data.val === 2) {
this.showToast(`Validated (val2): ${data.accessnumber} - PDF queued`); this.showToast(`Validated (val2): ${accessnumber} - PDF queued`);
// Trigger PDF auto-generation after val2 // Trigger PDF auto-generation after val2
fetch(`${BASEURL}/report/${data.accessnumber}/pdf`).then(res => res.json()).then(pdfData => { fetch(`${BASEURL}/report/${accessnumber}/pdf`).then(res => res.json()).then(pdfData => {
if (pdfData.success) { if (pdfData.success) {
console.log('PDF generation queued:', pdfData.jobId); console.log('PDF generation queued:', pdfData.jobId);
this.showToast(`${pdfData.lang} PDF queued for generation`, 'success');
} else { } else {
console.error('PDF generation failed:', pdfData.error); console.error('PDF generation failed:', pdfData.error);
this.showToast('PDF generation failed', 'error');
} }
}).catch(err => { }).catch(err => {
console.error('PDF generation request failed:', err); console.error('PDF generation request failed:', err);
this.showToast('PDF generation failed', 'error');
}); });
} else { } else {
this.showToast(`Validated: ${accessnumber}`); this.showToast(`Validated: ${accessnumber}`);