2024-09-08 12:30:09 +00:00
|
|
|
import { useState } from "react";
|
|
|
|
import axios from "axios";
|
|
|
|
import Navbar from "./Navbar";
|
2024-09-09 16:38:14 +00:00
|
|
|
import Footer from "./Footer";
|
|
|
|
import { NavLink } from "react-router-dom";
|
2024-09-08 12:30:09 +00:00
|
|
|
|
|
|
|
|
2024-09-09 15:37:41 +00:00
|
|
|
|
2024-09-08 12:30:09 +00:00
|
|
|
const ForgotPassword = () => {
|
2024-09-09 15:37:41 +00:00
|
|
|
|
2024-09-08 12:30:09 +00:00
|
|
|
const [email, setEmail] = useState("");
|
|
|
|
const [message, setMessage] = useState("");
|
|
|
|
|
|
|
|
const BASE_URL = import.meta.env.VITE_REACT_APP_SECRET;
|
|
|
|
|
|
|
|
const handleResetPassword = async () => {
|
|
|
|
try {
|
|
|
|
const response = await axios.post(`${BASE_URL}/users/forgotpassword`, {
|
|
|
|
email,
|
|
|
|
});
|
|
|
|
|
|
|
|
setMessage(response.data.message);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Forgot Password Error:", error);
|
|
|
|
setMessage(error.response.data.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
2024-09-09 15:37:41 +00:00
|
|
|
|
2024-09-08 12:30:09 +00:00
|
|
|
|
|
|
|
return (
|
2024-09-09 15:37:41 +00:00
|
|
|
<>
|
|
|
|
<Navbar />
|
|
|
|
<br />
|
|
|
|
<br /><br /><br /><br />
|
|
|
|
|
|
|
|
|
|
|
|
<section
|
|
|
|
className="card"
|
|
|
|
style={{ minHeight: "100vh", backgroundColor: "#FFFFFF" }}
|
|
|
|
>
|
|
|
|
<div className="container-fluid px-0">
|
|
|
|
<div className="row gy-4 align-items-center justify-content-center">
|
|
|
|
<div className="col-12 col-md-0 col-xl-20 text-center text-md-start">
|
|
|
|
|
|
|
|
</div>
|
2024-09-08 12:30:09 +00:00
|
|
|
|
2024-09-09 15:37:41 +00:00
|
|
|
<div className="col-12 col-md-6 col-xl-5">
|
2024-09-08 12:30:09 +00:00
|
|
|
<div
|
2024-09-09 15:37:41 +00:00
|
|
|
className="card border-0 rounded-4 shadow-lg"
|
|
|
|
style={{ width: "100%" }}
|
2024-09-08 12:30:09 +00:00
|
|
|
>
|
2024-09-09 15:37:41 +00:00
|
|
|
<div className="card-body p-3 p-md-4 p-xl-5">
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-12">
|
|
|
|
<div className="mb-4">
|
|
|
|
<h2 className="h3">Forgot Password</h2>
|
|
|
|
|
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="row gy-3 overflow-hidden">
|
|
|
|
|
|
|
|
|
|
|
|
<div className="col-12">
|
|
|
|
<div className="form-floating mb-3">
|
|
|
|
<input
|
|
|
|
type="email"
|
|
|
|
className="form-control"
|
|
|
|
value={email}
|
|
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
|
|
|
|
|
|
placeholder="name@example.com"
|
|
|
|
required="required"
|
|
|
|
/>
|
|
|
|
<label htmlFor="email" className="form-label">
|
|
|
|
Enter your email address to receive a password reset link
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="col-12">
|
|
|
|
<div className="d-grid">
|
|
|
|
<button
|
|
|
|
className="btn btn-primary btn-lg"
|
|
|
|
type="submit"
|
|
|
|
style={{
|
|
|
|
backgroundColor: "#fda417",
|
|
|
|
border: "#fda417",
|
|
|
|
}}
|
|
|
|
onClick={handleResetPassword}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Reset Password
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<p
|
2024-09-08 12:30:09 +00:00
|
|
|
style={{ color: "#067ADC" }}
|
|
|
|
className="card-title text-center"
|
|
|
|
>
|
|
|
|
{message}
|
|
|
|
</p>
|
2024-09-09 15:37:41 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-12">
|
|
|
|
<div className="d-flex gap-2 gap-md-4 flex-column flex-md-row justify-content-md-end mt-4">
|
|
|
|
<p className="m-0 text-secondary text-center">
|
|
|
|
Already have an account?{" "}
|
2024-09-09 16:38:14 +00:00
|
|
|
|
|
|
|
<NavLink to="/login" className="link-primary text-decoration-none">
|
|
|
|
Sign In
|
|
|
|
</NavLink>
|
|
|
|
|
2024-09-09 15:37:41 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-12"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-08 12:30:09 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-09-09 16:38:14 +00:00
|
|
|
<Footer />
|
2024-09-08 12:30:09 +00:00
|
|
|
</section>
|
|
|
|
|
2024-09-09 15:37:41 +00:00
|
|
|
|
|
|
|
</>
|
2024-09-08 12:30:09 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ForgotPassword;
|