import "./index.css"; import background from "../../assets/Images/background_pattern_decorative.png"; import React, { useEffect, useState } from "react"; import EmailIcon from "../../assets/icons/email.svg?react"; import Button from "../../Components/Button"; 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 = [ { body: "Email not found.", }, { body: "Redirecting in 3...", }, { body: "Redirecting in 2...", }, { body: "Redirecting in 1...", }, ]; 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({ body: `Instructions sent to ${form.email}.`, }); setDisabled(false); } else { if (action.payload) { // dispatch errors createToast({ body: action.payload.msg, }); } else { // unknown errors createToast({ body: "Unknown error.", }); } } } }; return (
background pattern
Check your email We sent a password reset link to{" "} {email || "username@email.com"}
); }; export default CheckEmail;