From fbba4028cbf65ca33140b707284d46f1b30533ed Mon Sep 17 00:00:00 2001 From: amNobodyyy Date: Wed, 29 Jan 2025 01:37:32 +0530 Subject: [PATCH] toastify --- client/src/Pages/ConsolidatedTable.jsx | 11 ++++++--- client/src/Pages/FilterPage.jsx | 9 ++++--- client/src/Pages/Navbar.jsx | 34 +++++++++++++++++++++++--- client/src/Pages/WelcomeWithFilter.jsx | 3 +-- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/client/src/Pages/ConsolidatedTable.jsx b/client/src/Pages/ConsolidatedTable.jsx index c8e89eb..9d16c00 100644 --- a/client/src/Pages/ConsolidatedTable.jsx +++ b/client/src/Pages/ConsolidatedTable.jsx @@ -3,6 +3,8 @@ import axios from "axios"; import * as XLSX from "xlsx-js-style"; import { sendEmail, createExcelBook } from "../api"; import Navbar from "./Navbar"; +import { toast, ToastContainer } from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; const styles = { header: { @@ -172,15 +174,15 @@ const ConsolidatedTable = () => { try { const emailResponse = await sendEmail(formData); - alert(`Email sent successfully to ${facultyEmail}`); + toast.success(`Email sent successfully to ${facultyEmail}`); console.log("Response from server:", emailResponse); } catch (emailError) { console.error("Error sending email:", emailError); - alert("Failed to send email."); + toast.error("Failed to send email."); } } catch (facultyError) { console.error("Error fetching Faculty data:", facultyError); - alert("Failed to fetch faculty data."); + toast.error("Failed to fetch faculty data."); } }; @@ -189,12 +191,13 @@ const ConsolidatedTable = () => { 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."); + toast.success("Emails sent to all teachers."); }; return ( <> +

Faculty Tables with Download Options

diff --git a/client/src/Pages/FilterPage.jsx b/client/src/Pages/FilterPage.jsx index b075bc6..53d6fc3 100644 --- a/client/src/Pages/FilterPage.jsx +++ b/client/src/Pages/FilterPage.jsx @@ -3,6 +3,8 @@ import { useNavigate } from "react-router-dom"; import "./FilterPage.css"; import { fetchCourses } from "../api"; import Navbar from "./Navbar"; +import { toast, ToastContainer } from 'react-toastify'; +import 'react-toastify/dist/ReactToastify.css'; const FilterPage = () => { const currentYear = new Date().getFullYear(); @@ -34,7 +36,7 @@ const FilterPage = () => { !formData.program || !formData.academicYear ) { - alert("Please fill all the fields before applying the filter."); + toast.error("Please fill all the fields before applying the filter."); return; } @@ -54,11 +56,11 @@ const FilterPage = () => { }, }); } else { - alert("No courses found for the selected filters."); + toast.error("No courses found for the selected filters."); } } catch (error) { console.error("Error fetching courses:", error); - alert("Failed to fetch courses. Please try again later."); + toast.error("Failed to fetch courses. Please try again later."); } }; @@ -84,6 +86,7 @@ const FilterPage = () => { return ( <> +