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

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-06-27 18:00:45 +00:00
import React, { PropTypes } from 'react';
2016-06-23 22:29:55 +00:00
2016-06-27 18:00:45 +00:00
function LoginForm(props) {
2016-09-30 02:02:06 +00:00
const { fields: { email, password }, handleSubmit, submitting, pristine } = props;
2016-06-27 18:00:45 +00:00
return (
<form className="login-form" onSubmit={handleSubmit(props.validateAndLoginUser.bind(this))}>
2016-06-27 18:00:45 +00:00
<p className="login-form__field">
<input
className="login-form__email-input"
2016-08-01 01:38:46 +00:00
aria-label="email"
2016-06-27 18:00:45 +00:00
type="text"
placeholder="Email"
{...email}
/>
{email.touched && email.error && <span className="form-error">{email.error}</span>}
2016-06-27 18:00:45 +00:00
</p>
<p className="login-form__field">
<input
className="signup-form__password-input"
2016-08-01 01:38:46 +00:00
aria-label="password"
2016-06-27 18:00:45 +00:00
type="password"
placeholder="Password"
{...password}
/>
{password.touched && password.error && <span className="form-error">{password.error}</span>}
2016-06-27 18:00:45 +00:00
</p>
2016-09-30 02:02:06 +00:00
<input type="submit" disabled={submitting || pristine} value="Login" aria-label="login" />
2016-06-27 18:00:45 +00:00
</form>
);
2016-06-23 22:29:55 +00:00
}
2016-06-27 18:00:45 +00:00
LoginForm.propTypes = {
fields: PropTypes.shape({
2016-08-30 03:26:45 +00:00
email: PropTypes.object.isRequired,
password: PropTypes.object.isRequired
2016-06-27 18:00:45 +00:00
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
validateAndLoginUser: PropTypes.func.isRequired,
submitting: PropTypes.bool,
invalid: PropTypes.bool,
pristine: PropTypes.bool
2016-06-27 18:00:45 +00:00
};
2016-06-23 22:29:55 +00:00
export default LoginForm;