import React from 'react'; import PropTypes from 'prop-types'; import { Slot } from 'plugin-api/beta/client/components'; import { Button, TextField, Spinner, Success, Alert, } from 'plugin-api/beta/client/components/ui'; import { t } from 'plugin-api/beta/client/services'; import styles from './SignUp.css'; import External from './External'; class SignUp extends React.Component { handleSignInLink = e => { e.preventDefault(); this.props.onSignInLink(); }; handleUsernameChange = e => this.props.onUsernameChange(e.target.value); handleEmailChange = e => this.props.onEmailChange(e.target.value); handlePasswordChange = e => this.props.onPasswordChange(e.target.value); handlePasswordRepeatChange = e => this.props.onPasswordRepeatChange(e.target.value); handleSubmit = e => { e.preventDefault(); this.props.onSubmit(); }; childFactory = el => { const key = el.key; const props = { indicateBlocker: () => this.props.indicateBlocker(key), indicateBlockerResolved: () => this.props.indicateBlockerResolved(key), }; return React.cloneElement(el, props); }; render() { const { username, email, password, passwordRepeat, usernameError, emailError, passwordError, passwordRepeatError, loading, errorMessage, requireEmailConfirmation, success, blocked, } = this.props; return (

{t('talk-plugin-auth.login.sign_up')}

{errorMessage && {errorMessage}} {!success && (
{passwordError && ( {' '} Password must be at least 8 characters.{' '} )}
{loading && }
)} {success && (
{requireEmailConfirmation && (

{t('talk-plugin-auth.login.verify_email')}

{t('talk-plugin-auth.login.verify_email2')}

)}
)}
{t('talk-plugin-auth.login.already_have_an_account')}{' '} {t('talk-plugin-auth.login.sign_in')}
); } } SignUp.propTypes = { loading: PropTypes.bool.isRequired, username: PropTypes.string.isRequired, usernameError: PropTypes.string, email: PropTypes.string.isRequired, emailError: PropTypes.string, password: PropTypes.string.isRequired, passwordError: PropTypes.string, passwordRepeat: PropTypes.string.isRequired, passwordRepeatError: PropTypes.string, onUsernameChange: PropTypes.func.isRequired, onEmailChange: PropTypes.func.isRequired, onPasswordChange: PropTypes.func.isRequired, onPasswordRepeatChange: PropTypes.func.isRequired, onSignInLink: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired, errorMessage: PropTypes.string, requireEmailConfirmation: PropTypes.bool.isRequired, success: PropTypes.bool.isRequired, blocked: PropTypes.bool.isRequired, indicateBlocker: PropTypes.func.isRequired, indicateBlockerResolved: PropTypes.func.isRequired, }; export default SignUp;