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

// 추천 Keyword 목록 조회 IF-LGSP-055
export const getMyRecommandedKeyword = () => (dispatch, getState) => {
  const onSuccess = (response) => {
    console.log("getMyRecommandedKeyword onSuccess ", response.data);

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

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

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

// FAQ 조회 (IF-LGSP-048)
export const getMyFaqInfo = () => (dispatch, getState) => {
  const onSuccess = (response) => {
    console.log("getMyFaqInfo onSuccess ", response.data);
    dispatch({
      type: types.GET_MY_FAQ_INFO,
      payload: response.data.data,
    });
  };

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

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