blob: 23cc0665b616514854861f36bf84b70de9927d51 (
plain)
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
|
import Link from "next/link";
import currencyFormat from "../helpers/currencyFormat";
import { createSlug } from "../helpers/slug";
import { LazyLoadImage } from "react-lazy-load-image-component";
import 'react-lazy-load-image-component/src/effects/blur.css';
export default function ProductCard({ data }) {
let product = data;
return (
<div className="product-card">
<Link href={'/shop/product/' + createSlug(product.name, product.id)} className="block relative">
<LazyLoadImage effect="blur" src={product.image ? product.image : '/images/noimage.jpeg'} alt={product.name} className="product-card__image" />
{product.variant_total > 1 ? (
<div className="absolute bottom-2 left-2 badge-yellow">{product.variant_total} Varian</div>
) : ''}
</Link>
<div className="product-card__description">
<div>
{typeof product.manufacture.name !== "undefined" ? (
<a href={'/shop/brands/' + createSlug(product.manufacture.name, product.manufacture.id)} className="product-card__brand">{product.manufacture.name}</a>
) : (
<span className="product-card__brand">-</span>
)}
<Link href={'/shop/product/' + createSlug(product.name, product.id)} className="product-card__title wrap-line-ellipsis-3">
{product.name}
</Link>
</div>
<div className="mt-2">
{product.lowest_price.discount_percentage > 0 ? (
<div className="flex gap-x-1 items-center">
<span className="badge-yellow">{product.lowest_price.discount_percentage}%</span>
<p className="text-xs text-gray-800 line-through">{currencyFormat(product.lowest_price.price)}</p>
</div>
) : ''}
{product.lowest_price.price_discount > 0 ? (
<p className="text-sm text-gray-900 font-semibold">
{currencyFormat(product.lowest_price.price_discount)}
</p>
) : (
<a href="https://wa.me" className="py-2 rounded block text-sm border border-yellow-900 text-center">
Tanya Harga
</a>
)}
{product.stock_total > 0 ? (
<div className="badge-green mt-2">Ready Stock {product.stock_total > 5 ? '> 5' : '< 5'}</div>
) : ''}
</div>
</div>
</div>
)
}
|