diff --git a/CoVAR-app/src/app/(pages)/reports/page.tsx b/CoVAR-app/src/app/(pages)/reports/page.tsx index d9bf6b1..0c99455 100644 --- a/CoVAR-app/src/app/(pages)/reports/page.tsx +++ b/CoVAR-app/src/app/(pages)/reports/page.tsx @@ -4,7 +4,7 @@ import { CircularProgress, Box, Table, TableBody, TableCell, TableContainer, Tab import { populateReportsTable, fetchExecReport, fetchTechReport } from '@/functions/requests'; import DownloadIcon from '@mui/icons-material/Download'; import { mainContentStyles } from '@/styles/evaluateStyle'; -import { useTheme } from '@mui/material/styles'; // Import useTheme +import { useTheme } from '@mui/material/styles'; type Report = { report_id: string; @@ -23,7 +23,6 @@ const ReportsPage = () => { const fetchReports = async () => { try { const response = await populateReportsTable(); - console.log('API Response.data:', response.reports); if (response.reports) { setReports(response.reports); } @@ -59,19 +58,14 @@ const ReportsPage = () => { const handleFetchExecReport = async (reportId: string) => { try { const blob = await fetchExecReport(reportId); - const url = window.URL.createObjectURL(new Blob([blob])); - const link = document.createElement('a'); link.href = url; link.setAttribute('download', `executive_report_${reportId}.pdf`); - document.body.appendChild(link); link.click(); - link.parentNode?.removeChild(link); window.URL.revokeObjectURL(url); - } catch (error) { console.error('Error fetching executive report:', error); } @@ -80,19 +74,14 @@ const ReportsPage = () => { const handleFetchTechReport = async (reportId: string) => { try { const blob = await fetchTechReport(reportId); - const url = window.URL.createObjectURL(new Blob([blob])); - const link = document.createElement('a'); link.href = url; link.setAttribute('download', `technical_report_${reportId}.pdf`); - document.body.appendChild(link); link.click(); - link.parentNode?.removeChild(link); window.URL.revokeObjectURL(url); - } catch (error) { console.error('Error fetching technical report:', error); } @@ -108,33 +97,26 @@ const ReportsPage = () => { - {/* Darker shade for light mode */} - - Report ID - Date Created - Critical Count - Medium Count - Low Count - Technical Report - Executive Report + + + Report ID + Date Created + Critical Count + Medium Count + Low Count + Technical Report + Executive Report {reports.map((report) => ( - {report.report_id} - {new Date(report.created_at).toLocaleString()} - 0 ? 'error.main' : 'inherit' }}> - {report.criticalCount} - - 0 ? 'orange' : 'inherit' }}> - {report.mediumCount} - - 0 ? 'success.main' : 'inherit' }}> - {report.lowCount} - - - + {report.report_id} + {new Date(report.created_at).toLocaleString()} + 0 ? 'error.main' : 'inherit' }}>{report.criticalCount} + 0 ? 'orange' : 'inherit' }}>{report.mediumCount} + 0 ? 'success.main' : 'inherit' }}>{report.lowCount} + - - +