File size: 796 Bytes
b89a86e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { Product } from "@/types";
import ProductCard from "./product-card";

interface SellerProductGridProps {
  products: Product[];
}

export default function SellerProductGrid({ products }: SellerProductGridProps) {
  // Ensure products is an array
  const productList = Array.isArray(products) ? products : [];
  
  if (productList.length === 0) {
    return (
      <div className="text-center py-6" data-testid="no-products">
        <p className="text-gray-500">No products found.</p>
      </div>
    );
  }

  return (
    <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 sm:gap-5 md:gap-6" data-testid="seller-product-grid">
      {productList.map((product) => (
        <ProductCard key={product.id} product={product} />
      ))}
    </div>
  );
}