diff --git a/src/Components/Forgot_password/ForgotPassword.js b/src/Components/Forgot_password/ForgotPassword.js index 461ac0d..b88f882 100644 --- a/src/Components/Forgot_password/ForgotPassword.js +++ b/src/Components/Forgot_password/ForgotPassword.js @@ -1,5 +1,7 @@ import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; +import { toast } from "react-toastify"; +import { sendPasswordResetEmail } from "firebase/auth"; import { NewContainer, FormContainer, @@ -14,35 +16,49 @@ import { } from "./ForgotPasswordelements"; import ForgotImg from "../../images/Forgotpassword.webp"; import Footer from "../Footer"; +import { auth } from "../../firebase-config"; // Import your Firebase authentication instance const GetMail = () => { const navigate = useNavigate(); const [email, setEmail] = useState(); - const handleContinue = () => { - if (!email) alert("enter email"); - else navigate("/signin/otpverification"); + + const handleContinue = async () => { + try { + if (!email) { + // alert("Please enter your email."); + let errorMessage = "Please enter your email"; + toast.error(errorMessage, { + position: "top-right", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + }); + return; + } + + // Send a password reset email + await sendPasswordResetEmail(auth, email); + + // After sending the email, navigate to the OTP verification page + navigate("/signin/otpverification"); + } catch (error) { + let errorMessage = "Error sending password reset email. Please try again."; + // console.error("Error sending password reset email", error); + // alert("Error sending password reset email. Please try again."); + toast.error(errorMessage, { + position: "top-right", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + }); + } }; + return ( - // <> - // - // - //
- // Email - // setEmail(e.target.value)} - // placeholder="email@example.com" - // type="email" - // id="email" - // require - // /> - // Continue - //
- // navigate("/signin")}>Cancel - // - //
- //
- //