testimonialReducer.js
786 Bytes
import { GET_TESTIMONIAL_REQUEST, CLEAR_ERRORS, GET_TESTIMONIAL_SUCCESS, GET_TESTIMONIAL_FAIL } from "../constants/testimonialConstants";
export const getAllTestimonialReducer = (state = { loading: true, success: false, testimonial: null }, action) => {
switch (action.type) {
case GET_TESTIMONIAL_REQUEST:
return {
loading: true,
};
case GET_TESTIMONIAL_SUCCESS:
return {
loading: false,
testimonial: action.payload
};
case GET_TESTIMONIAL_FAIL:
return {
loading: false,
error: action.payload.error.message
};
case CLEAR_ERRORS:
return {
...state,
error: null
};
default:
return state;
}
};