From 12992c8ae168e28985b2c31c83fef89e21cf9aa0 Mon Sep 17 00:00:00 2001 From: Daniel Cojocea Date: Mon, 12 Aug 2024 13:58:18 -0400 Subject: [PATCH] Final auth design --- Client/src/Pages/Auth/ForgotPassword.jsx | 117 +++++++++++------------ Client/src/Pages/Auth/index.css | 4 + 2 files changed, 60 insertions(+), 61 deletions(-) diff --git a/Client/src/Pages/Auth/ForgotPassword.jsx b/Client/src/Pages/Auth/ForgotPassword.jsx index fa1f216ed..ab8728f8c 100644 --- a/Client/src/Pages/Auth/ForgotPassword.jsx +++ b/Client/src/Pages/Auth/ForgotPassword.jsx @@ -1,4 +1,4 @@ -import { Stack, Typography } from "@mui/material"; +import { Box, Stack, Typography } from "@mui/material"; import { useTheme } from "@emotion/react"; import { createToast } from "../../Utils/toastUtils"; import { useDispatch, useSelector } from "react-redux"; @@ -8,10 +8,8 @@ import { credentials } from "../../Validation/validation"; import { useNavigate } from "react-router-dom"; import Field from "../../Components/Inputs/Field"; import ButtonSpinner from "../../Components/ButtonSpinner"; -import Button from "../../Components/Button"; import Logo from "../../assets/icons/bwu-icon.svg?react"; import Key from "../../assets/icons/key.svg?react"; -import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; import background from "../../assets/Images/background_pattern_decorative.png"; import "./index.css"; @@ -26,10 +24,6 @@ const ForgotPassword = () => { email: "", }); - const idMap = { - "forgot-password-email-input": "email", - }; - const handleSubmit = async (event) => { event.preventDefault(); @@ -41,11 +35,9 @@ const ForgotPassword = () => { error.details && error.details.length > 0 ? error.details[0].message : "Error validating data."; - setErrors(err); + setErrors({ email: err }); createToast({ - variant: "info", body: err, - hasIcon: false, }); } else { const action = await dispatch(forgotPassword(form)); @@ -72,24 +64,16 @@ const ForgotPassword = () => { }; const handleChange = (event) => { - const { value, id } = event.target; - const name = idMap[id]; - setForm((prev) => ({ - ...prev, - [name]: value, - })); + const { value } = event.target; + setForm({ email: value }); const { error } = credentials.validate( - { [name]: value }, + { email: value }, { abortEarly: false } ); - setErrors((prev) => { - const prevErrors = { ...prev }; - if (error) prevErrors[name] = error.details[0].message; - else delete prevErrors[name]; - return prevErrors; - }); + if (error) setErrors({ email: error.details[0].message }); + else delete errors.email; }; return ( @@ -128,45 +112,56 @@ const ForgotPassword = () => { }, }, }} - > - {/*
- - - - Forgot password? - - - No worries, we'll send you reset instructions. - + > + + + + Forgot password? + + No worries, we'll send you reset instructions. + + + + + + + + - - - -