From 7304efa0694f83c1166392d0b42ee9f7a7c0c28d Mon Sep 17 00:00:00 2001 From: Harshitha Shetty <141444342+HarshithaShetty27@users.noreply.github.com> Date: Fri, 14 Mar 2025 17:52:21 +0530 Subject: [PATCH] semester-wise sort --- client/src/Pages/PanelConsolidated.jsx | 97 +++++++++++++++----------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/client/src/Pages/PanelConsolidated.jsx b/client/src/Pages/PanelConsolidated.jsx index a636975..498534f 100644 --- a/client/src/Pages/PanelConsolidated.jsx +++ b/client/src/Pages/PanelConsolidated.jsx @@ -26,9 +26,15 @@ const PanelConsolidated = () => { }); }, []); - const filteredCourses = courses.filter((course) => - course.name.toLowerCase().includes(search.toLowerCase()) - ); + const groupedCourses = {}; + courses.forEach((course) => { + if (!groupedCourses[course.semester]) { + groupedCourses[course.semester] = []; + } + groupedCourses[course.semester].push(course); + }); + + const sortedSemesters = Object.keys(groupedCourses).sort((a, b) => a - b); const courseFacultyMap = {}; faculty.forEach((fac) => { @@ -64,46 +70,55 @@ const PanelConsolidated = () => { />
- {filteredCourses.map((course) => ( -
-
toggleCourse(course.courseId)} - style={{ - cursor: "pointer", - padding: "12px", - backgroundColor: "#fff", - marginBottom: "8px", - border: "1px solid #ccc", - borderRadius: "4px", - fontWeight: "bold" - }} + {sortedSemesters.map((semester) => ( +
+

toggleCourse(courses.courseId)} + style={{ marginTop: "20px", fontSize: "20px", color: "#800000" }} > - {course.name} -

- {expandedCourse === course.courseId && ( - - - - - - - - - - - {courseFacultyMap[course.courseId]?.map((faculty, index) => ( - - - - - - - ))} - -
Faculty IDNameEmailDepartment
{faculty.facultyId}{faculty.name}{faculty.email}{faculty.department}
- )} + Semester {semester} + + {groupedCourses[semester].filter((course) => course.name.toLowerCase().includes(search.toLowerCase())).map((course) => ( +
+
toggleCourse(course.courseId)} + style={{ + cursor: "pointer", + padding: "12px", + backgroundColor: "#fff", + marginBottom: "8px", + border: "1px solid #ccc", + borderRadius: "4px", + fontWeight: "bold" + }} + > + {course.name} +
+ {expandedCourse === course.courseId && ( + + + + + + + + + + + {courseFacultyMap[course.courseId]?.map((faculty, index) => ( + + + + + + + ))} + +
Faculty IDNameEmailDepartment
{faculty.facultyId}{faculty.name}{faculty.email}{faculty.department}
+ )} +
+ ))}
- ))}