import { apiWorker } from './api';

export const getCategoryTree = async () => {
  const result = await apiWorker.get('/shopee/category/getCategoryTree');
  return result ? result.data : null;
};

export const getCategoryList = async () => {
  const result = await apiWorker.get('/shopee/category/getCategoryList');
  return result ? result.data : null;
};

/**
 *
 * @param {string[]} listCategoryId
 * @param {number} page
 * @param {number} limit
 * @returns {Promise<Array>}
 */
export const fetchListProductCategoryId = async (listCategoryId, page = 0, limit = 100) => {
  const result = await apiWorker.post('/shopee/product/fetchProductListCategoryId', {
    listCategoryId,
    limit,
    page,
  });
  return result ? result.data : null;
};

/**
 *
 * @param {string[]} listShopId
 * @param {number} page
 * @param {number} limit
 * @returns {Promise<Array>}
 */
export const fetchListProductShopId = async (listShopId, page = 0, limit = 100) => {
  const result = await apiWorker.post('/shopee/product/fetchProductListShopId', {
    listShopId,
    limit,
    page,
  });
  return result ? result.data : null;
};
