import {CATEGORIES, PRODUCTS} from "@/shared/constants/apiEndpoints";
import {GetProductsResponse} from "@/shared/types/product";
import {GET} from "@/shared/api/apiClient";
import { BrandProductsType } from "../types/brands";

interface GetProductsProps {
  categoryId: number
  currentPage?: number
}

export const getProducts = async ({categoryId, currentPage}: GetProductsProps): Promise<{
  data: GetProductsResponse
}> => {
  const res = await GET<GetProductsResponse>(`${CATEGORIES}/${categoryId}${PRODUCTS}`, {
      ...(currentPage !== undefined && { page: currentPage })
  });
  return res;
}

export const getProductById = async (productId: number): Promise<any> => {
  const res = await GET(`${PRODUCTS}/${productId}`);
  return res;
}