diff --git a/client/src/Pages/Auth/ForgotPassword.jsx b/client/src/Pages/Auth/ForgotPassword.jsx deleted file mode 100644 index 1dee3b125..000000000 --- a/client/src/Pages/Auth/ForgotPassword.jsx +++ /dev/null @@ -1,243 +0,0 @@ -import { Box, Stack, Typography, Button } from "@mui/material"; -import { useTheme } from "@emotion/react"; -import { createToast } from "../../Utils/toastUtils.jsx"; -import { useDispatch, useSelector } from "react-redux"; -import { forgotPassword } from "../../Features/Auth/authSlice.js"; -import { useEffect, useState } from "react"; -import { newOrChangedCredentials } from "../../Validation/validation.js"; -import { useNavigate, useLocation } from "react-router-dom"; -import TextInput from "@/Components/v1/Inputs/TextInput/index.jsx"; -import Logo from "@/assets/icons/checkmate-icon.svg?react"; -import Background from "@/assets/Images/background-grid.svg?react"; -import IconBox from "@/Components/v1/IconBox/index.jsx"; -import Icon from "@/Components/v1/Icon"; -import { Trans, useTranslation } from "react-i18next"; -import "./index.css"; - -const ForgotPassword = () => { - const navigate = useNavigate(); - const dispatch = useDispatch(); - const theme = useTheme(); - const location = useLocation(); - - const { isLoading } = useSelector((state) => state.auth); - const [errors, setErrors] = useState({}); - const [form, setForm] = useState({ - email: "", - }); - - useEffect(() => { - const email = sessionStorage.getItem("email"); - email && setForm({ email: sessionStorage.getItem("email") }); - }, []); - - const { t } = useTranslation(); - - const handleSubmit = async (event) => { - event.preventDefault(); - - const { error } = newOrChangedCredentials.validate(form, { abortEarly: false }); - - if (error) { - // validation errors - const err = - error.details && error.details.length > 0 - ? error.details[0].message // FIXME: Possibly untranslated string - : t("auth.common.errors.validation"); - setErrors({ email: err }); - createToast({ - body: err, - }); - } else { - const action = await dispatch(forgotPassword(form)); - if (action.payload.success) { - sessionStorage.setItem("email", form.email); - navigate("/check-email", { - state: location.state || { from: "/login" }, // Preserve original from, fallback to login - }); - createToast({ - body: t("auth.forgotPassword.toasts.sent").replace("", form.email), - }); - } else { - if (action.payload) { - // dispatch errors - createToast({ - body: action.payload.msg, // FIXME: Potentially untranslated string - }); - } else { - // unknown errors - createToast({ - body: t("common.toasts.unknownError"), - }); - } - } - } - }; - - const handleChange = (event) => { - const { value } = event.target; - setForm({ email: value }); - - const { error } = newOrChangedCredentials.validate( - { email: value }, - { abortEarly: false } - ); - - if (error) setErrors({ email: error.details[0].message }); - else delete errors.email; - }; - - const handleNavigate = () => { - sessionStorage.removeItem("email"); - location.state?.from - ? navigate(location.state.from, { replace: true }) - : navigate("/login"); - }; - - return ( - - - - - - - {t("common.appName")} - - .MuiStack-root": { - border: 1, - borderRadius: theme.spacing(5), - borderColor: theme.palette.primary.lowContrast, - backgroundColor: theme.palette.primary.main, - padding: { - xs: theme.spacing(12), - sm: theme.spacing(20), - }, - }, - }} - > - - - - - - - - {t("auth.forgotPassword.heading")} - {t("auth.forgotPassword.subheadings.stepOne")} - - - - - - - - - - Account Password" - : "auth.forgotPassword.links.login" - } - components={{ - a: ( - - ), - }} - /> - - - - ); -}; - -export default ForgotPassword; diff --git a/client/src/Routes/index.jsx b/client/src/Routes/index.jsx index 6882fafbf..acc9ad0c1 100644 --- a/client/src/Routes/index.jsx +++ b/client/src/Routes/index.jsx @@ -10,7 +10,6 @@ import NotFound from "../Pages/NotFound/index.jsx"; // Auth import AuthLogin from "../Pages/Auth/Login"; import AuthRegister from "../Pages/Auth/Register/index.jsx"; -// import AuthForgotPassword from "../Pages/Auth/ForgotPassword.jsx"; import AuthForgotPassword from "@/Pages/Auth/Recovery"; import AuthCheckEmail from "../Pages/Auth/CheckEmail.jsx"; import AuthSetNewPassword from "../Pages/Auth/SetNewPassword.jsx";