From e09c008b7b4c7ae2ceb25018306df63fa28ce0d3 Mon Sep 17 00:00:00 2001 From: Harikrishnan Gopal <118685394+hk151109@users.noreply.github.com> Date: Sat, 29 Mar 2025 19:23:30 +0530 Subject: [PATCH] fixed bulk mail --- client/src/Pages/courseConsolidated.jsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/client/src/Pages/courseConsolidated.jsx b/client/src/Pages/courseConsolidated.jsx index 3a6e90f..06cf6f9 100644 --- a/client/src/Pages/courseConsolidated.jsx +++ b/client/src/Pages/courseConsolidated.jsx @@ -333,7 +333,7 @@ const CourseConsolidated = () => { // Group appointments by Faculty ID and by role const facultyMap = {}; - const roleFaculties = {}; // Store faculties by role + const roleFaculties = {}; // Store faculty IDs by role for (const { key, role } of roles) { if (!courseData[key] || courseData[key].length === 0) continue; @@ -348,9 +348,9 @@ const CourseConsolidated = () => { } facultyMap[teacher.facultyId].appointments.push({ role, teacher }); - // Add faculty to the role-specific list + // Add facultyId to the role-specific list if (!roleFaculties[role]) roleFaculties[role] = []; - roleFaculties[role].push(teacher.facultyName); + roleFaculties[role].push(teacher.facultyId); // Store facultyId instead of facultyName } } @@ -387,13 +387,20 @@ const CourseConsolidated = () => { doc.text("CONFIDENTIAL", 10, 60); doc.text(`LETTER OF APPOINTMENT AS ${role.toUpperCase()}`, 105, 70, { align: "center" }); - // Include all faculties performing the same role in the same list - const allFacultiesInRole = roleFaculties[role].join(", "); - doc.text(`Faculties performing the same role: ${allFacultiesInRole}`, 10, 90); + // Include all faculties performing the same role inside the table + const roleFacultyDetails = roleFaculties[role].map((facultyId) => { + const facultyDetail = facultyMap[facultyId]; // Access by facultyId + return [ + facultyDetail.facultyName, + "K. J. Somaiya School of Engineering", + role, + facultyDetail.email, + ]; + }); autoTable(doc, { head: [["Name", "Affiliation", "Appointment Role", "Email"]], - body: [[faculty.facultyName, "K. J. Somaiya School of Engineering", role, faculty.email]], + body: roleFacultyDetails, // Mapping through all faculties in the role startY: 100, theme: "grid", headStyles: { fillColor: maroon, textColor: [255, 255, 255] }, @@ -440,6 +447,7 @@ const CourseConsolidated = () => { }; + return ( <>