/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import {
  GET_SHORT_OFFERS,
  GET_ACCORDION_DATA,
  SET_CATEGORY_PRODUCTS,
  SET_CATEGORY_TITLE,
  GET_SLIDER_DATA
} from "../types/HomePage";

const INITIAL_STATE : HomePageReducerState = {
    shortOffers: [],
    accordionData: [],
    categoryProductList: [],
    categoryTitle: '',
    sliderData: []
  };

  interface HomePageReducerState {
    shortOffers: Array<any>;
    accordionData: Array<any>;
    categoryProductList: Array<any>;
    categoryTitle: string;
    sliderData: Array<any>;
  }
  
  export default function (state = INITIAL_STATE, action:any): HomePageReducerState {
    switch (action.type) {
      case GET_SHORT_OFFERS:
        return { ...state, shortOffers: action.payload };
      case GET_ACCORDION_DATA:
        return { ...state, accordionData: action.payload };
      case SET_CATEGORY_PRODUCTS:
        return { ...state, categoryProductList: action.payload };
      case SET_CATEGORY_TITLE:
        return { ...state, categoryTitle: action.payload };
      case GET_SLIDER_DATA:
        return { ...state, sliderData: action.payload };
      default :
        return state
    }
  };