Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

SecondStepForm.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import { useFormik } from "formik";
  2. import React, { useContext } from "react";
  3. import * as yup from "yup";
  4. import { useTranslation } from "react-i18next";
  5. import { TextField } from "@mui/material";
  6. import Button from "../Button/Button";
  7. // import googleLogo from "../../assets/images/google1.png";
  8. import DiligLogo from "../../assets/images/logo_horizontal_black.png";
  9. import { Box } from "@mui/system";
  10. import { FormContext } from "../../context/FormContext";
  11. import { useDispatch } from "react-redux";
  12. import { registerRequest } from "../../store/actions/register/registerActions";
  13. import { BASE_PAGE } from "../../constants/pages";
  14. import { useHistory } from "react-router-dom";
  15. function SecondStepForm() {
  16. const { formData } = useContext(FormContext);
  17. const dispatch = useDispatch();
  18. const { t } = useTranslation();
  19. const history = useHistory();
  20. const submitHandler = (values) => {
  21. const data = { ...formData, ...values };
  22. dispatch(
  23. registerRequest({
  24. model: data,
  25. handleApiResponseSuccess,
  26. })
  27. );
  28. };
  29. const handleApiResponseSuccess = () => {
  30. history.push({
  31. pathname: BASE_PAGE,
  32. state: {
  33. from: history.location.pathname,
  34. },
  35. });
  36. };
  37. const formik = useFormik({
  38. initialValues: {
  39. phone: "",
  40. position: "",
  41. linkedin: "",
  42. },
  43. validationSchema: yup.object().shape({
  44. phone: yup.string().required("Required"),
  45. position: yup.string().required("Required"),
  46. linkedin: yup.string().required("Required"),
  47. }),
  48. onSubmit: submitHandler,
  49. validateOnBlur: true,
  50. enableReinitialize: true,
  51. });
  52. return (
  53. <Box
  54. onSubmit={formik.handleSubmit}
  55. component="form"
  56. sx={{ position: "relative" }}
  57. >
  58. {/* <Backdrop
  59. position="absolute"
  60. isLoading={isLoading || isGoogleLoading}
  61. /> */}
  62. <>
  63. <TextField
  64. name="phone"
  65. label={t("registration.phone")}
  66. margin="normal"
  67. fullWidth
  68. onChange={formik.handleChange}
  69. error={formik.touched.phone && Boolean(formik.errors.phone)}
  70. helperText={formik.touched.phone && formik.errors.phone}
  71. />
  72. <TextField
  73. name="position"
  74. label={t("registration.position")}
  75. margin="normal"
  76. fullWidth
  77. onChange={formik.handleChange}
  78. error={formik.touched.position && Boolean(formik.errors.position)}
  79. helperText={formik.touched.position && formik.errors.position}
  80. />
  81. <TextField
  82. name="linkedin"
  83. label={t("registration.linkedinProfile")}
  84. margin="normal"
  85. fullWidth
  86. onChange={formik.handleChange}
  87. error={formik.touched.linkedin && Boolean(formik.errors.linkedin)}
  88. helperText={formik.touched.linkedin && formik.errors.linkedin}
  89. />
  90. </>
  91. <Button
  92. variant="contained"
  93. sx={{ mt: 3, mb: 2 }}
  94. fullWidth
  95. className="c-btn c-btn--primary w-289 f"
  96. type="submit"
  97. >
  98. Registruj se
  99. </Button>
  100. {/* <div className="flex-center">
  101. <div className="hr hr-s"></div>
  102. <div className="hr-mid">{t("common.or")}</div>
  103. <div className="hr hr-e"></div>
  104. </div>
  105. <div>
  106. <Button
  107. className="c-btn c-btn--gray flex-center w-289"
  108. sx={{ width: "100%", mt: 2 }}
  109. // onClick={handleGoogleSubmit}
  110. >
  111. <img src={googleLogo} style={{ marginRight: "15px" }} />
  112. <Typography sx={{ m: 0, p: 0 }} variant="buttonText">
  113. {t("login.signInWithGoogle")}
  114. </Typography>
  115. </Button>
  116. <div id="signInDiv"></div>
  117. </div> */}
  118. <div className="flex-center">
  119. <img src={DiligLogo} style={{ margin: "50px auto 30px auto" }} />
  120. </div>
  121. </Box>
  122. );
  123. }
  124. export default SecondStepForm;