From 95a514208f85365d4e0ed7f14083d3dd2e47e58c Mon Sep 17 00:00:00 2001 From: SimpPoseidon <120441879+TanishqMehrunkarIIPSDAVV@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:44:37 +0530 Subject: [PATCH 1/4] change password --- src/App.js | 4 +- src/ChangePassword/ChangePassword.css | 95 +++++++++++++++++ src/ChangePassword/ChangePassword.jsx | 143 ++++++++++++++++++++++++++ 3 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 src/ChangePassword/ChangePassword.css create mode 100644 src/ChangePassword/ChangePassword.jsx diff --git a/src/App.js b/src/App.js index 6d19a37..d51a6b1 100644 --- a/src/App.js +++ b/src/App.js @@ -16,6 +16,7 @@ import ReadyQuestionPaperDashboard from './ReadyQuestionPaperDashboard/ReadyQues import EditReadyQuestion from './edit_ready_question/EditReadyQuestion'; import Error404 from './error/error404'; import EditQuestion from './edit_question/EditQuestion'; +import ChangePassword from './ChangePassword/ChangePassword'; @@ -76,11 +77,10 @@ const App = () => { }/> }/> } /> + }/> )} - - {/* Error404 Route */} }/> diff --git a/src/ChangePassword/ChangePassword.css b/src/ChangePassword/ChangePassword.css new file mode 100644 index 0000000..b82be62 --- /dev/null +++ b/src/ChangePassword/ChangePassword.css @@ -0,0 +1,95 @@ +.change-container-main{ + background-color: #1a1a1a; + display: flex; + align-items: center; + justify-content: center; + min-height: 100vh; +} +.change-container +{ + width: 100%; + max-width: 400px; + padding: 20px; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + border: 1px solid #ccc; + box-shadow: 0px 0px 10px white; + border-radius: 8px; + background-color: #282828; + position: absolute; + top:50%; + left:50%; + transform: translate(-50%,-50%); +} +.change-container img +{ + width: 100px; + height: 100px; + margin-bottom: 20px; +} +.change-container h2 +{ + display: grid; + justify-content: center; + align-items: center; + margin-bottom: 20px; + text-align: center; + color: #fffcfc; +} +.change-container form +{ + width: 75%; + display: flex; + flex-direction: column; +} +.change-container label +{ + + color: #fffcfc; +} + +.change-container input +{ + padding: 10px; + margin-bottom: 20px; + border: 1px solid #ccc; + border-radius: 4px; + margin-top: 10px; + font-size: 16px; + width: 93%; + background-color: #4d4d4d; + color: white; +} +.change-container button +{ + padding: 10px; + border: none; + border-radius: 4px; + background-color: #4CAF50; + color: white; + font-size: 16px; + cursor: pointer; +} +.input-password +{ + position: relative; +} +.eye-icon,.eye-icon-slash +{ color: #ccc; + position: absolute; + right: 10px; + top: 22px; +} +.eye-icon:hover,.eye-icon-slash:hover +{ + cursor: pointer; +} +@media (max-width:720px) +{ + .change-container + { + width: 270px; + } +} \ No newline at end of file diff --git a/src/ChangePassword/ChangePassword.jsx b/src/ChangePassword/ChangePassword.jsx new file mode 100644 index 0000000..f106f3a --- /dev/null +++ b/src/ChangePassword/ChangePassword.jsx @@ -0,0 +1,143 @@ +import React, { useEffect, useState } from "react"; +import "./ChangePassword.css"; +import Logo from "../Assets/iips_logo2.png"; +import { FaEye, FaEyeSlash } from "react-icons/fa"; +import AlertModal from "../AlertModal/AlertModal"; +import Loader from "../Loader/Loader"; +import axios from "axios"; +import { useNavigate } from "react-router-dom"; + +const ChangePassword = () => { + const [display1, setDisplay1] = useState(false); + const [display2, setDisplay2] = useState(false); + const [message, setMessage] = useState(""); + const [modalIsOpen, setModalIsOpen] = useState(false); + const [isError, setIsError] = useState(false); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [loading, setLoading] = useState(true); + const navigate=useNavigate(); + + useEffect(() => { + setTimeout(() => { + setLoading(false); + }, 1000); + }, []); + + const handleSubmit= async(e)=> + { + e.preventDefault(); + if(password !== confirmPassword) + { + setModalIsOpen(true); + setMessage("Passwords do not match!!!"); + setIsError(true); + return; + } + try + { + const teacherID=localStorage.getItem("teacherId"); + const response=await axios.post("http://localhost:5000/teacher/change-password",{ + newPassword: password, + teacherId: teacherID, + }); + setMessage(response.data.message); + setIsError(false); + setModalIsOpen(true); + setTimeout(() => { + setModalIsOpen(false); + navigate("/teacherDashboard"); + }, 2000); + } + catch(error) + { + setMessage( + error.response?.data?.error || "Something went wrong. Please try again." + ); + setIsError(true); + setModalIsOpen(true); + } + } + + return ( + <> +
+ {loading ? ( + + ) : ( + <> +
+ Logo +

Teacher: Change Password

+
+ +
+ { + setPassword(e.target.value); + }} + value={password} + required + /> + {display1 ? ( + { + setDisplay1(false); + }} + /> + ) : ( + { + setDisplay1(true); + }} + /> + )} +
+ +
+ { + setConfirmPassword(e.target.value); + }} + value={confirmPassword} + required + /> + {display2 ? ( + { + setDisplay2(false); + }} + /> + ) : ( + { + setDisplay2(true); + }} + /> + )} +
+ +
+ setModalIsOpen(false)} + message={message} + iserror={isError} + /> +
+ + )} +
+ + ); +}; + +export default ChangePassword; From 903852bb15422e54f4fddbcc524d5837a68a8fda Mon Sep 17 00:00:00 2001 From: SimpPoseidon <120441879+TanishqMehrunkarIIPSDAVV@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:42:36 +0530 Subject: [PATCH 2/4] ... --- .../QuestionPaperDashboard.css | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/QuestionPaperDashboard/QuestionPaperDashboard.css b/src/QuestionPaperDashboard/QuestionPaperDashboard.css index dea2a4c..4d4c6dc 100644 --- a/src/QuestionPaperDashboard/QuestionPaperDashboard.css +++ b/src/QuestionPaperDashboard/QuestionPaperDashboard.css @@ -70,18 +70,21 @@ { color: rgb(4, 231, 4); } -.question_paper_h3{ - margin: 0px; -} -.description +.description, +.question_paper_h3 { + width: 80%; /* Adjust the width as needed */ line-clamp: 2; - width: 80%; overflow: hidden; - text-overflow: ellipsis; + text-overflow: ellipsis; /* Ensures the '...' is shown */ display: -webkit-box; - -webkit-line-clamp: 2; + -webkit-line-clamp: 2; /* Limits the text to 2 lines */ -webkit-box-orient: vertical; + word-wrap: break-word; /* Prevents overflow */ +} +.question_paper_h3 +{ + margin:0; } .question-image { @@ -154,7 +157,7 @@ font-size: 18px; } @media(max-width : 1000px) { - .description + .description,.question_paper_h3 { width: 70%; } @@ -171,7 +174,7 @@ font-size: 18px; justify-content: center; text-align: center; } - .description + .description,.question_paper_h3 { width: 60%; } From 77d0846bedf298dfe7328bb3cf7ee2a625f0fa60 Mon Sep 17 00:00:00 2001 From: SimpPoseidon <120441879+TanishqMehrunkarIIPSDAVV@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:45:39 +0530 Subject: [PATCH 3/4] updated ... --- src/QuestionPaperDashboard/QuestionPaperDashboard.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QuestionPaperDashboard/QuestionPaperDashboard.css b/src/QuestionPaperDashboard/QuestionPaperDashboard.css index 4d4c6dc..c9e6e38 100644 --- a/src/QuestionPaperDashboard/QuestionPaperDashboard.css +++ b/src/QuestionPaperDashboard/QuestionPaperDashboard.css @@ -74,11 +74,11 @@ .question_paper_h3 { width: 80%; /* Adjust the width as needed */ - line-clamp: 2; + line-clamp: 1; overflow: hidden; text-overflow: ellipsis; /* Ensures the '...' is shown */ display: -webkit-box; - -webkit-line-clamp: 2; /* Limits the text to 2 lines */ + -webkit-line-clamp: 1; /* Limits the text to 2 lines */ -webkit-box-orient: vertical; word-wrap: break-word; /* Prevents overflow */ } From b006d2be08f965e40d0575887ae957ed8aed3d73 Mon Sep 17 00:00:00 2001 From: SimpPoseidon <120441879+TanishqMehrunkarIIPSDAVV@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:53:39 +0530 Subject: [PATCH 4/4] updated --- src/App.js | 2 - src/ChangePassword/ChangePassword.css | 95 ----------------- src/ChangePassword/ChangePassword.jsx | 143 -------------------------- 3 files changed, 240 deletions(-) delete mode 100644 src/ChangePassword/ChangePassword.css delete mode 100644 src/ChangePassword/ChangePassword.jsx diff --git a/src/App.js b/src/App.js index 671765b..09effb6 100644 --- a/src/App.js +++ b/src/App.js @@ -17,7 +17,6 @@ import EditReadyQuestion from './edit_ready_question/EditReadyQuestion'; import Error404 from './error/error404'; import EditQuestion from './edit_question/EditQuestion'; import Profile from './Profile/profile'; -import ChangePassword from './ChangePassword/ChangePassword'; @@ -79,7 +78,6 @@ const App = () => { }/> } /> }/> - }/> )} diff --git a/src/ChangePassword/ChangePassword.css b/src/ChangePassword/ChangePassword.css deleted file mode 100644 index b82be62..0000000 --- a/src/ChangePassword/ChangePassword.css +++ /dev/null @@ -1,95 +0,0 @@ -.change-container-main{ - background-color: #1a1a1a; - display: flex; - align-items: center; - justify-content: center; - min-height: 100vh; -} -.change-container -{ - width: 100%; - max-width: 400px; - padding: 20px; - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - border: 1px solid #ccc; - box-shadow: 0px 0px 10px white; - border-radius: 8px; - background-color: #282828; - position: absolute; - top:50%; - left:50%; - transform: translate(-50%,-50%); -} -.change-container img -{ - width: 100px; - height: 100px; - margin-bottom: 20px; -} -.change-container h2 -{ - display: grid; - justify-content: center; - align-items: center; - margin-bottom: 20px; - text-align: center; - color: #fffcfc; -} -.change-container form -{ - width: 75%; - display: flex; - flex-direction: column; -} -.change-container label -{ - - color: #fffcfc; -} - -.change-container input -{ - padding: 10px; - margin-bottom: 20px; - border: 1px solid #ccc; - border-radius: 4px; - margin-top: 10px; - font-size: 16px; - width: 93%; - background-color: #4d4d4d; - color: white; -} -.change-container button -{ - padding: 10px; - border: none; - border-radius: 4px; - background-color: #4CAF50; - color: white; - font-size: 16px; - cursor: pointer; -} -.input-password -{ - position: relative; -} -.eye-icon,.eye-icon-slash -{ color: #ccc; - position: absolute; - right: 10px; - top: 22px; -} -.eye-icon:hover,.eye-icon-slash:hover -{ - cursor: pointer; -} -@media (max-width:720px) -{ - .change-container - { - width: 270px; - } -} \ No newline at end of file diff --git a/src/ChangePassword/ChangePassword.jsx b/src/ChangePassword/ChangePassword.jsx deleted file mode 100644 index f106f3a..0000000 --- a/src/ChangePassword/ChangePassword.jsx +++ /dev/null @@ -1,143 +0,0 @@ -import React, { useEffect, useState } from "react"; -import "./ChangePassword.css"; -import Logo from "../Assets/iips_logo2.png"; -import { FaEye, FaEyeSlash } from "react-icons/fa"; -import AlertModal from "../AlertModal/AlertModal"; -import Loader from "../Loader/Loader"; -import axios from "axios"; -import { useNavigate } from "react-router-dom"; - -const ChangePassword = () => { - const [display1, setDisplay1] = useState(false); - const [display2, setDisplay2] = useState(false); - const [message, setMessage] = useState(""); - const [modalIsOpen, setModalIsOpen] = useState(false); - const [isError, setIsError] = useState(false); - const [password, setPassword] = useState(""); - const [confirmPassword, setConfirmPassword] = useState(""); - const [loading, setLoading] = useState(true); - const navigate=useNavigate(); - - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 1000); - }, []); - - const handleSubmit= async(e)=> - { - e.preventDefault(); - if(password !== confirmPassword) - { - setModalIsOpen(true); - setMessage("Passwords do not match!!!"); - setIsError(true); - return; - } - try - { - const teacherID=localStorage.getItem("teacherId"); - const response=await axios.post("http://localhost:5000/teacher/change-password",{ - newPassword: password, - teacherId: teacherID, - }); - setMessage(response.data.message); - setIsError(false); - setModalIsOpen(true); - setTimeout(() => { - setModalIsOpen(false); - navigate("/teacherDashboard"); - }, 2000); - } - catch(error) - { - setMessage( - error.response?.data?.error || "Something went wrong. Please try again." - ); - setIsError(true); - setModalIsOpen(true); - } - } - - return ( - <> -
- {loading ? ( - - ) : ( - <> -
- Logo -

Teacher: Change Password

-
- -
- { - setPassword(e.target.value); - }} - value={password} - required - /> - {display1 ? ( - { - setDisplay1(false); - }} - /> - ) : ( - { - setDisplay1(true); - }} - /> - )} -
- -
- { - setConfirmPassword(e.target.value); - }} - value={confirmPassword} - required - /> - {display2 ? ( - { - setDisplay2(false); - }} - /> - ) : ( - { - setDisplay2(true); - }} - /> - )} -
- -
- setModalIsOpen(false)} - message={message} - iserror={isError} - /> -
- - )} -
- - ); -}; - -export default ChangePassword;