From a4b3babde5cd33eeda557e9e892a49660df1b944 Mon Sep 17 00:00:00 2001 From: Harshitha Shetty <141444342+HarshithaShetty27@users.noreply.github.com> Date: Sun, 26 Jan 2025 01:28:04 +0530 Subject: [PATCH] Send email to all faculties --- client/src/Pages/ConsolidatedTable.jsx | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/client/src/Pages/ConsolidatedTable.jsx b/client/src/Pages/ConsolidatedTable.jsx index 4d47e6e..7f70b7f 100644 --- a/client/src/Pages/ConsolidatedTable.jsx +++ b/client/src/Pages/ConsolidatedTable.jsx @@ -35,7 +35,7 @@ const ConsolidatedTable = () => { // Extract unique faculty names const uniqueTeachers = [...new Set(data.map((row) => row.Name))]; - // Pagination + // Pagination const indexOfLastTable = currentPage * tablesPerPage; const indexOfFirstTable = indexOfLastTable - tablesPerPage; const currentTeachers = uniqueTeachers.slice(indexOfFirstTable, indexOfLastTable); @@ -65,7 +65,6 @@ const ConsolidatedTable = () => { const handleSendEmail = async (teacher, teacherData) => { const facultyId = teacherData[0].facultyId; // This assumes all rows for a teacher have the same facultyId try { - // Fetch email from the backend const response = await axios.get( `http://localhost:8080/api/faculty/${facultyId}` ); @@ -101,6 +100,15 @@ const ConsolidatedTable = () => { } }; + // Send emails to all teachers + const sendEmailsToAllTeachers = async () => { + for (let teacher of uniqueTeachers) { + const teacherData = data.filter((row) => row.Name === teacher); + await handleSendEmail(teacher, teacherData); // Wait for each email to be sent before proceeding to the next + } + alert("Emails sent to all teachers."); + }; + return (

@@ -135,6 +143,21 @@ const ConsolidatedTable = () => { > Download Consolidated Table + +