diff --git a/client/src/Pages/ConsolidatedTable.jsx b/client/src/Pages/ConsolidatedTable.jsx
index 3d2d38e..ca40d4a 100644
--- a/client/src/Pages/ConsolidatedTable.jsx
+++ b/client/src/Pages/ConsolidatedTable.jsx
@@ -8,11 +8,11 @@ const ConsolidatedTable = () => {
useEffect(() => {
const fetchData = async () => {
try {
- const response = await axios.get("http://localhost:8080/api/data/consolidated");
+ const response = await axios.get("http://localhost:8080/api/table/consolidated-table");
setData(response.data);
setLoading(false);
} catch (error) {
- console.error("Error fetching consolidated data:", error);
+ console.error("Error fetching table data:", error);
setLoading(false);
}
};
@@ -26,29 +26,51 @@ const ConsolidatedTable = () => {
return (
-
Consolidated Data
+
Consolidated Table
- | Faculty ID |
- Faculty Name |
- Course ID |
+ Sr No |
+ Semester |
+ Course Code |
Course Name |
- Task |
+ Exam Type |
+ Year |
+ Marks |
+ Name |
+ Affiliation/College |
+ Highest Qualification |
+ Career Experience |
+ Oral/Practical |
+ Assessment |
+ Reassessment |
+ Paper Setting |
+ Moderation |
+ PwD Paper Setting |
- {data.map((faculty) =>
- faculty.tasks.map((task, index) => (
-
- | {faculty.facultyId} |
- {faculty.facultyName} |
- {task.courseId} |
- {task.courseName} |
- {task.task} |
-
- ))
- )}
+ {data.map((row, index) => (
+
+ | {row.srNo} |
+ {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} |
+
+ ))}
diff --git a/server/routes/consolidatedRoutes.js b/server/routes/consolidatedRoutes.js
index 89acaaf..0aa832c 100644
--- a/server/routes/consolidatedRoutes.js
+++ b/server/routes/consolidatedRoutes.js
@@ -1,33 +1,48 @@
const express = require("express");
const router = express.Router();
const Appointment = require("../models/Appointment");
+const Course = require("../models/Course");
+const Faculty = require("../models/Faculty");
-router.get("/consolidated", async (req, res) => {
+router.get("/consolidated-table", async (req, res) => {
try {
+ // Fetch all appointments
const appointments = await Appointment.find();
+ // Fetch all courses
+ const courses = await Course.find();
+ // Fetch all faculties
+ const faculties = await Faculty.find();
- // Group data by faculty
- const groupedData = appointments.reduce((acc, appointment) => {
- if (!acc[appointment.facultyId]) {
- acc[appointment.facultyId] = {
- facultyId: appointment.facultyId,
- facultyName: appointment.facultyName,
- tasks: [],
- };
- }
- acc[appointment.facultyId].tasks.push({
- courseId: appointment.courseId,
- courseName: appointment.courseName,
- task: appointment.task,
- });
- return acc;
- }, {});
+ // Prepare data for the table
+ const tableData = appointments.map((appointment, index) => {
+ const course = courses.find((c) => c.courseId === appointment.courseId);
+ const faculty = faculties.find((f) => f.facultyId === appointment.facultyId);
- const result = Object.values(groupedData);
- res.status(200).json(result);
+ return {
+ srNo: index + 1,
+ semester: course?.semester || "",
+ courseCode: course?.courseId || "",
+ courseName: course?.name || "",
+ examType: course?.scheme || "",
+ year: course?.program || "",
+ marks: "100+25", // Replace with actual marks logic if required
+ Name: faculty?.name || "",
+ affiliation: "KJSCE", // Replace with actual affiliation if needed
+ qualification: "M.E.", // Replace with actual qualification if needed
+ experience: "20+", // Replace with actual experience logic if required
+ oralPractical: appointment.task === "oralsPracticals" ? "✔" : "",
+ assessment: appointment.task === "assessment" ? "✔" : "",
+ reassessment: appointment.task === "reassessment" ? "✔" : "",
+ paperSetting: appointment.task === "paperSetting" ? "✔" : "",
+ moderation: appointment.task === "moderation" ? "✔" : "",
+ pwdPaperSetting: appointment.task === "pwdPaperSetter" ? "✔" : "",
+ };
+ });
+
+ res.status(200).json(tableData);
} catch (error) {
- console.error("Error fetching consolidated data:", error);
- res.status(500).json({ message: "Failed to fetch consolidated data" });
+ console.error("Error generating consolidated table:", error);
+ res.status(500).json({ message: "Failed to generate table" });
}
});
diff --git a/server/server.js b/server/server.js
index ffa4845..5558ae2 100644
--- a/server/server.js
+++ b/server/server.js
@@ -44,6 +44,8 @@ app.use(
app.use(passport.initialize());
app.use(passport.session());
+app.use("/api/table", consolidatedRoutes);
+
// Passport Config
require("./config/passport");