import React from 'react'; import PropTypes from 'prop-types'; import Layout from 'coral-admin/src/components/Layout'; import styles from './NotFound.css'; import { Button, TextField, Alert, Success } from 'coral-ui'; import Recaptcha from 'react-recaptcha'; import cn from 'classnames'; import t from 'coral-framework/services/i18n'; class AdminLogin extends React.Component { constructor(props) { super(props); this.state = { email: '', password: '', requestPassword: false }; } handleSignIn = e => { e.preventDefault(); this.props.handleLogin(this.state.email, this.state.password); }; onRecaptchaLoad = () => { // do something? }; onRecaptchaVerify = recaptchaResponse => { this.props.handleLogin( this.state.email, this.state.password, recaptchaResponse ); }; handleRequestPassword = e => { e.preventDefault(); this.props.requestPasswordReset(this.state.email); }; render() { const { errorMessage, loginMaxExceeded, recaptchaPublic } = this.props; const signInForm = (
{errorMessage && {errorMessage}} this.setState({ email: e.target.value })} /> this.setState({ password: e.target.value })} type="password" />

{t('login.forgot_password')}{' '} { e.preventDefault(); this.setState({ requestPassword: true }); }} > {t('login.request_passowrd')}

{loginMaxExceeded && ( )} ); const requestPasswordForm = this.props.passwordRequestSuccess ? (

{ location.href = location.href; }} > {this.props.passwordRequestSuccess}{' '} {t('login.sign_in')}

) : (
this.setState({ email: e.target.value })} /> ); return (

{t('login.team_sign_in')}

{t('login.sign_in_message')}

{this.state.requestPassword ? requestPasswordForm : signInForm}
); } } AdminLogin.propTypes = { loginMaxExceeded: PropTypes.bool.isRequired, handleLogin: PropTypes.func.isRequired, passwordRequestSuccess: PropTypes.string, loginError: PropTypes.string, recaptchaPublic: PropTypes.string, requestPasswordReset: PropTypes.func, errorMessage: PropTypes.string, }; export default AdminLogin;