simba-mobile-cud/app/redux/historic/historic.reducer.js

39 lines
898 B
JavaScript
Raw Permalink Normal View History

2025-01-07 09:47:45 +00:00
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
}
};