Blame view

redux/reducers/homeBannerReducer.js 776 Bytes
Ravindra Kanojiya 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_HOMEBANNER_REQUEST, CLEAR_ERRORS, GET_HOMEBANNER_SUCCESS, GET_HOMEBANNER_FAIL } from "../constants/homeBannerConstants";

export const getAllHomeBannerReducer = (state = { loading: true, success: false, homeBanner: null }, action) => {
    switch (action.type) {
      case GET_HOMEBANNER_REQUEST:
        return {
          loading: true,
        };
  
      case GET_HOMEBANNER_SUCCESS:
        return {
          loading: false,
          homeBanner: action.payload
        };
  
      case GET_HOMEBANNER_FAIL:
        return {
          loading: false,
          error: action.payload.error.message
        };
  
      case CLEAR_ERRORS:
        return {
          ...state,
          error: null
        };
  
      default:
        return state;
    }
  };