import { types } from "../actions/actionTypes";

const initialState = {
  bestSellerData: {},
  productImageLength: 0,
  prdtOptInfo: {},
};

export const productReducer = (state = initialState, action) => {
  switch (action.type) {
    case types.GET_BEST_SELLER:
      return {
        ...state,
        bestSellerData: action.payload,
      };
    case types.GET_PRODUCT_OPTION:
      return {
        ...state,
        prdtOptInfo: action.payload.prdtOptInfo,
      };
    case types.GET_PRODUCT_GROUP:
      return {
        ...state,
        groupInfo: action.payload.groupInfo,
      };
    case types.GET_PRODUCT_IMAGE_LENGTH:
      return {
        ...state,
        productImageLength: action.payload + 1,
      };
    case types.GET_VIDEO_INDECATOR_FOCUS:
      return {
        ...state,
        videoIndicatorFocus: action.payload,
      };
    case types.CLEAR_PRODUCT_DETAIL:
      return {
        ...state,
        prdtOptInfo: null,
      };
    case types.GET_PRODUCT_OPTION_ID:
      return {
        ...state,
        prodOptCdCval: action.payload,
      };
    default:
      return state;
  }
};
