Skip to content

Commit 9d3d077

Browse files
committed
Modification des reducers
1 parent bd4c79a commit 9d3d077

File tree

5 files changed

+75
-44
lines changed

5 files changed

+75
-44
lines changed

src/reducers/competenceReducer.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//Liste des actions
2+
import {
3+
FETCH_COMPETENCES,FETCH_COMPETENCES_SUCCESS,FETCH_COMPETENCES_FAILURE
4+
} from '../constants/actionTypes';
5+
6+
const INITIAL_STATE = {
7+
competencesList: null,
8+
lastRequest: null
9+
};
10+
11+
export const competencesReducer = (state = INITIAL_STATE, action) => {
12+
13+
const {data, type, request, error} = action;
14+
15+
switch (type) {
16+
case FETCH_COMPETENCES:
17+
return {
18+
...state,
19+
lastRequest: request,
20+
};
21+
case FETCH_COMPETENCES_SUCCESS:
22+
return {
23+
...state,
24+
competencesList: data,
25+
};
26+
case FETCH_COMPETENCES_FAILURE:
27+
return {
28+
...state,
29+
error,
30+
};
31+
default:
32+
return state;
33+
}
34+
};
35+
36+
// Get all posts
37+
export default competencesReducer;

src/reducers/competence_reducer.js

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

src/reducers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { combineReducers } from 'redux';
22

33
import interventionReducer from './intervention_reducer';
4-
import competenceReducer from './competence_reducer';
4+
import competencesReducer from './competence_reducer';
55

66
//import {reducer as form} from 'redux-form';
77

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//Liste des actions
2+
import {
3+
FETCH_INTERVENTIONS,FETCH_INTERVENTIONS_SUCCESS,FETCH_INTERVENTIONS_FAILURE
4+
} from '../constants/actionTypes';
5+
6+
const INITIAL_STATE = {
7+
interventionsList: null,
8+
lastRequest: null
9+
};
10+
11+
export const interventionsReducer = (state = INITIAL_STATE, action) => {
12+
13+
const {data, type, request, error} = action;
14+
15+
switch (type) {
16+
case FETCH_INTERVENTIONS:
17+
return {
18+
...state,
19+
lastRequest: request,
20+
};
21+
case FETCH_INTERVENTIONS_SUCCESS:
22+
return {
23+
...state,
24+
interventionsList: data,
25+
};
26+
case FETCH_INTERVENTIONS_FAILURE:
27+
return {
28+
...state,
29+
error,
30+
};
31+
default:
32+
return state;
33+
}
34+
};
35+
36+
// Get all posts
37+
export default interventionsReducer;

src/reducers/intervention_reducer.js

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

0 commit comments

Comments
 (0)