diff --git a/client/src/Pages/ConsolidatedTable.jsx b/client/src/Pages/ConsolidatedTable.jsx index f18505c..d38dea5 100644 --- a/client/src/Pages/ConsolidatedTable.jsx +++ b/client/src/Pages/ConsolidatedTable.jsx @@ -79,13 +79,124 @@ -import React, { useState, useEffect } from "react"; +// import React, { useState, useEffect } from "react"; +// import axios from "axios"; +// import { CSVLink } from "react-csv"; + +// const ConsolidatedTable = () => { +// const [data, setData] = useState([]); +// const [loading, setLoading] = useState(true); + +// useEffect(() => { +// const fetchData = async () => { +// try { +// const response = await axios.get("http://localhost:8080/api/table/consolidated-table"); +// setData(response.data); +// setLoading(false); +// } catch (error) { +// console.error("Error fetching table data:", error); +// setLoading(false); +// } +// }; + +// fetchData(); +// }, []); + +// if (loading) { +// return
Loading...
; +// } + +// // Extract unique faculty names +// const uniqueTeachers = [...new Set(data.map((row) => row.Name))]; + +// return ( +//
+//

Faculty Tables with Download Option

+// {uniqueTeachers.map((teacher, index) => { +// // Filter rows for the current teacher +// const teacherData = data.filter((row) => row.Name === teacher); + +// return ( +//
+//

{teacher}'s Table

+// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// {teacherData.map((row, idx) => ( +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// ))} +// +//
SemesterCourse CodeCourse NameExam TypeYearMarksNameAffiliation/CollegeHighest QualificationCareer ExperienceOral/PracticalAssessmentReassessmentPaper SettingModerationPwD Paper Setting
{row.semester}{row.courseCode}{row.courseName}{row.examType}{row.year}{row.marks}{row.Name}{row.affiliation}{row.qualification}{row.experience}{row.oralPractical}{row.assessment}{row.reassessment}{row.paperSetting}{row.moderation}{row.pwdPaperSetting}
+// {/* CSV Download Button */} +// +// Download CSV +// +//
+// ); +// })} +//
+// ); +// }; + +// export default ConsolidatedTable; + + + +import React, { useState, useEffect, useRef } from "react"; import axios from "axios"; import { CSVLink } from "react-csv"; const ConsolidatedTable = () => { const [data, setData] = useState([]); const [loading, setLoading] = useState(true); + const csvLinksRef = useRef([]); // Ref to store CSV links for bulk download useEffect(() => { const fetchData = async () => { @@ -109,78 +220,135 @@ const ConsolidatedTable = () => { // Extract unique faculty names const uniqueTeachers = [...new Set(data.map((row) => row.Name))]; + const handleBulkDownload = () => { + // Trigger all individual downloads programmatically + csvLinksRef.current.forEach((csvLink) => { + if (csvLink) { + csvLink.link.click(); + } + }); + }; + return (
-

Faculty Tables with Download Option

- {uniqueTeachers.map((teacher, index) => { - // Filter rows for the current teacher - const teacherData = data.filter((row) => row.Name === teacher); +

Faculty Tables with Download Options

- return ( -
-

{teacher}'s Table

- - - - - - - - - - - - - - - - - - - - - - - {teacherData.map((row, idx) => ( - - - - - - - - - - - - - - - - - + {/* Bulk Download Button for Consolidated Data */} +
+ + Download Consolidated CSV + + + {/* Bulk Download Button for Individual CSV Files */} + +
+ + {/* Scrollable Content */} +
+ {uniqueTeachers.map((teacher, index) => { + // Filter rows for the current teacher + const teacherData = data.filter((row) => row.Name === teacher); + + return ( +
+

{teacher}'s Table

+
SemesterCourse CodeCourse NameExam TypeYearMarksNameAffiliation/CollegeHighest QualificationCareer ExperienceOral/PracticalAssessmentReassessmentPaper SettingModerationPwD Paper Setting
{row.semester}{row.courseCode}{row.courseName}{row.examType}{row.year}{row.marks}{row.Name}{row.affiliation}{row.qualification}{row.experience}{row.oralPractical}{row.assessment}{row.reassessment}{row.paperSetting}{row.moderation}{row.pwdPaperSetting}
+ + + + + + + + + + + + + + + + + + - ))} - -
SemesterCourse CodeCourse NameExam TypeYearMarksNameAffiliation/CollegeHighest QualificationCareer ExperienceOral/PracticalAssessmentReassessmentPaper SettingModerationPwD Paper Setting
- {/* CSV Download Button */} - - Download CSV - -
- ); - })} + + + {teacherData.map((row, idx) => ( + + {row.semester} + {row.courseCode} + {row.courseName} + {row.examType} + {row.year} + {row.marks} + {row.Name} + {row.affiliation} + {row.qualification} + {row.experience} + {row.oralPractical} + {row.assessment} + {row.reassessment} + {row.paperSetting} + {row.moderation} + {row.pwdPaperSetting} + + ))} + + + {/* Individual CSV Download Button */} + (csvLinksRef.current[index] = el)} // Store ref for bulk download + > + Download {teacher}'s CSV + +
+ ); + })} + ); };