client/src/components/Login.js
changeset 12 48ddaa42b810
child 44 3b20e2b584fe
equal deleted inserted replaced
11:6fb4de54acea 12:48ddaa42b810
       
     1 import React, { Component } from 'react';
       
     2 import { connect } from 'react-redux';
       
     3 import { bindActionCreators } from 'redux';
       
     4 import { Grid, Row, Col, Panel, FormGroup, ControlLabel, FormControl, Button } from 'react-bootstrap';
       
     5 import '../App.css';
       
     6 import Navbar from './Navbar';
       
     7 import * as sessionsActions from '../actions/sessionsActions';
       
     8 
       
     9 class Login extends Component {
       
    10 
       
    11   login = () => {
       
    12     const username = this.username.value;
       
    13     const password = this.password.value;
       
    14 
       
    15     console.log(username, password);
       
    16 
       
    17   }
       
    18 
       
    19   render() {
       
    20     return (
       
    21       <div>
       
    22         <Navbar history={this.props.history} />
       
    23         <Grid fluid>
       
    24           <Row>
       
    25             <Col md={6} mdOffset={3}>
       
    26               <Panel>
       
    27                 <form>
       
    28                   <FormGroup>
       
    29                     <ControlLabel>Username</ControlLabel>
       
    30                     <FormControl componentClass="input" type="text" inputRef={ref => { this.username = ref; }} />
       
    31                   </FormGroup>
       
    32                   <FormGroup>
       
    33                     <ControlLabel>Password</ControlLabel>
       
    34                     <FormControl componentClass="input" type="password" inputRef={ref => { this.password = ref; }} />
       
    35                   </FormGroup>
       
    36                   <Button block bsStyle="primary" onClick={this.login}>Login</Button>
       
    37                 </form>
       
    38               </Panel>
       
    39             </Col>
       
    40           </Row>
       
    41         </Grid>
       
    42       </div>
       
    43     );
       
    44   }
       
    45 }
       
    46 
       
    47 function mapStateToProps(state, props) {
       
    48   return {
       
    49     currentSession: state.get('currentSession'),
       
    50     sessions: state.get('sessions')
       
    51   };
       
    52 }
       
    53 
       
    54 function mapDispatchToProps(dispatch) {
       
    55   return {
       
    56     actions: bindActionCreators(sessionsActions, dispatch)
       
    57   }
       
    58 }
       
    59 
       
    60 export default connect(mapStateToProps, mapDispatchToProps)(Login);