Blame view

redux/reducers/reviewsReducers.js 657 Bytes
.  
jaymehta committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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;
  }
};