reviewsReducers.js
657 Bytes
import { GET_REVIEWS_FAIL, GET_REVIEWS_REQUEST, GET_REVIEWS_SUCCESS, CLEAR_ERRORS } from "../constants/reviewsConstants";
// Room details reducer.
export const reviewsReducer = (state = { reviews: [] }, action) => {
switch (action.type) {
case GET_REVIEWS_REQUEST:
return {
loading: true
};
case GET_REVIEWS_SUCCESS:
return {
loading: false,
reviews: action.payload.data
};
case GET_REVIEWS_FAIL:
return {
error: action.payload.error.message
};
case CLEAR_ERRORS:
return {
...state,
error: null
};
default:
return state;
}
};