client/src/components/Register.js
changeset 94 2c2a9c8dc216
parent 90 990f2c928b15
child 129 d48946d164c6
equal deleted inserted replaced
93:469da13402e2 94:2c2a9c8dc216
    13     const email = this.email.value;
    13     const email = this.email.value;
    14     const password1 = this.password1.value;
    14     const password1 = this.password1.value;
    15     const password2 = this.password2.value;
    15     const password2 = this.password2.value;
    16 
    16 
    17     this.props.authActions.registerSubmit(username, email, password1, password2);
    17     this.props.authActions.registerSubmit(username, email, password1, password2);
       
    18   }
       
    19 
       
    20   submit = (e) => {
       
    21     e.preventDefault();
       
    22 
       
    23     this.register();
    18   }
    24   }
    19 
    25 
    20   onClickLogin = (e) => {
    26   onClickLogin = (e) => {
    21     e.preventDefault();
    27     e.preventDefault();
    22     this.props.history.push('/login');
    28     this.props.history.push('/login');
    43         <Navbar history={this.props.history} />
    49         <Navbar history={this.props.history} />
    44         <Grid fluid>
    50         <Grid fluid>
    45           <Row>
    51           <Row>
    46             <Col md={6} mdOffset={3}>
    52             <Col md={6} mdOffset={3}>
    47               <Panel header={ panelHeader } className="panel-login">
    53               <Panel header={ panelHeader } className="panel-login">
    48                 <form>
    54                 <form onSubmit={this.submit}>
    49                   <FormGroup validationState={ errorMessages && errorMessages.has('username') ? 'error' : null }>
    55                   <FormGroup validationState={ errorMessages && errorMessages.has('username') ? 'error' : null }>
    50                     <ControlLabel>Username</ControlLabel>
    56                     <ControlLabel>Username</ControlLabel>
    51                     <FormControl componentClass="input" type="text" inputRef={ref => { this.username = ref; }} />
    57                     <FormControl componentClass="input" type="text" inputRef={ref => { this.username = ref; }} />
    52                     { this.renderErrorMessage(errorMessages, 'username') }
    58                     { this.renderErrorMessage(errorMessages, 'username') }
    53                   </FormGroup>
    59                   </FormGroup>
    64                   <FormGroup validationState={ errorMessages && errorMessages.has('password2') ? 'error' : null }>
    70                   <FormGroup validationState={ errorMessages && errorMessages.has('password2') ? 'error' : null }>
    65                     <ControlLabel>Confirm password</ControlLabel>
    71                     <ControlLabel>Confirm password</ControlLabel>
    66                     <FormControl componentClass="input" type="password" inputRef={ref => { this.password2 = ref; }} />
    72                     <FormControl componentClass="input" type="password" inputRef={ref => { this.password2 = ref; }} />
    67                     { this.renderErrorMessage(errorMessages, 'password2') }
    73                     { this.renderErrorMessage(errorMessages, 'password2') }
    68                   </FormGroup>
    74                   </FormGroup>
    69                   <Button block bsStyle="primary" onClick={this.register}>Register</Button>
    75                   <Button type="submit" block bsStyle="primary" onClick={this.register}>Register</Button>
    70                 </form>
    76                 </form>
    71               </Panel>
    77               </Panel>
    72               <p className="text-center">
    78               <p className="text-center">
    73                 <a className="text-muted" href="/login" onClick={ this.onClickLogin }>Already registered? Sign in.</a>
    79                 <a className="text-muted" href="/login" onClick={ this.onClickLogin }>Already registered? Sign in.</a>
    74               </p>
    80               </p>