-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1580bf3
commit e8b1081
Showing
21 changed files
with
878 additions
and
184 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,62 @@ | ||
import React from "react"; | ||
import React, { useState } from "react"; | ||
import Logo from "../Assets/iips_logo2.png"; | ||
import "./Forgot_Password.css"; | ||
import { useNavigate } from "react-router-dom"; | ||
const ForgotPassword=()=> | ||
{ | ||
const navigate=useNavigate(); | ||
return( | ||
<> | ||
import axios from "axios"; | ||
import AlertModal from "../AlertModal/AlertModal"; | ||
|
||
|
||
const ForgotPassword = () => { | ||
const [email, setEmail] = useState(""); | ||
const [message, setMessage] = useState(""); | ||
const [modalIsOpen, setModalIsOpen] = useState(false); // Modal state | ||
const [isError, setIsError] = useState(false); // Error state for modal | ||
const navigate = useNavigate(); | ||
|
||
const handleSubmit = async (e) => { | ||
e.preventDefault(); | ||
try { | ||
const response = await axios.post("http://localhost:5000/teacher/forgot-password", { email }); | ||
setMessage(response.data.message); | ||
setIsError(false); | ||
setModalIsOpen(true); | ||
setTimeout(() => { | ||
setModalIsOpen(false); | ||
navigate("/Login"); | ||
}, 3000); // Optional: Navigate to login after 3 seconds | ||
} catch (error) { | ||
setMessage(error.response?.data?.error || "Something went wrong. Please try again."); | ||
setIsError(true); | ||
setModalIsOpen(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="forgot-container"> | ||
<img alt="Logo" src={Logo}/> | ||
<h2> Forgot Your Password ?</h2> | ||
<form onSubmit={()=> navigate("/Login")}> | ||
<img alt="Logo" src={Logo} /> | ||
<h2>Forgot Your Password?</h2> | ||
<form onSubmit={handleSubmit}> | ||
<label>Email:</label> | ||
<input type="email" name="forgot_email" placeholder="Enter your Email"/> | ||
<input | ||
type="email" | ||
name="forgot_email" | ||
placeholder="Enter your Email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
required | ||
/> | ||
<button type="submit">Submit</button> | ||
</form> | ||
|
||
{/* Use the AlertModal component */} | ||
<AlertModal | ||
isOpen={modalIsOpen} | ||
onClose={() => setModalIsOpen(false)} | ||
message={message} | ||
iserror={isError} | ||
/> | ||
</div> | ||
</> | ||
); | ||
} | ||
}; | ||
|
||
export default ForgotPassword; | ||
export default ForgotPassword; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.