client/src/components/Session.js
changeset 62 b2514a9bcd49
parent 59 1eb52770eefa
child 63 4088f8dc6b52
equal deleted inserted replaced
61:7586b4a11c32 62:b2514a9bcd49
     9 import SessionForm from './SessionForm';
     9 import SessionForm from './SessionForm';
    10 import * as sessionsActions from '../actions/sessionsActions';
    10 import * as sessionsActions from '../actions/sessionsActions';
    11 import * as notesActions from '../actions/notesActions';
    11 import * as notesActions from '../actions/notesActions';
    12 
    12 
    13 class Session extends Component {
    13 class Session extends Component {
    14 
       
    15   componentDidMount = () => {
       
    16     this.props.notesActions.loadNotesBySession({ _id: this.props.match.params.id });
       
    17   }
       
    18 
    14 
    19   render() {
    15   render() {
    20     return (
    16     return (
    21       <div>
    17       <div>
    22         <Navbar history={this.props.history} />
    18         <Navbar history={this.props.history} />
    48 
    44 
    49 function mapStateToProps(state, props) {
    45 function mapStateToProps(state, props) {
    50 
    46 
    51   const sessionId = props.match.params.id;
    47   const sessionId = props.match.params.id;
    52 
    48 
    53   const sessions = state.get('sessions');
    49   const sessions = state['sessions'];
    54   const notes = state.get('notes');
    50   const notes = state['notes'];
       
    51 
    55   const currentSession = sessions.find(session => session._id === sessionId);
    52   const currentSession = sessions.find(session => session._id === sessionId);
       
    53   const currentNotes = notes.filter(note => {
       
    54         return note.session === sessionId;
       
    55     });
    56 
    56 
    57   return {
    57   return {
    58     currentSession,
    58     currentSession,
    59     sessions,
    59     sessions,
    60     notes,
    60     notes: currentNotes,
    61   };
    61   };
    62 }
    62 }
    63 
    63 
    64 function mapDispatchToProps(dispatch) {
    64 function mapDispatchToProps(dispatch) {
    65   return {
    65   return {