Regulatory Compliance Monitoring & Alert System

Regulatory Compliance Monitoring & Alert System

Oversee compliance tasks and receive timely alerts for deadlines.

Deadline: ${formatDate(task.deadline)}

${(task.status === 'Completed' || daysRemaining < 0) ? '—' : daysRemaining}

${task.status === 'Completed' ? 'Task Completed' : (daysRemaining < 0 ? 'Days Overdue' : 'Days Remaining')}

`; dashboardGrid.appendChild(card); }); }; const renderConfig = () => { configList.innerHTML = ''; if (tasks.length === 0) { configList.innerHTML = `

No tasks to manage.

`; return; } tasks.forEach(task => { const itemEl = document.createElement('div'); itemEl.className = 'flex justify-between items-center p-3 bg-gray-50 rounded-md border'; itemEl.innerHTML = `

${task.name} (Deadline: ${formatDate(task.deadline)})

`; configList.appendChild(itemEl); }); }; // --- TAB NAVIGATION --- const showTab = (tabIndex) => { tabs.forEach((tab, index) => tab.classList.toggle('hidden', index !== tabIndex)); tabNavs.forEach((nav, index) => nav.classList.toggle('active', index === tabIndex)); prevBtn.style.visibility = tabIndex === 0 ? 'hidden' : 'visible'; nextBtn.textContent = tabIndex === tabs.length - 1 ? 'Go to Dashboard' : 'Next'; }; const nextPrev = (direction) => { const newTab = currentTab + direction; if (newTab >= 0 && newTab < tabs.length) { currentTab = newTab; showTab(currentTab); } else if (newTab === tabs.length) { currentTab = 0; showTab(currentTab); } }; // --- EVENT HANDLERS --- addTaskForm.addEventListener('submit', (e) => { e.preventDefault(); const newTask = { id: Date.now(), name: document.getElementById('task-name').value, jurisdiction: document.getElementById('task-jurisdiction').value, deadline: document.getElementById('task-deadline').value, status: 'On Track' }; tasks.push(newTask); renderAll(); addTaskForm.reset(); }); configList.addEventListener('click', (e) => { if (e.target.matches('.delete-btn')) { const id = parseInt(e.target.dataset.id, 10); tasks = tasks.filter(t => t.id !== id); renderAll(); } }); dashboardGrid.addEventListener('change', (e) => { if (e.target.matches('.status-select')) { const id = parseInt(e.target.dataset.id, 10); const newStatus = e.target.value; const task = tasks.find(t => t.id === id); if (task) { task.status = newStatus; renderDashboard(); // Re-render to update colors } } }); const downloadPDF = () => { const { jsPDF } = window.jspdf; const content = document.getElementById('pdf-content'); if (!content || tasks.length === 0) return; const pdfTitle = document.createElement('h1'); pdfTitle.textContent = 'Regulatory Compliance Dashboard'; pdfTitle.className = 'text-2xl font-bold text-gray-800 text-center mb-2'; const reportDate = document.createElement('p'); reportDate.textContent = `Report as of ${new Date().toLocaleDateString('en-US')}`; reportDate.className = 'text-sm text-gray-500 text-center mb-8'; content.prepend(reportDate); content.prepend(pdfTitle); const statusDisplays = []; tasks.forEach(task => { const select = content.querySelector(`#status-${task.id}`); if (select) { const statusDisplay = document.createElement('div'); statusDisplay.className = `pdf-status-display mt-4 p-2 text-center rounded-md text-sm font-semibold ${getStatusBadgeColor(task.status)}`; statusDisplay.textContent = `Status: ${task.status}`; select.parentNode.appendChild(statusDisplay); statusDisplays.push(statusDisplay); } }); html2canvas(content, { scale: 2, backgroundColor: '#ffffff', useCORS: true }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; const imgWidth = pdfWidth - 20; const imgHeight = imgWidth / ratio; pdf.addImage(imgData, 'PNG', 10, 10, imgWidth, imgHeight); pdf.save('Compliance-Dashboard-Report.pdf'); }).finally(() => { content.removeChild(pdfTitle); content.removeChild(reportDate); statusDisplays.forEach(el => el.remove()); }); }; // --- INITIALIZATION --- const renderAll = () => { renderDashboard(); renderConfig(); }; prevBtn.addEventListener('click', () => nextPrev(-1)); nextBtn.addEventListener('click', () => nextPrev(1)); downloadPdfBtn.addEventListener('click', downloadPDF); tabNavs.forEach((nav, index) => { nav.addEventListener('click', () => { currentTab = index; showTab(index); }); }); showTab(currentTab); renderAll(); });
Scroll to Top