diff --git a/frontend/src/pages/Auth/ForgotPAssword.jsx b/frontend/src/pages/Auth/ForgotPAssword.jsx new file mode 100644 index 0000000..45741e4 --- /dev/null +++ b/frontend/src/pages/Auth/ForgotPAssword.jsx @@ -0,0 +1,155 @@ +import React, { useState } from "react"; +import Input from "../../components/Inputs/Input"; +import Button from "../../components/Button/Button"; +import { validateEmail } from "../../utils/helper"; +import { API_PATHS } from "../../utils/apiPaths"; +import axiosInstance from "../../utils/axiosinstance"; +import { LuArrowRight, LuArrowLeft } from "react-icons/lu"; + +const ForgotPassword = ({ setCurrentPage }) => { + const [email, setEmail] = useState(""); + const [error, setError] = useState(null); + const [success, setSuccess] = useState(false); + const [loading, setLoading] = useState(false); + + const handleSubmit = async (e) => { + e.preventDefault(); + + if (!validateEmail(email)) { + setError("Please enter a valid email address."); + return; + } + + setError(null); + setLoading(true); + + try { + await axiosInstance.post(API_PATHS.AUTH.FORGOT_PASSWORD, { email }); + + setSuccess(true); + setError(null); + } catch (err) { + if (err.response?.data?.message) { + setError(err.response.data.message); + } else { + setError("Failed to send reset link. Please try again."); + } + } finally { + setLoading(false); + } + }; + + return ( +
+ PrepPilot
+ + Enter your email and we'll send you a link to reset your password +
+
+ We've sent a password reset link to
+ {email}
+
- PrepPilot
- Sign in to continue your interview preparation journey
+ {/* Header */} +
+ PrepPilot
+ Sign in to continue your interview preparation journey +
+