homeBannersReducer.js 577 Bytes
import { FETCH_HOME_BANNERS_SUCCESS, FETCH_HOME_BANNERS_FAIL, CLEAR_ERRORS } from "../constants/homeBannerConstants";

// Room details reducer.
export const homeBannerReducer = (state = { homeBanners: [] }, action) => {
  switch (action.type) {
    case FETCH_HOME_BANNERS_SUCCESS:
      return {
        homeBanners: action.payload.data
      };

    case FETCH_HOME_BANNERS_FAIL:
      return {
        error: action.payload.error.message
      };

    case CLEAR_ERRORS:
      return {
        ...state,
        error: null
      };

    default:
      return state;
  }
};