@@ -5,7 +5,7 @@ import { useDispatch, useSelector } from "react-redux";
55import { forgotPassword } from "../../Features/Auth/authSlice.js" ;
66import { useEffect , useState } from "react" ;
77import { newOrChangedCredentials } from "../../Validation/validation.js" ;
8- import { useNavigate } from "react-router-dom" ;
8+ import { useNavigate , useLocation } from "react-router-dom" ;
99import TextInput from "@/Components/v1/Inputs/TextInput/index.jsx" ;
1010import Logo from "@/assets/icons/checkmate-icon.svg?react" ;
1111import Background from "@/assets/Images/background-grid.svg?react" ;
@@ -18,6 +18,7 @@ const ForgotPassword = () => {
1818 const navigate = useNavigate ( ) ;
1919 const dispatch = useDispatch ( ) ;
2020 const theme = useTheme ( ) ;
21+ const location = useLocation ( ) ;
2122
2223 const { isLoading } = useSelector ( ( state ) => state . auth ) ;
2324 const [ errors , setErrors ] = useState ( { } ) ;
@@ -51,7 +52,9 @@ const ForgotPassword = () => {
5152 const action = await dispatch ( forgotPassword ( form ) ) ;
5253 if ( action . payload . success ) {
5354 sessionStorage . setItem ( "email" , form . email ) ;
54- navigate ( "/check-email" ) ;
55+ navigate ( "/check-email" , {
56+ state : location . state || { from : "/login" } , // Preserve original from, fallback to login
57+ } ) ;
5558 createToast ( {
5659 body : t ( "auth.forgotPassword.toasts.sent" ) . replace ( "<email/>" , form . email ) ,
5760 } ) ;
@@ -86,7 +89,9 @@ const ForgotPassword = () => {
8689
8790 const handleNavigate = ( ) => {
8891 sessionStorage . removeItem ( "email" ) ;
89- navigate ( "/login" ) ;
92+ location . state ?. from
93+ ? navigate ( location . state . from , { replace : true } )
94+ : navigate ( "/login" ) ;
9095 } ;
9196
9297 return (
@@ -212,7 +217,11 @@ const ForgotPassword = () => {
212217 >
213218 < Typography display = "inline-block" >
214219 < Trans
215- i18nKey = "auth.forgotPassword.links.login"
220+ i18nKey = {
221+ location . state ?. from
222+ ? "Go back to <a>Account Password</a>"
223+ : "auth.forgotPassword.links.login"
224+ }
216225 components = { {
217226 a : (
218227 < Typography
0 commit comments