import React from 'react';
import { connect } from "react-redux";
import { Link } from "react-router-dom";

import { postLoginSubmit } from "../../actions/login";

import LoginForm from '../../components/login-form/LoginForm';

export class Login extends React.Component {
    render() {
        const { postLoginSubmit } = this.props;
        const history = this.props.history;
        //console.log(this.props);
        return (
            <div>
                <LoginForm postLoginSubmit={postLoginSubmit} history={ history }/>
                <p>Don't have an account? <Link to="/registration">Sign up now</Link></p>
            </div>
        )
    }
}

const mapStateToProps = state => {
    return {
        user: state.login.user
    };
};

export default connect(
    mapStateToProps,
    { postLoginSubmit }
)(Login);