import React from 'react' import { Icon, Button, Link, Dropdown, CircularLoader } from 'UI' import { login } from 'App/routes' import ReCAPTCHA from 'react-google-recaptcha' import stl from './signup.css' import { signup } from 'Duck/user'; import { connect } from 'react-redux' const LOGIN_ROUTE = login() const recaptchaRef = React.createRef() @connect( state => ({ tenants: state.getIn(['user', 'tenants']), errors: state.getIn([ 'user', 'signupRequest', 'errors' ]), loading: state.getIn([ 'user', 'signupRequest', 'loading' ]), }), { signup }, ) export default class SignupForm extends React.Component { state = { tenantId: '', fullname: '', password: '', email: '', projectName: '', organizationName: '', reload: false, }; static getDerivedStateFromProps(props, state) { if (props.errors && props.errors.size > 0 && state.reload) { recaptchaRef.current.reset(); return { reload: false } } return null; } handleSubmit = (token) => { const { tenantId, fullname, password, email, projectName, organizationName, auth } = this.state; this.props.signup({ tenantId, fullname, password, email, projectName, organizationName, auth, 'g-recaptcha-response': token }) this.setState({ reload: true }) } write = ({ target: { value, name } }) => this.setState({ [ name ]: value }) writeOption = (e, { name, value }) => this.setState({ [ name ]: value }); onSubmit = (e) => { e.preventDefault(); if (window.ENV.CAPTCHA_ENABLED && recaptchaRef.current) { recaptchaRef.current.execute(); } else if (!window.ENV.CAPTCHA_ENABLED) { this.handleSubmit(); } } render() { const { loading, errors, tenants } = this.props; return (

Get Started

Already having an account? Sign in
<> { window.ENV.CAPTCHA_ENABLED && ( this.handleSubmit(token) } /> )}
{ tenants.length > 0 && (
)}
By creating an account, you agree to our Terms of Service and Privacy Policy.
{ errors &&
{ errors.map(error => (
{ error }
)) }
}
) } }