import React from 'react';
import { reduxForm } from 'redux-form';
import { validateAndLoginUser } from '../../User/actions';
import LoginForm from '../components/LoginForm';
// import GithubButton from '../components/GithubButton';
import { Link } from 'react-router';
class LoginView extends React.Component {
componentDidMount() {
this.refs.login.focus();
}
render() {
return (
Login
{/*
Or
*/}
Don't have an account?
Sign Up
Forgot your password?
Reset your password
Cancel
);
}
}
function mapStateToProps(state, ownProps) {
return {
user: state.user,
previousPath: ownProps.previousPath
};
}
function mapDispatchToProps() {
return {
validateAndLoginUser
};
}
function validate(formProps) {
const errors = {};
if (!formProps.email) {
errors.email = 'Please enter an email';
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
return errors;
}
export default reduxForm({
form: 'login',
fields: ['email', 'password'],
validate
}, mapStateToProps, mapDispatchToProps)(LoginView);