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.

RegisterPage.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* eslint-disable */
  2. import React, { useEffect, useState, useContext } from "react";
  3. import PropTypes from "prop-types";
  4. import { useFormik } from "formik";
  5. import { useDispatch, useSelector } from "react-redux";
  6. import { NavLink } from "react-router-dom";
  7. import * as Yup from "yup";
  8. import { useTranslation } from "react-i18next";
  9. import HrLogo from "../../assets/images/hrcenter.png";
  10. import jwt_decode from "jwt-decode";
  11. import {
  12. clearLoginErrors,
  13. fetchUser,
  14. fetchGoogleUser,
  15. } from "../../store/actions/login/loginActions";
  16. import { selectLoginError } from "../../store/selectors/loginSelectors";
  17. import { FORGOT_PASSWORD_PAGE, HOME_PAGE } from "../../constants/pages";
  18. import {
  19. Box,
  20. Button,
  21. Container,
  22. Grid,
  23. IconButton,
  24. InputAdornment,
  25. Link,
  26. TextField,
  27. Typography,
  28. } from "@mui/material";
  29. import { Visibility, VisibilityOff } from "@mui/icons-material";
  30. import Backdrop from "../../components/MUI/BackdropComponent";
  31. import ErrorMessage from "../../components/MUI/ErrorMessageComponent";
  32. import { selectIsLoadingByActionType } from "../../store/selectors/loadingSelectors";
  33. import {
  34. LOGIN_USER_LOADING,
  35. LOGIN_GOOGLE_USER_LOADING,
  36. } from "../../store/actions/login/loginActionConstants";
  37. import { authScopeStringGetHelper } from "../../util/helpers/authScopeHelpers";
  38. import { JWT_TOKEN } from "../../constants/localStorage";
  39. import Step from "../../components/Registration/Step";
  40. import { FormContext, FormProvider } from "../../context/FormContext";
  41. const RegisterPage = ({ history }) => {
  42. // const dispatch = useDispatch();
  43. const { t } = useTranslation();
  44. // const error = useSelector(selectLoginError);
  45. const { activeStepIndex } = useContext(FormContext);
  46. const [showPassword, setShowPassword] = useState(false);
  47. const [firstDone, setFirst] = useState(false);
  48. const [isInit, setIsInit] = useState(true);
  49. const handleClickShowPassword = () => setShowPassword(!showPassword);
  50. const handleMouseDownPassword = () => setShowPassword(!showPassword);
  51. const handleCallbackResponse = (response) => {
  52. const userObject = jwt_decode(response.credential);
  53. const user = userObject;
  54. const token = response.credential;
  55. dispatch(clearLoginErrors());
  56. dispatch(
  57. fetchGoogleUser({
  58. user,
  59. token,
  60. handleApiResponseSuccess,
  61. })
  62. );
  63. };
  64. const isLoading = useSelector(
  65. selectIsLoadingByActionType(LOGIN_USER_LOADING)
  66. );
  67. const isGoogleLoading = useSelector(
  68. selectIsLoadingByActionType(LOGIN_GOOGLE_USER_LOADING)
  69. );
  70. useEffect(() => {
  71. if (isInit) {
  72. setIsInit(false);
  73. return;
  74. }
  75. }, [isInit]);
  76. return (
  77. <>
  78. <Container
  79. component="main"
  80. maxWidth="xl"
  81. className="c-login-container"
  82. fullwidth="true"
  83. >
  84. <div className="l-t-rectangle"></div>
  85. <div className="r-b-rectangle"></div>
  86. <Box
  87. sx={{
  88. marginTop: 2,
  89. width: 289,
  90. height: 684,
  91. display: "flex",
  92. flexDirection: "column",
  93. alignItems: "center",
  94. }}
  95. >
  96. <img src={HrLogo} className="login-logo" />
  97. <Typography variant="h5" sx={{ m: 1, mt: 3 }}>
  98. {t("login.welcome")}
  99. </Typography>
  100. <Typography variant="p" sx={{ mb: 2 }}>
  101. Dva koraka do HR Centra.
  102. </Typography>
  103. <div className="steps-cont">
  104. <div
  105. className={`step ${activeStepIndex && activeStepIndex === 1 ? "done" : "current"}`}
  106. >
  107. 1
  108. </div>
  109. <div className="line-btw"></div>
  110. <div
  111. className={`step ${
  112. activeStepIndex && activeStepIndex === 1 ? "current" : "disallowed"
  113. }`}
  114. >
  115. 2
  116. </div>
  117. </div>
  118. {/* {error && <ErrorMessage error={error} />} */}
  119. {/* THIS SHOULD BE COPIED */}
  120. <Step />
  121. </Box>
  122. </Container>
  123. </>
  124. );
  125. };
  126. RegisterPage.propTypes = {
  127. history: PropTypes.shape({
  128. replace: PropTypes.func,
  129. push: PropTypes.func,
  130. location: PropTypes.shape({
  131. pathname: PropTypes.string,
  132. }),
  133. }),
  134. };
  135. export default RegisterPage;