p5.js-web-editor/client/modules/User/pages/LoginView.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-24 00:29:55 +02:00
import React from 'react';
import { bindActionCreators } from 'redux';
import { reduxForm } from 'redux-form';
import * as UserActions from '../actions';
import LoginForm from '../components/LoginForm';
import InlineSVG from 'react-inlinesvg';
const githubUrl = require('../../../images/github.svg');
2016-06-24 00:29:55 +02:00
2016-06-25 00:18:22 +02:00
function LoginView(props) {
return (
<div className="login">
<h1>Login</h1>
<LoginForm {...props} />
<h2 className="login__divider">Or</h2>
<a
className="login__github-button"
href="/auth/github"
>
<InlineSVG src={githubUrl} className="login__github-icon" />
<span>Login with Github</span>
</a>
2016-06-25 00:18:22 +02:00
</div>
);
2016-06-24 00:29:55 +02:00
}
function mapStateToProps(state) {
return {
user: state.user
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(UserActions, dispatch);
}
function validate(formProps) {
const errors = {};
2016-06-24 20:22:32 +02:00
if (!formProps.email) {
errors.email = 'Please enter a email';
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
2016-06-24 00:29:55 +02:00
return errors;
}
export default reduxForm({
form: 'login',
fields: ['email', 'password'],
validate
}, mapStateToProps, mapDispatchToProps)(LoginView);