import { URLS } from "./apiConfig";
import api from "./axiosConfig";

// Featured Brands 정보 조회 IF-LGSP-304
export async function getBrandList() {
  try {
    const response = await api.get(URLS.GET_BRAND_LIST);
    return response.data.data;
  } catch (error) {
    const { response } = error;

    if (response) {
      const statusCode = response.status;
      const statusText = response.statusText;

      console.error(`${statusCode} Error, ${statusText}`);
    }

    // throw new Error(error);
  }
}

// Featured Brands LAYOUT (shelf) 정보 조회 IF-LGSP-305
export async function getBrandLayoutInfo(props) {
  const { patnrId } = props;
  try {
    const response = await api.get(URLS.GET_BRAND_LAYOUT_INFO, {
      params: {
        patnrId,
      },
    });

    return response.data.data;
  } catch (error) {
    const { response } = error;

    if (response) {
      const statusCode = response.status;
      const statusText = response.statusText;

      console.error(`${statusCode} Error, ${statusText}`);
    }

    // throw new Error(error);
  }
}

// Featured Brands Live 채널 정보 조회 IF-LGSP-306
export async function getBrandLiveChannelInfo(props) {
  const { patnrId } = props;
  try {
    const response = await api.get(URLS.GET_BRAND_LIVE_CHANNEL_INFO, {
      params: {
        patnrId,
      },
    });

    return response.data.data;
  } catch (error) {
    const { response } = error;

    if (response) {
      const statusCode = response.status;
      const statusText = response.statusText;

      console.error(`${statusCode} Error, ${statusText}`);
    }

    // throw new Error(error);
  }
}

// Featured Brands Today's deals 정보 조회 IF-LGSP-307
export async function getBrandTSVInfo(props) {
  const { patnrId } = props;
  try {
    const response = await api.get(URLS.GET_BRAND_TODAYS_DEALS, {
      params: {
        patnrId,
      },
    });

    return response.data.data;
  } catch (error) {
    const { response } = error;

    if (response) {
      const statusCode = response.status;
      const statusText = response.statusText;

      console.error(`${statusCode} Error, ${statusText}`);
    }

    // throw new Error(error);
  }
}
