giftCardReducer.js
748 Bytes
import { GET_GIFTCARD_FAIL, GET_GIFTCARD_REQUEST, GET_GIFTCARD_SUCCESS, CLEAR_ERRORS } from "../constants/giftCardConstants";
export const giftCardReducer = (state = { giftCard: [] }, action) => {
switch (action.type) {
case GET_GIFTCARD_REQUEST:
return {
loading: true
};
case GET_GIFTCARD_SUCCESS:
return {
giftCard: action.payload.data,
// totalCount: action.payload.meta.pagination.total,
// resultsPerPage: action.payload.meta.pagination.pageSize
};
case GET_GIFTCARD_FAIL:
return {
error: action.payload.error.message
};
case CLEAR_ERRORS:
return {
...state,
error: null
};
default:
return state;
}
};