simba-mobile-cad3/app/redux/reducers/GetNotificationReducer.js

34 lines
932 B
JavaScript
Raw Normal View History

2025-01-07 09:47:45 +00:00
import { GET_NOTIFICATIONS_SUCCESS, GET_NOTIFICATIONS_ERROR, GET_NOTIFICATIONS_RESET, GET_NOTIFICATIONS_PENDING } from "../types/NanoCreditType";
const initialState = {
loading: false,
result: null,
error: null
};
export default (state = initialState, action) => {
switch (action.type) {
case GET_NOTIFICATIONS_PENDING: return {
...state,
loading: true
}
case GET_NOTIFICATIONS_SUCCESS: return {
...state,
loading: false,
result: action.result.data,
error: null
}
case GET_NOTIFICATIONS_ERROR: return {
...state,
loading: false,
result: null,
error: action.result
}
case GET_NOTIFICATIONS_RESET: return initialState;
default: {
return state;
}
}
};