function RelatedProducts({ productId }: { productId: string }) {
const { data, isLoading } = useRelatedProducts({ productId });
if (isLoading) return <div>Loading...</div>;
if (!data?.products.length) return null;
return (
<section>
<h2>You may also like</h2>
<div className="product-grid">
{data.products.map(product => (
<ProductCard key={product.id} product={product} />
))}
</div>
</section>
);
}
Hook to fetch products related to a specific product