import { Dispatch } from "redux";
import proxy from "../proxy";
const publicApi = {
  getHomeData: (data: undefined) => async (dispatch: Dispatch) =>
    await proxy.get("public/homePage", data, { dispatch }),

  setFaqActive: (data: {}) => async (dispatch: Dispatch) =>
    await dispatch({ type: "public/faq/activate", data: data }),
  bookInfo:
    (data = {}) =>
    async (dispatch: Dispatch) =>
      await proxy.get("public/vod/bookCourse", data, { dispatch }),
  getContactData:
    (data = {}) =>
    async (dispatch: Dispatch) =>
      await proxy.get("public/contact", data, { dispatch }),

  getBlogList: (data: undefined) => async (dispatch: Dispatch) =>
    await proxy.get("public/blogList", data, { dispatch }),

  getBlogInfo: (data: String) => async (dispatch: Dispatch) =>
    await proxy.get("public/blogInfo", data, { dispatch }),
  setSubscribe: (data: Object) => async (dispatch: Dispatch) =>
    await dispatch({ type: "public/setSubscribe", data: data }),
  getProvince:
    (data = {}) =>
    async (dispatch: Dispatch) =>
      await proxy.get("public/province", data, { dispatch }),
  getCity:
    (data = {}) =>
    async (dispatch: Dispatch) =>
      await proxy.get("public/city", data, { dispatch }),
  selectMenu: (data: Object) => async (dispatch: Dispatch) =>
    await dispatch({ type: "public/selectMenu", data: data }),
  getHeader:
    (data = {}) =>
    async (dispatch: Dispatch) =>
      await proxy.get("public/VOD/homePage", data, { dispatch }),
};

export default publicApi;
