import React from 'react'; import { Row, Col, FormGroup, ControlLabel, Button } from 'react-bootstrap'; import PropTypes from 'prop-types'; import { Link } from 'react-router-dom'; import { Accounts } from 'meteor/accounts-base'; import { Bert } from 'meteor/themeteorchef:bert'; import OAuthLoginButtons from '../../components/OAuthLoginButtons/OAuthLoginButtons'; import InputHint from '../../components/InputHint/InputHint'; import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter'; import validate from '../../../modules/validate'; class Signup extends React.Component { constructor(props) { super(props); this.handleSubmit = this.handleSubmit.bind(this); } componentDidMount() { const component = this; validate(component.form, { rules: { firstName: { required: true, }, lastName: { required: true, }, emailAddress: { required: true, email: true, }, password: { required: true, minlength: 6, }, }, messages: { firstName: { required: 'What\'s your first name?', }, lastName: { required: 'What\'s your last name?', }, emailAddress: { required: 'Need an email address here.', email: 'Is this email address correct?', }, password: { required: 'Need a password here.', minlength: 'Please use at least six characters.', }, }, submitHandler() { component.handleSubmit(); }, }); } handleSubmit() { const { history } = this.props; Accounts.createUser({ email: this.emailAddress.value, password: this.password.value, profile: { name: { first: this.firstName.value, last: this.lastName.value, }, }, }, (error) => { if (error) { Bert.alert(error.reason, 'danger'); } else { Bert.alert('Welcome!', 'success'); history.push('/documents'); } }); } render() { return (