Skip to content

Commit abc8959

Browse files
committed
component container et action
1 parent 9d3d077 commit abc8959

File tree

10 files changed

+223
-199
lines changed

10 files changed

+223
-199
lines changed

src/actions/getCompetences.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//Asyncrone request and Promise based HTTP client for the browser
2+
import axios from 'axios';
3+
4+
//Liste des actions
5+
import {
6+
GET_COMPETENCES_REQUEST,GET_COMPETENCES_SUCCESS,GET_COMPETENCES_FAILURE
7+
} from '../constants/actionTypes';
8+
9+
// Point d'entré de notre API
10+
const ROOT_URI = axios.create({
11+
baseURL: 'http://127.0.0.1:8000'
12+
})
13+
14+
15+
16+
const getCompetencesRequest = (request) => {
17+
return {
18+
type: GET_COMPETENCES_REQUEST,
19+
request
20+
}
21+
};
22+
23+
const getCompetencesSuccess = (data) => {
24+
25+
return {
26+
type: GET_COMPETENCES_SUCCESS,
27+
data
28+
}
29+
};
30+
const getCompetencesFailure = (error) => {
31+
32+
return {
33+
type: GET_COMPETENCES_FAILURE,
34+
error
35+
}
36+
};
37+
38+
39+
export const getCompetences = () => {
40+
41+
let request = "/competences";
42+
43+
return dispatch => {
44+
dispatch(getCompetencesRequest(request));
45+
return ROOT_URI.get(request)
46+
.then(
47+
res => dispatch(getCompetencesSuccess(res)),
48+
error => {
49+
dispatch(getCompetencesFailure(error))
50+
}
51+
)
52+
}
53+
};
54+
55+
export default getCompetences;
56+
57+

src/actions/getInterventions.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//Asyncrone request and Promise based HTTP client for the browser
2+
import axios from 'axios';
3+
4+
//Liste des actions
5+
import {
6+
GET_INTERVENTIONS_REQUEST,GET_INTERVENTIONS_SUCCESS,GET_INTERVENTIONS_FAILURE,
7+
GET_COMPETENCES_REQUEST,GET_COMPETENCES_SUCCESS,GET_COMPETENCES_FAILURE
8+
} from '../constants/actionTypes';
9+
10+
// Point d'entré de notre API
11+
const ROOT_URI = axios.create({
12+
baseURL: 'http://127.0.0.1:8000'
13+
})
14+
15+
16+
17+
const getInterventionsRequest = (request) => {
18+
return {
19+
type: GET_INTERVENTIONS_REQUEST,
20+
request
21+
}
22+
};
23+
24+
const getInterventionsSuccess = (data) => {
25+
26+
return {
27+
type: GET_INTERVENTIONS_SUCCESS,
28+
data
29+
}
30+
};
31+
const getInterventionsFailure = (error) => {
32+
33+
return {
34+
type: GET_INTERVENTIONS_FAILURE,
35+
error
36+
}
37+
};
38+
39+
40+
export const getInterventions = () => {
41+
42+
let request = "/interventions";
43+
44+
return dispatch => {
45+
dispatch(getInterventionsRequest(request));
46+
return ROOT_URI.get(request)
47+
.then(
48+
res => dispatch(getInterventionsSuccess(res)),
49+
error => {
50+
dispatch(getInterventionsFailure(error))
51+
}
52+
)
53+
}
54+
};
55+
56+
export default getInterventions;
57+
58+

src/actions/index.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/components/CompetencesList.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
3+
4+
const CompetencesList =({competencesList}) => {
5+
6+
7+
return (
8+
<div>
9+
{competencesList.map((competence, index) =>
10+
<div key={index}>
11+
<span>{competence.description}</span>
12+
</div>
13+
)}
14+
15+
</div>
16+
);
17+
}
18+
19+
20+
export default CompetencesList;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
3+
4+
const InterventionsList =({interventionsList}) => {
5+
6+
7+
return (
8+
<div>
9+
{interventionsList.map((intervention, index) =>
10+
<div key={index}>
11+
<span>{intervention.description}</span>
12+
</div>
13+
)}
14+
15+
</div>
16+
);
17+
}
18+
19+
20+
export default InterventionsList;

src/components/competences.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/components/interventions.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/constants/actionTypes.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
//Liste des Interventins
3-
export const FETCH_INTERVENTIONS = 'FETCH_INTERVENTIONS';
4-
export const FETCH_INTERVENTIONS_SUCCESS = 'FETCH_INTERVENTIONS_SUCCESS';
5-
export const FETCH_INTERVENTIONS_FAILURE = 'FETCH_INTERVENTIONS_FAILURE';
3+
export const GET_INTERVENTIONS_REQUEST = 'GET_INTERVENTIONS_REQUEST';
4+
export const GET_INTERVENTIONS_SUCCESS = 'GET_INTERVENTIONS_SUCCESS';
5+
export const GET_INTERVENTIONS_FAILURE = 'GET_INTERVENTIONS_FAILURE';
66

77
//Liste des Competences
8-
export const FETCH_COMPETENCES = 'FETCH_COMPETENCES';
9-
export const FETCH_COMPETENCES_SUCCESS = 'FETCH_COMPETENCES_SUCCESS';
10-
export const FETCH_COMPETENCES_FAILURE = 'FETCH_COMPETENCES_FAILURE';
8+
export const GET_COMPETENCES_REQUEST = 'GET_COMPETENCES_REQUEST';
9+
export const GET_COMPETENCES_SUCCESS = 'GET_COMPETENCES_SUCCESS';
10+
export const GET_COMPETENCES_FAILURE = 'GET_COMPETENCES_FAILURE';

0 commit comments

Comments
 (0)