forked from IT-Cotato/12th-OnGil-FE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-list.tsx
More file actions
48 lines (44 loc) · 1.38 KB
/
product-list.tsx
File metadata and controls
48 lines (44 loc) · 1.38 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { ProductWithWishlist } from '@/types/domain/product';
import ProductCard from './product-card';
interface ProductListProps {
products: ProductWithWishlist[];
title?: string;
totalElements?: number;
productDetailFrom?: string;
showWishlistButton?: boolean;
}
export function ProductList({
products,
totalElements,
productDetailFrom,
showWishlistButton = false,
}: ProductListProps) {
const count = totalElements ?? products.length;
return (
<div className="mx-auto min-h-screen max-w-7xl bg-white">
<main className="p-4">
<div className="mb-4 flex items-center justify-between">
<span className="text-sm text-gray-500">
총 <b className="text-black">{count}</b>개
</span>
</div>
{products.length === 0 ? (
<div className="flex h-60 items-center justify-center text-gray-500">
해당 카테고리에 등록된 상품이 없습니다.
</div>
) : (
<div className="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 lg:grid-cols-4">
{products.map((product) => (
<ProductCard
key={product.id}
product={product}
detailFrom={productDetailFrom}
showWishlistButton={showWishlistButton}
/>
))}
</div>
)}
</main>
</div>
);
}