p5.js-web-editor/client/modules/IDE/components/LoginView.js

63 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-06-23 22:29:55 +00:00
import React from 'react';
import { reduxForm } from 'redux-form';
import { validateAndLoginUser } from '../../User/actions';
2016-06-23 22:29:55 +00:00
import LoginForm from '../components/LoginForm';
2016-09-06 20:53:37 +00:00
// import GithubButton from '../components/GithubButton';
import { Link } from 'react-router';
2016-06-23 22:29:55 +00:00
class LoginView extends React.Component {
componentDidMount() {
this.refs.login.focus();
}
render() {
return (
<div className="login" ref="login" tabIndex="0">
<h1>Login</h1>
<LoginForm {...this.props} />
{/* <h2 className="login__divider">Or</h2>
<GithubButton buttonText="Login with Github" /> */}
2016-10-12 18:25:24 +00:00
<p className="form__navigation-options">
Don't have an account?&nbsp;
<Link className="form__signup-button" to="/signup">Sign Up</Link>
</p>
<p className="form__navigation-options">
Forgot your password?&nbsp;
<Link className="form__reset-password-button" to="/reset-password">Reset your password</Link>
</p>
<Link className="form__cancel-button" to="/">Cancel</Link>
</div>
);
}
2016-06-23 22:29:55 +00:00
}
function mapStateToProps(state) {
return {
user: state.user
};
}
function mapDispatchToProps() {
return {
validateAndLoginUser
};
2016-06-23 22:29:55 +00:00
}
function validate(formProps) {
const errors = {};
2016-06-24 18:22:32 +00:00
if (!formProps.email) {
2016-10-12 18:25:24 +00:00
errors.email = 'Please enter an email';
2016-06-24 18:22:32 +00:00
}
if (!formProps.password) {
errors.password = 'Please enter a password';
}
2016-06-23 22:29:55 +00:00
return errors;
}
export default reduxForm({
form: 'login',
fields: ['email', 'password'],
validate
}, mapStateToProps, mapDispatchToProps)(LoginView);