client/src/components/SessionList.js
changeset 93 469da13402e2
parent 62 b2514a9bcd49
child 95 7bc08467c726
equal deleted inserted replaced
92:5a73b44925f2 93:469da13402e2
    14     const sessionId = uuidV1();
    14     const sessionId = uuidV1();
    15     this.props.sessionsActions.createSession(sessionId);
    15     this.props.sessionsActions.createSession(sessionId);
    16     this.props.history.push('/sessions/' + sessionId);
    16     this.props.history.push('/sessions/' + sessionId);
    17   }
    17   }
    18 
    18 
       
    19   onClickDelete(session, e) {
       
    20     e.preventDefault();
       
    21     e.stopPropagation();
       
    22 
       
    23     this.props.sessionsActions.deleteSession(session);
       
    24   }
       
    25 
    19   render() {
    26   render() {
    20     return (
    27     return (
    21       <div>
    28       <div>
    22         <Navbar history={this.props.history} />
    29         <Navbar history={this.props.history} />
    23         <Grid fluid>
    30         <Grid fluid>
    27                 {this.props.sessions.map((session) =>
    34                 {this.props.sessions.map((session) =>
    28                   <ListGroupItem
    35                   <ListGroupItem
    29                     key={session.get('_id')}
    36                     key={session.get('_id')}
    30                     onClick={() => this.props.history.push('/sessions/' + session.get('_id'))}>
    37                     onClick={() => this.props.history.push('/sessions/' + session.get('_id'))}>
    31                     {session.title || 'No title'} {session.get('_id')} {moment(session.get('date')).format('DD/MM/YYYY')}
    38                     {session.title || 'No title'} {session.get('_id')} {moment(session.get('date')).format('DD/MM/YYYY')}
       
    39                     <a className="pull-right" onClick={ this.onClickDelete.bind(this, session) }>
       
    40                       <span className="material-icons">delete</span>
       
    41                     </a>
    32                   </ListGroupItem>
    42                   </ListGroupItem>
    33                 )}
    43                 )}
    34               </ListGroup>
    44               </ListGroup>
    35               <Button bsStyle="success" onClick={this.createSession}>Create new session</Button>
    45               <Button bsStyle="success" onClick={this.createSession}>Create new session</Button>
    36             </Col>
    46             </Col>
    41   }
    51   }
    42 }
    52 }
    43 
    53 
    44 function mapStateToProps(state, props) {
    54 function mapStateToProps(state, props) {
    45   return {
    55   return {
    46     // currentSession: state.get('currentSession'),
       
    47     // sessions: state.get('sessions')
       
    48     sessions: state['sessions']
    56     sessions: state['sessions']
    49   };
    57   };
    50 }
    58 }
    51 
    59 
    52 function mapDispatchToProps(dispatch) {
    60 function mapDispatchToProps(dispatch) {