import {Component} from 'react'; import {browserHistory} from 'react-router'; import {ClassNames} from '@emotion/react'; import styled from '@emotion/styled'; import {Client} from 'sentry/api'; import Form from 'sentry/components/deprecatedforms/form'; import PasswordField from 'sentry/components/deprecatedforms/passwordField'; import RadioBooleanField from 'sentry/components/deprecatedforms/radioBooleanField'; import TextField from 'sentry/components/deprecatedforms/textField'; import ExternalLink from 'sentry/components/links/externalLink'; import {t, tct} from 'sentry/locale'; import ConfigStore from 'sentry/stores/configStore'; import {AuthConfig} from 'sentry/types'; import {formFooterClass} from 'sentry/views/auth/login'; const SubscribeField = () => ( Privacy Policy, } )} /> ); type Props = { api: Client; authConfig: AuthConfig; }; type State = { errorMessage: null | string; errors: Record; }; class RegisterForm extends Component { state: State = { errorMessage: null, errors: {}, }; handleSubmit: Form['props']['onSubmit'] = async (data, onSuccess, onError) => { const {api} = this.props; try { const response = await api.requestPromise('/auth/register/', { method: 'POST', data, }); onSuccess(data); // TODO(epurkhiser): There is more we need to do to setup the user. but // definitely primarily we need to init our user. ConfigStore.set('user', response.user); browserHistory.push({pathname: response.nextUri}); } catch (e) { if (!e.responseJSON || !e.responseJSON.errors) { onError(e); return; } let message = e.responseJSON.detail; if (e.responseJSON.errors.__all__) { message = e.responseJSON.errors.__all__; } this.setState({ errorMessage: message, errors: e.responseJSON.errors || {}, }); onError(e); } }; render() { const {hasNewsletter} = this.props.authConfig; const {errorMessage, errors} = this.state; return ( {({css}) => (
{t('Privacy Policy')} } > {hasNewsletter && } )}
); } } const PrivacyPolicyLink = styled(ExternalLink)` color: ${p => p.theme.gray300}; &:hover { color: ${p => p.theme.textColor}; } `; export default RegisterForm;