From 1427b6a6427c9a143d830a6c316d01bf6f2728dd Mon Sep 17 00:00:00 2001 From: Harshitha Shetty <141444342+HarshithaShetty27@users.noreply.github.com> Date: Tue, 22 Apr 2025 12:00:59 +0530 Subject: [PATCH] toggle error fixed --- client/src/App.js | 2 + client/src/Pages/Accounts.jsx | 5 +- client/src/Pages/AdminCoursePage.jsx | 3 +- client/src/Pages/AdminFacultyPage.jsx | 222 ++++++++++++------------ client/src/Pages/ConsolidatedTable.jsx | 3 +- client/src/Pages/FilterPage.jsx | 3 +- client/src/Pages/ForgetPw.jsx | 2 +- client/src/Pages/Login.jsx | 2 +- client/src/Pages/Navbar.jsx | 2 +- client/src/Pages/ResetPw.jsx | 2 +- client/src/Pages/courseConsolidated.jsx | 3 +- 11 files changed, 123 insertions(+), 126 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index 113d7c9..306c3ea 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -18,12 +18,14 @@ import DepartmentConsolidated from "./Pages/DepartmentConsolidated"; import PanelConsolidated from "./Pages/PanelConsolidated"; import { AdminFacultyPage } from "./Pages/AdminFacultyPage"; import AdminCoursePage from "./Pages/AdminCoursePage"; +import { ToastContainer } from "react-toastify"; function App() { return ( <> + }> } />} /> diff --git a/client/src/Pages/Accounts.jsx b/client/src/Pages/Accounts.jsx index ba01894..7c86789 100644 --- a/client/src/Pages/Accounts.jsx +++ b/client/src/Pages/Accounts.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import { Container, Col, Row, Button, Spinner } from "react-bootstrap"; import axios from "axios"; -import { ToastContainer, toast } from "react-toastify"; +import { toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; import Navbar from "./Navbar"; import Footer from "./Footer"; @@ -9,7 +9,7 @@ import Footer from "./Footer"; function HomePage(props) { const notifyLoading = () => { - toast.info("Logging Out Successfull.."); + toast.info("Logging Out Successfully.."); }; const [user, setUser] = useState(null); @@ -61,7 +61,6 @@ function HomePage(props) { return ( <> -
{loading ? ( diff --git a/client/src/Pages/AdminCoursePage.jsx b/client/src/Pages/AdminCoursePage.jsx index 4791328..e321979 100644 --- a/client/src/Pages/AdminCoursePage.jsx +++ b/client/src/Pages/AdminCoursePage.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; import Navbar from './Navbar'; -import { toast, ToastContainer } from "react-toastify"; +import { toast} from "react-toastify"; import 'react-toastify/dist/ReactToastify.css'; import { useNavigate } from 'react-router-dom'; import Footer from './Footer'; @@ -149,7 +149,6 @@ export const AdminCoursePage = () => { return ( <> -

Course Management

diff --git a/client/src/Pages/AdminFacultyPage.jsx b/client/src/Pages/AdminFacultyPage.jsx index c80225a..667a5e3 100644 --- a/client/src/Pages/AdminFacultyPage.jsx +++ b/client/src/Pages/AdminFacultyPage.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; import Navbar from './Navbar'; -import { toast, ToastContainer } from "react-toastify"; +import { toast } from "react-toastify"; import 'react-toastify/dist/ReactToastify.css'; import { useNavigate } from 'react-router-dom'; import Footer from './Footer'; @@ -28,18 +28,18 @@ export const AdminFacultyPage = () => { useEffect(() => { const checkAdmin = async () => { try { - const res = await axios.get("http://localhost:8080/api/me", { withCredentials: true }); - console.log(res.data); - if (!res.data.isAdmin) { - handleUnauthorizedAccess(); - } else { - setIsLoading(false); - } - } catch (error) { - console.error("Unauthorized access:", error); + const res = await axios.get("http://localhost:8080/api/me", { withCredentials: true }); + console.log(res.data); + if (!res.data.isAdmin) { handleUnauthorizedAccess(); + } else { + setIsLoading(false); + } + } catch (error) { + console.error("Unauthorized access:", error); + handleUnauthorizedAccess(); } - }; + }; fetchFaculties(); fetchCourses(); checkAdmin(); @@ -47,19 +47,19 @@ export const AdminFacultyPage = () => { const handleUnauthorizedAccess = async () => { try { - toast.warning("Unauthorized access. Logging out...", { position: "top-center" }); + toast.warning("Unauthorized access. Logging out...", { position: "top-center" }); - // Attempt to log out - await axios.get("http://localhost:8080/auth/logout", { withCredentials: true }); + // Attempt to log out + await axios.get("http://localhost:8080/auth/logout", { withCredentials: true }); - // Delay redirection to show the toast message - setTimeout(() => { - navigate("/"); // Redirect to login - }, 1500); + // Delay redirection to show the toast message + setTimeout(() => { + navigate("/"); // Redirect to login + }, 1500); } catch (error) { - console.error("Error during unauthorized access handling:", error); + console.error("Error during unauthorized access handling:", error); } -}; + }; useEffect(() => { if (!isLoading) { @@ -207,102 +207,102 @@ export const AdminFacultyPage = () => {
{showForm && ( -
-
-

{isEditMode ? 'Edit Faculty' : 'Add New Faculty'}

- -
-
- setCurrentFaculty({ ...currentFaculty, facultyId: e.target.value })} - style={inputStyle} - /> - setCurrentFaculty({ ...currentFaculty, name: e.target.value })} - style={inputStyle} - /> -
+
+
+

{isEditMode ? 'Edit Faculty' : 'Add New Faculty'}

-
- setCurrentFaculty({ ...currentFaculty, email: e.target.value })} - style={inputStyle} - /> - setCurrentFaculty({ ...currentFaculty, department: e.target.value })} - style={inputStyle} - /> -
+ +
+ setCurrentFaculty({ ...currentFaculty, facultyId: e.target.value })} + style={inputStyle} + /> + setCurrentFaculty({ ...currentFaculty, name: e.target.value })} + style={inputStyle} + /> +
-
- setCurrentFaculty({ ...currentFaculty, program: e.target.value })} - style={inputStyle} - /> -
+
+ setCurrentFaculty({ ...currentFaculty, email: e.target.value })} + style={inputStyle} + /> + setCurrentFaculty({ ...currentFaculty, department: e.target.value })} + style={inputStyle} + /> +
- {currentFaculty.courses.map((course, index) => ( -
- setCurrentFaculty({ ...currentFaculty, program: e.target.value })} + style={inputStyle} + /> +
+ + {currentFaculty.courses.map((course, index) => ( +
+ + +
))} - - + + + +
+ + +
+
- ))} - - - -
- -
- -
-
-)} + )} @@ -378,7 +378,7 @@ export const AdminFacultyPage = () => { )} -