import { useQuery } from '@tanstack/react-query';
import { getProductData } from '../requests/products/producDataRequest';
import { getProductsByCategory } from '../requests/products/productsByCategoryRequest';

export const useFetchSingleProduct = (customID) => {
  return useQuery(
    ['product', customID],
    async () => await getProductData(customID)
  );
};

export const useFetchSimilarProducts = (category) => {
  return useQuery(
    ['products', category],
    async () => await getProductsByCategory(category),
    {
      enabled: !!category,
    }
  );
};

export const useFetchProductsByCategory = (productType) => {
  return useQuery(
    ['filteredProducts', productType],
    async () => await getProductsByCategory(productType),
    { enabled: productType === 'Mug' || productType === 'Coffee' }
  );
};
