client/src/components/SessionList.js
changeset 155 e55ae84508bf
parent 154 a28361bda28c
child 156 384f4539b76a
equal deleted inserted replaced
154:a28361bda28c 155:e55ae84508bf
    40     // opportunity to validate something and keep the modal open even if it
    40     // opportunity to validate something and keep the modal open even if it
    41     // requested to be closed
    41     // requested to be closed
    42     this.setState({modalIsOpen: false});
    42     this.setState({modalIsOpen: false});
    43   }
    43   }
    44 
    44 
    45   createSession = () => {
       
    46     const sessionId = uuidV1();
       
    47     let groupName = null;
       
    48     let protocol = null;
       
    49     if(this.props.currentGroup) {
       
    50       groupName = this.props.currentGroup.get('name');
       
    51       protocol = this.props.currentGroup.get('protocol');
       
    52     }
       
    53     if(groupName === null) {
       
    54       groupName = (this.props.currentUser)?this.props.currentUser.get('default_group'):null;
       
    55       if(groupName != null) {
       
    56         const group = this.props.groups.find((g) => g.name === groupName);
       
    57         if(group) {
       
    58           protocol = group.get('protocol');
       
    59         }
       
    60       }
       
    61     }
       
    62 
       
    63     this.props.sessionsActions.createSession(sessionId, groupName, protocol);
       
    64     this.props.history.push('/sessions/' + sessionId);
       
    65   }
       
    66 
       
    67   onClickDelete(session, e) {
    45   onClickDelete(session, e) {
    68     e.preventDefault();
    46     e.preventDefault();
    69     e.stopPropagation();
    47     e.stopPropagation();
    70 
    48 
    71 
    49 
    88 
    66 
    89   render() {
    67   render() {
    90     return (
    68     return (
    91       <div>
    69       <div>
    92         <Navbar history={this.props.history} />
    70         <Navbar history={this.props.history} />
    93         {/* <button id="session-button" type="button" className="btn btn-primary btn-lg text-secondary" onClick={ this.createSession}>Créer une nouvelle session</button> */}
       
    94         <div className="container-fluid">
    71         <div className="container-fluid">
    95           <div className="row mt-5 pt-5">
    72           <div className="row mt-5 pt-5">
    96                 {this.props.sessions.map((session) =>
    73                 {this.props.sessions.map((session) =>
    97                   <div className="col-lg-4" id="session">
    74                   <div className="col-lg-4" id="session">
    98                       <div className="col-md-auto m-4 p-4 session" key={session.get('_id')}>
    75                       <div className="col-md-auto m-4 p-4 session" key={session.get('_id')}>