forked from IT-Cotato/12th-OnGil-FE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-card.tsx
More file actions
58 lines (54 loc) · 1.87 KB
/
product-card.tsx
File metadata and controls
58 lines (54 loc) · 1.87 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
49
50
51
52
53
54
55
56
57
58
import Link from 'next/link';
import { ProductWithWishlist } from '@/types/domain/product';
import { WishlistButton } from './wishlist-button';
// 카드 UI 컴포넌트, 클릭 시 상세 페이지로 이동함.
interface ProductCardProps {
product: ProductWithWishlist;
detailFrom?: string;
showWishlistButton?: boolean;
}
export default function ProductCard({
product,
detailFrom,
showWishlistButton = false,
}: ProductCardProps) {
const href = detailFrom
? `/product/${product.id}?from=${encodeURIComponent(detailFrom)}`
: `/product/${product.id}`;
return (
<Link href={href} className="block">
<div className="font-pretendard flex w-41 flex-col gap-1">
<div className="relative">
<img
src={product.thumbnailImageUrl}
alt={product.name}
width={164}
height={170}
className="h-[170px] w-[164px] object-cover"
/>
{showWishlistButton && (
<WishlistButton
productId={product.id}
initialIsLiked={product.isLiked || false}
initialWishlistId={product.wishlistId}
className="absolute top-2 right-2"
/>
)}
</div>
<span className="font-extrabold">{product.brandName}</span>
<span className="line-clamp-2 h-14 w-full overflow-hidden text-lg font-medium text-ellipsis">
{product.name}
</span>
<div className="flex w-full gap-2 text-xl font-bold">
{product.discountRate !== undefined && product.discountRate > 0 && (
<span className="text-ongil-teal">{product.discountRate}%</span>
)}
<span>{product.finalPrice.toLocaleString()}</span>
</div>
<span className="text-xs text-gray-500">
후기 {product.reviewCount.toLocaleString()}개
</span>
</div>
</Link>
);
}