39 lines
898 B
JavaScript
39 lines
898 B
JavaScript
|
import HistoricActions from "./historic.type";
|
||
|
|
||
|
|
||
|
const INITIAL_STATE = {
|
||
|
loading: false,
|
||
|
result: null,
|
||
|
error: null,
|
||
|
};
|
||
|
|
||
|
export const historicReducer = (state = INITIAL_STATE, action) => {
|
||
|
switch (action.type) {
|
||
|
case HistoricActions.GET_HISTORY_PENDING:
|
||
|
return {
|
||
|
...state,
|
||
|
loading: true
|
||
|
}
|
||
|
case HistoricActions.GET_HISTORY_SUCCESS:
|
||
|
return {
|
||
|
loading: false,
|
||
|
result: action.payload,
|
||
|
error: null
|
||
|
}
|
||
|
case HistoricActions.GET_HISTORY_ERROR:
|
||
|
return {
|
||
|
...state,
|
||
|
loading: false,
|
||
|
result: null,
|
||
|
error: action.payload
|
||
|
}
|
||
|
|
||
|
case HistoricActions.GET_HISTORY_RESET:
|
||
|
return INITIAL_STATE;
|
||
|
|
||
|
default:
|
||
|
return state
|
||
|
|
||
|
}
|
||
|
};
|