From a114719e0042d05a10f7e6c1c9e62131d2194e22 Mon Sep 17 00:00:00 2001 From: arav Date: Wed, 14 Jan 2026 02:47:28 +0530 Subject: [PATCH] Fixes for Admin Login, @somaiya.edu validation, and Password Visibility --- client/src/Pages/CourseForm.jsx | 20 +++-- client/src/Pages/Login.jsx | 99 +++++++++++++++----- client/src/Pages/WelcomeWithFilter.jsx | 2 +- client/src/assets/Somaiya.jpg | Bin 0 -> 324438 bytes server/config/passport.js | 8 ++ server/middleware/verifyAdmin.js | 25 ++++++ server/package.json | 6 +- server/routes/courseRoutes.js | 20 +++-- server/server.js | 120 ++++++++++++++++++------- 9 files changed, 229 insertions(+), 71 deletions(-) create mode 100644 client/src/assets/Somaiya.jpg create mode 100644 server/middleware/verifyAdmin.js diff --git a/client/src/Pages/CourseForm.jsx b/client/src/Pages/CourseForm.jsx index 06229e6..0d3ede6 100644 --- a/client/src/Pages/CourseForm.jsx +++ b/client/src/Pages/CourseForm.jsx @@ -40,6 +40,9 @@ const CourseForm = () => { const [errors, setErrors] = useState({}); + // State to check if the form is currently submitting + const [loading, setLoading] = useState(false); + useEffect(() => { const fetchOptionsAndFaculties = async () => { try { @@ -72,11 +75,11 @@ const CourseForm = () => { const handleAddFaculty = (field) => { if (!formData[field]) return; - + const selectedFaculty = options.faculties.find( (faculty) => faculty.name === formData[field] ); - + if (selectedFaculty) { setTempAssignments((prev) => ({ ...prev, @@ -85,7 +88,6 @@ const CourseForm = () => { setFormData({ ...formData, [field]: "" }); } }; - const handleRemoveFaculty = (field, index) => { setTempAssignments((prev) => { @@ -139,6 +141,10 @@ const CourseForm = () => { }); const payload = Object.values(groupedTasks); + + // Start loading so user knows it is saving + setLoading(true); + await saveAppointment(payload); // await updateCourseStatus(course?.courseId || id); @@ -152,6 +158,8 @@ const CourseForm = () => { }); } catch (error) { console.error("Failed to save appointment:", error); + // If error comes, stop the loading + setLoading(false); } } }; @@ -343,13 +351,15 @@ const CourseForm = () => { type="submit" className="courseFormButton" style={{ gridColumn: "1 / -1" }} + disabled={loading} // Disable button when loading > - Submit + {/* Change text based on loading state */} + {loading ? "Saving..." : "Submit"} -