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

// On Sale 조회 IF-LGSP-086
export const getOnSaleInfo = (props) => (dispatch, getState) => {
  const { categoryIncFlag, lgCatCd } = props;

  const onSuccess = (response) => {
    console.log("getOnSaleInfo onSuccess ", response.data);

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

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

  TAxios(
    dispatch,
    getState,
    "get",
    URLS.GET_ON_SALE_INFO,
    { categoryIncFlag, lgCatCd },
    {},
    onSuccess,
    onFail
  );
};
