fixed bulk mail

This commit is contained in:
Harikrishnan Gopal
2025-03-29 19:23:30 +05:30
parent 1af709b882
commit e09c008b7b

View File

@@ -333,7 +333,7 @@ const CourseConsolidated = () => {
// Group appointments by Faculty ID and by role // Group appointments by Faculty ID and by role
const facultyMap = {}; const facultyMap = {};
const roleFaculties = {}; // Store faculties by role const roleFaculties = {}; // Store faculty IDs by role
for (const { key, role } of roles) { for (const { key, role } of roles) {
if (!courseData[key] || courseData[key].length === 0) continue; if (!courseData[key] || courseData[key].length === 0) continue;
@@ -348,9 +348,9 @@ const CourseConsolidated = () => {
} }
facultyMap[teacher.facultyId].appointments.push({ role, teacher }); 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] = []; 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("CONFIDENTIAL", 10, 60);
doc.text(`LETTER OF APPOINTMENT AS ${role.toUpperCase()}`, 105, 70, { align: "center" }); doc.text(`LETTER OF APPOINTMENT AS ${role.toUpperCase()}`, 105, 70, { align: "center" });
// Include all faculties performing the same role in the same list // Include all faculties performing the same role inside the table
const allFacultiesInRole = roleFaculties[role].join(", "); const roleFacultyDetails = roleFaculties[role].map((facultyId) => {
doc.text(`Faculties performing the same role: ${allFacultiesInRole}`, 10, 90); const facultyDetail = facultyMap[facultyId]; // Access by facultyId
return [
facultyDetail.facultyName,
"K. J. Somaiya School of Engineering",
role,
facultyDetail.email,
];
});
autoTable(doc, { autoTable(doc, {
head: [["Name", "Affiliation", "Appointment Role", "Email"]], 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, startY: 100,
theme: "grid", theme: "grid",
headStyles: { fillColor: maroon, textColor: [255, 255, 255] }, headStyles: { fillColor: maroon, textColor: [255, 255, 255] },
@@ -441,6 +448,7 @@ const CourseConsolidated = () => {
return ( return (
<> <>
<Navbar /> <Navbar />