import React from 'react'; import PropTypes from 'prop-types'; import styles from './SignIn.css'; import { Button, TextField, Alert } from 'coral-ui'; import cn from 'classnames'; import Recaptcha from 'coral-framework/components/Recaptcha'; import External from './External'; class SignIn extends React.Component { recaptcha = null; handleForgotPasswordLink = e => { e.preventDefault(); this.props.onForgotPasswordLink(); }; handleEmailChange = e => this.props.onEmailChange(e.target.value); handlePasswordChange = e => this.props.onPasswordChange(e.target.value); handleSubmit = e => { e.preventDefault(); this.props.onSubmit(); // Reset recaptcha because each response can only // be used once. if (this.recaptcha) { this.recaptcha.reset(); } }; handleRecaptchaRef = ref => { this.recaptcha = ref; }; render() { const { email, password, errorMessage, requireRecaptcha } = this.props; return (
{errorMessage && {errorMessage}} {requireRecaptcha && (
)}

{/* TODO: translate */} Forgot your password?{' '} Request a new one.

); } } SignIn.propTypes = { email: PropTypes.string.isRequired, password: PropTypes.string.isRequired, onEmailChange: PropTypes.func.isRequired, onPasswordChange: PropTypes.func.isRequired, onForgotPasswordLink: PropTypes.func.isRequired, onRecaptchaVerify: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired, errorMessage: PropTypes.string, requireRecaptcha: PropTypes.bool.isRequired, }; export default SignIn;