p5.js-web-editor/client/modules/User/pages/LoginView.js
2016-08-31 15:12:18 -04:00

45 lines
1 KiB
JavaScript

import React from 'react';
import { bindActionCreators } from 'redux';
import { reduxForm } from 'redux-form';
import * as UserActions from '../actions';
import LoginForm from '../components/LoginForm';
import GithubButton from '../components/GithubButton';
function LoginView(props) {
return (
<div className="login">
<h1>Login</h1>
<LoginForm {...props} />
<h2 className="login__divider">Or</h2>
<GithubButton buttonText="Login with Github" />
</div>
);
}
function mapStateToProps(state) {
return {
user: state.user
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(UserActions, dispatch);
}
function validate(formProps) {
const errors = {};
if (!formProps.email) {
errors.email = 'Please enter a email';
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
return errors;
}
export default reduxForm({
form: 'login',
fields: ['email', 'password'],
validate
}, mapStateToProps, mapDispatchToProps)(LoginView);