From 4ce4a124d640bf5809577dc9e44ee20817d4c1ec Mon Sep 17 00:00:00 2001 From: llpingll <94099281+llpingll@users.noreply.github.com> Date: Sun, 25 Jan 2026 22:57:36 +0000 Subject: [PATCH] Refactor PasswordPanel to pass navigation context via state to ForgotPassword using TextLink | Update ForgotPassword and CheckEmail to handle navigation context for Back links, ensuring users return to the correct page after password reset | Fix TextLink prop usage to avoid warnings by passing state and href correctly | Ensure error messages and navigation links use translation keys for localization --- client/src/Components/v1/TextLink/index.jsx | 4 +++- .../Account/components/PasswordPanel.jsx | 13 +++++++++++-- client/src/Pages/Auth/CheckEmail.jsx | 13 ++++++++++--- client/src/Pages/Auth/ForgotPassword.jsx | 19 ++++++++++++++----- client/src/locales/en.json | 3 +++ 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/client/src/Components/v1/TextLink/index.jsx b/client/src/Components/v1/TextLink/index.jsx index 83ae251a5..e226250a6 100644 --- a/client/src/Components/v1/TextLink/index.jsx +++ b/client/src/Components/v1/TextLink/index.jsx @@ -5,7 +5,7 @@ import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; import { Link as RouterLink } from "react-router-dom"; -const TextLink = ({ text, linkText, href, target = "_self" }) => { +const TextLink = ({ text, linkText, href, state, target = "_self" }) => { const theme = useTheme(); return ( @@ -19,6 +19,7 @@ const TextLink = ({ text, linkText, href, target = "_self" }) => { to={href} component={RouterLink} target={target} + state={state} > {linkText} @@ -30,6 +31,7 @@ TextLink.propTypes = { text: PropTypes.string, linkText: PropTypes.string, href: PropTypes.string, + state: PropTypes.object, target: PropTypes.string, }; diff --git a/client/src/Pages/Account/components/PasswordPanel.jsx b/client/src/Pages/Account/components/PasswordPanel.jsx index 1c365804f..7deb6dc8c 100644 --- a/client/src/Pages/Account/components/PasswordPanel.jsx +++ b/client/src/Pages/Account/components/PasswordPanel.jsx @@ -13,6 +13,8 @@ import { getTouchedFieldErrors } from "../../../Validation/error.js"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; import { clearAuthState } from "../../../Features/Auth/authSlice.js"; +import TextLink from "@/Components/v1/TextLink/index.jsx"; +import { useLocation } from "react-router-dom"; const defaultPasswordsState = { password: "", @@ -31,6 +33,7 @@ const PasswordPanel = () => { const dispatch = useDispatch(); const { t } = useTranslation(); const navigate = useNavigate(); + const location = useLocation(); const SPACING_GAP = theme.spacing(12); @@ -267,8 +270,15 @@ const PasswordPanel = () => { )} +