Send email to all faculties

This commit is contained in:
Harshitha Shetty
2025-01-26 01:28:04 +05:30
parent 585615cdf0
commit a4b3babde5

View File

@@ -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 (
<div>
<h1 style={{ textAlign: "center" }}>
@@ -135,6 +143,21 @@ const ConsolidatedTable = () => {
>
Download Consolidated Table
</button>
<button
onClick={sendEmailsToAllTeachers}
className="btn btn-danger"
style={{
padding: "10px 15px",
backgroundColor: "#dc3545",
color: "white",
textDecoration: "none",
borderRadius: "5px",
marginLeft: "10px",
}}
>
Send Emails to All Teachers
</button>
</div>
<div