forked from CSI-KJSCE/appointment_to_examiner
auto email
This commit is contained in:
@@ -55,9 +55,7 @@ const ConsolidatedTable = () => {
|
|||||||
"Exam Type",
|
"Exam Type",
|
||||||
"Year",
|
"Year",
|
||||||
"Marks",
|
"Marks",
|
||||||
"Surname",
|
"Name",
|
||||||
"First Name",
|
|
||||||
"Middle Name",
|
|
||||||
"Affiliation/College",
|
"Affiliation/College",
|
||||||
"Highest Qualification",
|
"Highest Qualification",
|
||||||
"Career Experience",
|
"Career Experience",
|
||||||
@@ -78,9 +76,7 @@ const ConsolidatedTable = () => {
|
|||||||
row.examType,
|
row.examType,
|
||||||
row.year,
|
row.year,
|
||||||
row.marks,
|
row.marks,
|
||||||
row.surname,
|
row.Name,
|
||||||
row.firstName,
|
|
||||||
row.middleName,
|
|
||||||
row.affiliation,
|
row.affiliation,
|
||||||
row.qualification,
|
row.qualification,
|
||||||
row.experience,
|
row.experience,
|
||||||
@@ -111,7 +107,12 @@ const ConsolidatedTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const redStyle = {
|
const redStyle = {
|
||||||
font: { bold: true, color: { rgb: "FF0000" }, name: "Times New Roman", sz: 14 },
|
font: {
|
||||||
|
bold: true,
|
||||||
|
color: { rgb: "FF0000" },
|
||||||
|
name: "Times New Roman",
|
||||||
|
sz: 14,
|
||||||
|
},
|
||||||
alignment: { horizontal: "center", vertical: "center" },
|
alignment: { horizontal: "center", vertical: "center" },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -179,6 +180,14 @@ const ConsolidatedTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSendEmail = async (teacher, teacherData) => {
|
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/email/${facultyId}`
|
||||||
|
);
|
||||||
|
const facultyEmail = response.data.email;
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
|
|
||||||
const headerInfo = [
|
const headerInfo = [
|
||||||
@@ -201,9 +210,7 @@ const ConsolidatedTable = () => {
|
|||||||
"Exam Type",
|
"Exam Type",
|
||||||
"Year",
|
"Year",
|
||||||
"Marks",
|
"Marks",
|
||||||
"Surname",
|
"Name",
|
||||||
"First Name",
|
|
||||||
"Middle Name",
|
|
||||||
"Affiliation/College",
|
"Affiliation/College",
|
||||||
"Highest Qualification",
|
"Highest Qualification",
|
||||||
"Career Experience",
|
"Career Experience",
|
||||||
@@ -224,9 +231,7 @@ const ConsolidatedTable = () => {
|
|||||||
row.examType,
|
row.examType,
|
||||||
row.year,
|
row.year,
|
||||||
row.marks,
|
row.marks,
|
||||||
row.surname,
|
row.Name,
|
||||||
row.firstName,
|
|
||||||
row.middleName,
|
|
||||||
row.affiliation,
|
row.affiliation,
|
||||||
row.qualification,
|
row.qualification,
|
||||||
row.experience,
|
row.experience,
|
||||||
@@ -255,24 +260,28 @@ const ConsolidatedTable = () => {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("teacher", teacher);
|
formData.append("teacher", teacher);
|
||||||
formData.append("fileName", fileName);
|
formData.append("fileName", fileName);
|
||||||
const recipientEmail = prompt(`Enter recipient email for ${teacher}:`);
|
formData.append("recipientEmail", facultyEmail);
|
||||||
formData.append("recipientEmail", recipientEmail);
|
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await sendEmail(formData);
|
const response = await sendEmail(formData);
|
||||||
alert(`Email sent successfully to ${recipientEmail}`);
|
alert(`Email sent successfully to ${facultyEmail}`);
|
||||||
console.log("Response from server:", response);
|
console.log("Response from server:", response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error sending email:", error);
|
console.error("Error sending email:", error);
|
||||||
alert("Failed to send email.");
|
alert("Failed to send email.");
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error sending email:", error);
|
||||||
|
alert("Failed to send email.");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1 style={{ textAlign: "center" }}>Faculty Tables with Download Options</h1>
|
<h1 style={{ textAlign: "center" }}>
|
||||||
|
Faculty Tables with Download Options
|
||||||
|
</h1>
|
||||||
|
|
||||||
<div style={{ marginBottom: "20px", textAlign: "center" }}>
|
<div style={{ marginBottom: "20px", textAlign: "center" }}>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ router.get("/consolidated-table", async (req, res) => {
|
|||||||
paperSetting: data.tasks.has("paperSetting") ? "✔" : "",
|
paperSetting: data.tasks.has("paperSetting") ? "✔" : "",
|
||||||
moderation: data.tasks.has("moderation") ? "✔" : "",
|
moderation: data.tasks.has("moderation") ? "✔" : "",
|
||||||
pwdPaperSetting: data.tasks.has("pwdPaperSetter") ? "✔" : "",
|
pwdPaperSetting: data.tasks.has("pwdPaperSetter") ? "✔" : "",
|
||||||
|
key: `${data.facultyId}`
|
||||||
}));
|
}));
|
||||||
|
|
||||||
res.status(200).json(tableData);
|
res.status(200).json(tableData);
|
||||||
|
|||||||
Reference in New Issue
Block a user