| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /* eslint-disable */
- import React, { useEffect, useState, useContext } from "react";
- import PropTypes from "prop-types";
- import { useFormik } from "formik";
- import { useDispatch, useSelector } from "react-redux";
- import { NavLink, useLocation } from "react-router-dom";
- import * as Yup from "yup";
- import { useTranslation } from "react-i18next";
- import HrLogo from "../../assets/images/hrcenter.png";
- import jwt_decode from "jwt-decode";
- import {
- clearLoginErrors,
- fetchUser,
- fetchGoogleUser,
- } from "../../store/actions/login/loginActions";
- import { selectLoginError } from "../../store/selectors/loginSelectors";
- import {
- ADS_PAGE,
- FORGOT_PASSWORD_PAGE,
- HOME_PAGE,
- } from "../../constants/pages";
- import {
- Box,
- Button,
- Container,
- Grid,
- IconButton,
- InputAdornment,
- Link,
- TextField,
- Typography,
- } from "@mui/material";
- import { Visibility, VisibilityOff } from "@mui/icons-material";
- import Backdrop from "../../components/MUI/BackdropComponent";
- import ErrorMessage from "../../components/MUI/ErrorMessageComponent";
- import { selectIsLoadingByActionType } from "../../store/selectors/loadingSelectors";
- import {
- LOGIN_USER_LOADING,
- LOGIN_GOOGLE_USER_LOADING,
- } from "../../store/actions/login/loginActionConstants";
- import { authScopeStringGetHelper } from "../../util/helpers/authScopeHelpers";
- import { JWT_TOKEN } from "../../constants/localStorage";
- import Step from "../../components/Registration/Step";
- import { FormContext, FormProvider } from "../../context/FormContext";
- import { selectIsUserAuthenticated } from "../../store/selectors/userSelectors";
-
- const RegisterPage = ({ history }) => {
- // const dispatch = useDispatch();
- const { t } = useTranslation();
- // const error = useSelector(selectLoginError);
- const { search } = useLocation();
-
- const { activeStepIndex } = useContext(FormContext);
-
- const [showPassword, setShowPassword] = useState(false);
- const [firstDone, setFirst] = useState(false);
- const [isInit, setIsInit] = useState(true);
- const handleClickShowPassword = () => setShowPassword(!showPassword);
- const handleMouseDownPassword = () => setShowPassword(!showPassword);
-
- const handleCallbackResponse = (response) => {
- const userObject = jwt_decode(response.credential);
- const user = userObject;
- const token = response.credential;
- dispatch(clearLoginErrors());
- dispatch(
- fetchGoogleUser({
- user,
- token,
- handleApiResponseSuccess,
- })
- );
- };
-
- const isLoading = useSelector(
- selectIsLoadingByActionType(LOGIN_USER_LOADING)
- );
-
- const isGoogleLoading = useSelector(
- selectIsLoadingByActionType(LOGIN_GOOGLE_USER_LOADING)
- );
-
- const isUserAuthenticated = useSelector(selectIsUserAuthenticated);
-
- useEffect(() => {
- if (isInit) {
- setIsInit(false);
- return;
- }
-
- if (!isUserAuthenticated) {
- history.push({ pathname: ADS_PAGE });
- }
- }, [isInit]);
-
- return (
- <>
- <Container
- component="main"
- maxWidth="xl"
- className="c-login-container"
- fullwidth="true"
- >
- <div className="l-t-rectangle"></div>
- <div className="r-b-rectangle"></div>
- <Box
- sx={{
- marginTop: 2,
- width: 289,
- height: 684,
- display: "flex",
- flexDirection: "column",
- alignItems: "center",
- }}
- >
- <img src={HrLogo} className="login-logo" />
- {search.split("&")[1]?.split("=")[1] ? (
- <>
- <Typography variant="h5" sx={{ m: 1, mt: 3 }}>
- {t("login.welcome")}
- </Typography>
- <Typography variant="p" sx={{ mb: 2 }}>
- Dva koraka do HR Centra.
- </Typography>
- <div className="steps-cont">
- <div
- className={`step ${
- activeStepIndex && activeStepIndex === 1
- ? "done"
- : "current"
- }`}
- >
- 1
- </div>
- <div className="line-btw"></div>
- <div
- className={`step ${
- activeStepIndex && activeStepIndex === 1
- ? "current"
- : "disallowed"
- }`}
- >
- 2
- </div>
- </div>
- <Step />
- </>
- ) : (
- <h3 style={{ margin: "50px 0px" }}>There was a mistake...</h3>
- )}
- </Box>
- </Container>
- </>
- );
- };
-
- RegisterPage.propTypes = {
- history: PropTypes.shape({
- replace: PropTypes.func,
- push: PropTypes.func,
- location: PropTypes.shape({
- pathname: PropTypes.string,
- }),
- }),
- };
- export default RegisterPage;
|