ilink-world/redux/reducers/GetDemandsGroupReducer.js

34 lines
924 B
JavaScript
Raw Normal View History

2020-09-30 05:46:30 +00:00
import { GET_DEMAND_GROUP_ERROR, GET_DEMAND_GROUP_PENDING, GET_DEMAND_GROUP_RESET, GET_DEMAND_GROUP_SUCCESS } from "../types/NanoCreditType";
2020-08-12 18:24:56 +00:00
const initialState = {
loading: false,
result: null,
error: null
};
export default (state = initialState, action) => {
switch (action.type) {
2020-09-30 05:46:30 +00:00
case GET_DEMAND_GROUP_PENDING: return {
2020-08-12 18:24:56 +00:00
...state,
loading: true
}
2020-09-30 05:46:30 +00:00
case GET_DEMAND_GROUP_SUCCESS: return {
2020-08-12 18:24:56 +00:00
...state,
loading: false,
result: action.result.data,
error: null
}
2020-09-30 05:46:30 +00:00
case GET_DEMAND_GROUP_ERROR: return {
2020-08-12 18:24:56 +00:00
...state,
loading: false,
result: null,
error: action.result
}
2020-09-30 05:46:30 +00:00
case GET_DEMAND_GROUP_RESET: return initialState;
2020-08-12 18:24:56 +00:00
default: {
return state;
}
}
};