import React, { useState } from 'react' import { Icon, Loader, Button, Link, Dropdown, CircularLoader } from 'UI' import { forgotPassword, login } from 'App/routes' import ReCAPTCHA from 'react-google-recaptcha' import stl from './signup.css' import cn from 'classnames' import { signup, fetchTenants } from 'Duck/user'; import { connect } from 'react-redux' const FORGOT_PASSWORD = forgotPassword() 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, fetchTenants }, ) export default class SignupForm extends React.Component { state = { tenantId: '', fullname: '', password: '', email: '', projectName: '', }; componentDidMount() { this.props.fetchTenants(); } handleSubmit = (token) => { const { tenantId, fullname, password, email, projectName, auth } = this.state; this.props.signup({ tenantId, fullname, password, email, projectName, auth, 'g-recaptcha-response': token }) } 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 (
) } } // export default connect(state => ({ // errors: state.getIn([ 'user', 'signupRequest', 'errors' ]), // loading: state.getIn([ 'user', 'signupRequest', 'loading' ]), // }), { signup })(SignupForm)