Restructured check email page

This commit is contained in:
Daniel Cojocea committed 2024-07-16 14:29:59 -04:00
1 parent 9f78173625
commit 3c8e722706
7 files changed
+184 -122

No files matched your search

+26 -75
View File
@@ -1,83 +1,34 @@
.check-email-page {
width: var(--env-var-width-1);
display: flex;
justify-content: center;
min-height: var(--env-var-height-1);
height: var(--env-var-height-1);
}
.check-email-page button:not(.MuiIconButton-root) {
height: 34px;
border-radius: var(--env-var-radius-2);
line-height: 0;
}
.check-email-page h1.MuiTypography-root {
font-size: var(--env-var-font-size-large);
color: var(--env-var-color-1);
font-weight: 600;
}
.check-email-page p.MuiTypography-root,
.check-email-page button,
.check-email-page span.MuiTypography-root {
font-size: var(--env-var-font-size-medium);
}
.check-email-page span.MuiTypography-root {
font-weight: 600;
}
.check-email-page p.MuiTypography-root {
color: var(--env-var-color-2);
}
.check-email-page button svg {
margin-right: 5px;
}
.check-email-form {
width: var(--env-var-width-2);
margin: 90px auto;
}
.check-email-form-header {
justify-content: center;
align-items: center;
text-align: center;
}
.check-email-v-gap-large {
height: var(--env-var-spacing-3);
}
.check-email-v-gap-medium {
height: var(--env-var-spacing-2);
}
.check-email-v-gap-small {
height: var(--env-var-spacing-1);
}
.check-email-form-heading {
font-size: var(--env-var-font-size-large);
font-weight: 700;
color: var(--env-var-color-1);
}
.check-email-form-subheading {
font-size: var(--env-var-font-size-medium);
font-weight: 400;
color: var(--env-var-color-2);
}
.check-email-form-subheading span {
font-weight: 700;
}
.check-email-body {
margin-top: 65px;
width: var(--env-var-width-2);
}
.check-email-resend {
font-size: var(--env-var-font-size-medium);
font-weight: 400;
color: var(--env-var-color-2);
text-align: center;
cursor: pointer;
}
.check-email-resend span {
font-weight: 700;
color: var(--env-var-color-3);
}
.check-email-back-button {
display: flex;
justify-content: center;
align-items: center;
}
.check-email-back-button-img {
width: var(--env-var-img-width-1);
height: var(--env-var-img-width-1);
margin-right: 5px;
align-items: center;
}
.check-email-back-button-text {
height: var(--env-var-img-width-1);
font-size: var(--env-var-font-size-medium);
font-weight: 500;
color: var(--env-var-color-2);
align-items: center;
}
+130 -43
View File
@@ -1,56 +1,143 @@
import BackgroundPattern from "../../Components/BackgroundPattern/BackgroundPattern";
import "./index.css";
import React from "react";
import EmailIcon from "../../assets/Images/email.png";
import React, { useEffect, useState } from "react";
import EmailIcon from "../../assets/icons/email.svg?react";
import Button from "../../Components/Button";
import LeftArrow from "../../assets/Images/arrow-left.png";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import { Stack, Typography } from "@mui/material";
import { useTheme } from "@emotion/react";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router";
import { createToast } from "../../Utils/toastUtils";
import { forgotPassword } from "../../Features/Auth/authSlice";
const CheckEmail = () => {
const theme = useTheme();
const navigate = useNavigate();
const dispatch = useDispatch();
const [email, setEmail] = useState();
const [disabled, setDisabled] = useState(false);
useEffect(() => {
setEmail(sessionStorage.getItem("email"));
}, []);
// TODO - fix
const openMail = () => {
window.location.href = "mailto:";
};
const toastFail = [
{
variant: "info",
body: "Email not found.",
hasIcon: false,
},
{
variant: "info",
body: "Redirecting in 3...",
hasIcon: false,
},
{
variant: "info",
body: "Redirecting in 2...",
hasIcon: false,
},
{
variant: "info",
body: "Redirecting in 1...",
hasIcon: false,
},
];
const resendToken = async () => {
setDisabled(true); // prevent resent button from being spammed
if (!email) {
let index = 0;
const interval = setInterval(() => {
if (index < toastFail.length) {
createToast(toastFail[index]);
index++;
} else {
clearInterval(interval);
navigate("/forgot-password");
}
}, 1000);
} else {
const form = { email: email };
const action = await dispatch(forgotPassword(form));
if (action.payload.success) {
createToast({
variant: "info",
body: `Instructions sent to ${form.email}.`,
hasIcon: false,
});
setDisabled(false);
} else {
if (action.payload) {
// dispatch errors
createToast({
variant: "info",
body: action.payload.msg,
hasIcon: false,
});
} else {
// unknown errors
createToast({
variant: "info",
body: "Unknown error.",
hasIcon: false,
});
}
}
}
};
return (
<div className="check-email-page">
<BackgroundPattern />
<div className="check-email-form">
<div className="check-email-form-header">
<img
className="check-email-form-header-logo"
src={EmailIcon}
alt="EmailIcon"
/>
<div className="check-email-v-gap-medium"></div>
<div className="check-email-form-heading">Check your email</div>
<div className="check-email-v-gap-small"></div>
<div className="check-email-form-subheading">
We sent a password reset link to <span>username@email.com</span>
</div>
</div>
<div className="check-email-v-gap-large"></div>
<div className="check-email-body">
<form className="check-email-form">
<Stack direction="column" alignItems="center" gap={theme.gap.small}>
<EmailIcon alt="EmailIcon" style={{ fill: "white" }} />
<Typography component="h1" sx={{ mt: theme.gap.ml }}>
Check your email
</Typography>
<Typography sx={{ width: "max-content" }}>
We sent a password reset link to{" "}
<Typography component="span">
{email || "username@email.com"}
</Typography>
</Typography>
</Stack>
<Stack gap={theme.gap.ml} sx={{ mt: `calc(${theme.gap.ml}*2)` }}>
<Button level="primary" label="Open email app" onClick={openMail} />
<Typography sx={{ alignSelf: "center", mb: theme.gap.medium }}>
Didn't receive the email?{" "}
<Typography
component="span"
onClick={resendToken}
sx={{
color: theme.palette.primary.main,
letterSpacing: "-0.1px",
userSelect: "none",
pointerEvents: disabled ? "none" : "auto",
cursor: disabled ? "default" : "pointer",
opacity: disabled ? 0.5 : 1,
}}
>
Click to resend
</Typography>
</Typography>
<Button
level="primary"
label="Open email app"
sx={{
width: "100%",
fontSize: "13px",
fontWeight: "200",
height: "44px",
}}
level="tertiary"
label="Back to log in"
img={<ArrowBackRoundedIcon />}
sx={{ alignSelf: "center", width: "fit-content" }}
onClick={() => navigate("/login")}
/>
</div>
<div className="check-email-v-gap-large"></div>
<div className="check-email-resend">
Didn’t receive the email?
<span> Click to resend</span>
</div>
<div className="check-email-v-gap-large"></div>
<div className="check-email-back-button">
<img
className="check-email-back-button-img"
src={LeftArrow}
alt="LeftArrow"
/>
<div className="check-email-back-button-text">Back to log in</div>
</div>
</div>
</Stack>
</form>
</div>
);
};
+2 -1
View File
@@ -50,6 +50,7 @@ const ForgotPassword = () => {
} else {
const action = await dispatch(forgotPassword(form));
if (action.payload.success) {
sessionStorage.setItem("email", form.email);
navigate("/check-email");
createToast({
variant: "info",
@@ -100,7 +101,7 @@ const ForgotPassword = () => {
return (
<div className="forgot-password-page">
<BackgroundPattern></BackgroundPattern>
<form className="forgot-password-form">
<form className="forgot-password-form" onSubmit={handleSubmit}>
<Stack direction="column" alignItems="center" gap={theme.gap.small}>
<Logomark alt="Logomark" style={{ fill: "white" }} />
<Typography component="h1" sx={{ mt: theme.gap.ml }}>
+3 -1
View File
@@ -173,7 +173,9 @@ const Login = () => {
}
label="Remember me"
/>
<span>Forgot password</span>
<span onClick={() => navigate("/forgot-password")}>
Forgot password
</span>
</Stack>
</Stack>
<Stack gap={theme.gap.ml} mt={theme.gap.large}>