import { URLS } from "../api/apiConfig";
import { TAxios } from "../api/TAxios";
import { types } from "./actionTypes";

// Best Seller 상품 목록 조회 IF-LGSP-303
export const getBestSeller = () => (dispatch, getState) => {
  const onSuccess = (response) => {
    console.log("getBestSeller onSuccess", response.data);

    dispatch({
      type: types.GET_BEST_SELLER,
      payload: response.data.data,
    });
  };

  const onFail = (error) => {
    console.error("getBestSeller onFail", error);
  };

  TAxios(
    dispatch,
    getState,
    "get",
    URLS.GET_PRODUCT_BESTSELLER,
    {},
    {},
    onSuccess,
    onFail
  );
};
