import React from "react";
import {connect} from "react-redux";
import AuthForm from "../../components/forms/authForm/authForm";
import style from "./auth.module.sass";
import Header from "../../components/header/header";
import {errorsAuth} from "../../constants/errors/auth";

const Auth = (props) => {


    return(
      <div className={style.mainContainer}>
          <div className={style.container}>
              <Header/>
          </div>
          <div className={style.authForm}>
                <AuthForm/>
              <a href={"/signUp"}>Регистрация</a>
              {
                  props.error && errorsAuth[props.error.status]
              }
          </div>

      </div>
    );
};

const mapStateToProps = state => {
    const {token, isFetching, error} = state.signUpReducers;

    return {
        token, isFetching, error
    }
};


export default connect(mapStateToProps)(Auth);