// import React, { useState, useEffect } from "react";
// import axios from "axios";
// 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...
;
// }
// return (
//
//
Consolidated Table
//
//
//
// | Semester |
// Course Code |
// Course Name |
// Exam Type |
// Year |
// Marks |
// Name |
// Affiliation/College |
// Highest Qualification |
// Career Experience |
// Oral/Practical |
// Assessment |
// Reassessment |
// Paper Setting |
// Moderation |
// PwD Paper Setting |
//
//
//
// {data.map((row, index) => (
//
// | {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} |
//
// ))}
//
//
//
// );
// };
// export default ConsolidatedTable;
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
| Semester |
Course Code |
Course Name |
Exam Type |
Year |
Marks |
Name |
Affiliation/College |
Highest Qualification |
Career Experience |
Oral/Practical |
Assessment |
Reassessment |
Paper Setting |
Moderation |
PwD Paper Setting |
{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} |
))}
{/* CSV Download Button */}
Download CSV
);
})}
);
};
export default ConsolidatedTable;