1+ 'use strict' ;
12import React , { Component } from 'react' ;
23//import { Link } from 'react-router';
4+ import { bindActionCreators } from 'redux' ;
5+ import { connect } from 'react-redux' ;
6+
7+
8+ import { fetchInterventions } from '../actions/index' ;
9+
10+ import { getInterventions } from '../reducers/intervention_reducer'
311
412class Interventions extends Component {
513
6- ComponentWillMount ( ) {
7- this . props . fetchInterventions ( ) ;
14+ componentWillMount ( ) {
15+ this . props . listActions ;
816 }
917
10- renderCompetences ( interventions ) {
11- return interventions . map ( ( intervention ) => {
12- return {
13- < div >
14- < h3 > { intervention . nom } </ h3 >
15- < p > { intervention . description } </ p >
18+ renderInterventions ( interventions ) {
19+ interventions . map ( interventions => {
20+ return (
21+ < div key = { interventions . id } >
22+ < h3 > { interventions . nom } </ h3 >
23+ < p > { interventions . description } </ p >
1624 </ div >
17- } ;
25+ ) ;
1826 } ) ;
1927 }
2028
2129 render ( ) {
22- const { interventions, error, loding } = this . props . interventionsList ;
23-
24- if ( loding ) {
25- return < div className = "interventions" > Loading...</ div >
26- }
27- else if ( error ) {
28- return < div className = "alert" > Error : { error } </ div >
29- }
30+ const interventions = this . props . interventionsList ;
31+
3032 return (
3133 < div >
32- < h2 > Divers Competences </ h2 >
34+ < h2 > Divers Interventions </ h2 >
3335 { this . renderInterventions ( interventions ) }
3436 </ div >
3537 ) ;
38+ } ;
39+ }
40+
41+ function mapDispatchToProps ( dispatch ) {
42+ return {
43+ listActions : bindActionCreators ( fetchInterventions , dispatch )
44+ }
45+ }
46+
47+ function mapStateToProps ( state ) {
48+ return {
49+ interventionsList : state . getInterventions
3650 }
3751}
3852
39- export default Interventions ;
53+ export default connect ( mapStateToProps , mapDispatchToProps ) ( Interventions ) ;
0 commit comments