You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ForgotPasswordPageMUI.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import React from "react";
  2. import { useFormik } from "formik";
  3. import { useTranslation } from "react-i18next";
  4. import * as Yup from "yup";
  5. import i18next from "i18next";
  6. import { ReactComponent as Logo } from "../../assets/images/svg/logo-vertical.svg";
  7. import {
  8. ForgotPasswordPageContainer,
  9. ForgotPasswordDescription,
  10. ForgotPasswordTitle,
  11. FormContainer,
  12. } from "./ForgotPassword.styled";
  13. import { TextField } from "../../components/TextFields/TextField/TextField";
  14. import { PrimaryButton } from "../../components/Buttons/PrimaryButton/PrimaryButton";
  15. import { useHistory } from "react-router-dom";
  16. import { FORGOT_PASSWORD_MAIL_SENT } from "../../constants/pages";
  17. import selectedTheme from "../../themes";
  18. const forgotPasswordValidationSchema = Yup.object().shape({
  19. email: Yup.string()
  20. .required(i18next.t("forgotPassword.emailRequired"))
  21. .email(i18next.t("forgotPassword.emailFormat")),
  22. });
  23. const ForgotPasswordPage = () => {
  24. const history = useHistory();
  25. const { t } = useTranslation();
  26. const handleSubmit = (values) => {
  27. console.log("Values", values);
  28. history.push(FORGOT_PASSWORD_MAIL_SENT);
  29. };
  30. const formik = useFormik({
  31. initialValues: {
  32. email: "",
  33. },
  34. validationSchema: forgotPasswordValidationSchema,
  35. onSubmit: handleSubmit,
  36. validateOnBlur: true,
  37. enableReinitialize: true,
  38. });
  39. return (
  40. <ForgotPasswordPageContainer>
  41. <Logo />
  42. <ForgotPasswordTitle component="h1" variant="h5">
  43. {t("forgotPassword.title")}
  44. </ForgotPasswordTitle>
  45. <ForgotPasswordDescription component="h1" variant="h6">
  46. {t("forgotPassword.description")}
  47. </ForgotPasswordDescription>
  48. <FormContainer component="form" onSubmit={formik.handleSubmit}>
  49. {/* <Backdrop position="absolute" isLoading={isLoading} /> */}
  50. <TextField
  51. name="email"
  52. placeholder={t("common.labelEmail")}
  53. margin="normal"
  54. value={formik.values.email}
  55. error={formik.touched.email && Boolean(formik.errors.email)}
  56. helperText={formik.touched.email && formik.errors.email}
  57. onChange={formik.handleChange}
  58. autoFocus
  59. fullWidth
  60. />
  61. <PrimaryButton
  62. type="submit"
  63. variant="contained"
  64. height="48px"
  65. fullWidth={true}
  66. buttoncolor={selectedTheme.primaryPurple}
  67. textcolor="white"
  68. disabled={formik.values.email?.length === 0}
  69. >
  70. {t("common.send")}
  71. </PrimaryButton>
  72. </FormContainer>
  73. </ForgotPasswordPageContainer>
  74. );
  75. };
  76. export default ForgotPasswordPage;