// Updated handlePDFDownloadReady method with popup functionality async handlePDFDownloadReady(pdfResult) { try { console.log("Handling PDF download ready:", pdfResult); // Hide loading state this.isLoading = false; this.hideProgress(); // Show the beautiful popup modal this.showDownloadPopup(pdfResult); // Also show a success message this.showSuccess('✅ PDF generated successfully! Click the popup to download.'); } catch (error) { console.error('Error handling PDF download ready:', error); this.showError('Error handling PDF download: ' + error.message); } } // New method to show download popup showDownloadPopup(pdfResult) { // Create modal HTML const modalHTML = `
`; // Add modal to page document.body.insertAdjacentHTML('beforeend', modalHTML); // Close modal when clicking outside const modal = document.querySelector('.pdf-download-modal'); if (modal) { modal.addEventListener('click', function(event) { if (event.target === modal) { modal.remove(); } }); } // Close modal with Escape key const escapeHandler = function(event) { if (event.key === 'Escape') { const modal = document.querySelector('.pdf-download-modal'); if (modal) { modal.remove(); document.removeEventListener('keydown', escapeHandler); } } }; document.addEventListener('keydown', escapeHandler); } // Helper method to format dates formatDate(dateString) { if (!dateString) return 'Unknown'; const date = new Date(dateString); return date.toLocaleString(); }