diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-03-01 09:18:52 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-03-01 09:18:52 +0000 |
| commit | a7abbf4ddc70068620e9f44b74dc162ce2e16ee2 (patch) | |
| tree | 74f66253717515d364ce74bd8275015c1f829cbc /src2/components/products/ProductCard.js | |
| parent | 90e1edab9b6a8ccc09a49fed3addbec2cbc4e4c3 (diff) | |
| parent | a1b9b647a6c4bda1f5db63879639d44543f9557e (diff) | |
Merged in refactor (pull request #1)
Refactor
Diffstat (limited to 'src2/components/products/ProductCard.js')
| -rw-r--r-- | src2/components/products/ProductCard.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src2/components/products/ProductCard.js b/src2/components/products/ProductCard.js new file mode 100644 index 00000000..c79a4900 --- /dev/null +++ b/src2/components/products/ProductCard.js @@ -0,0 +1,69 @@ +import Link from "../elements/Link"; +import currencyFormat from "@/core/utils/currencyFormat"; +import { createSlug } from "@/core/utils/slug"; +import { ChevronRightIcon } from "@heroicons/react/20/solid"; +import Image from "../elements/Image"; + + +export default function ProductCard({ + data, + simpleProductTitleLine = false +}) { + let product = data; + return ( + <div className="product-card"> + <Link href={'/shop/product/' + createSlug(product.name, product.id)} className="block relative bg-white"> + <Image + src={product.image} + alt={product.name} + className="product-card__image" + /> + {product.variant_total > 1 ? ( + <div className="absolute bottom-2 left-2 badge-gray">{product.variant_total} Varian</div> + ) : ''} + </Link> + <div className="product-card__content"> + <div> + {typeof product.manufacture.name !== "undefined" ? ( + <Link href={'/shop/brands/' + createSlug(product.manufacture.name, product.manufacture.id)} className="product-card__brand">{product.manufacture.name}</Link> + ) : ( + <span className="product-card__brand">-</span> + )} + <Link href={'/shop/product/' + createSlug(product.name, product.id)} className={`product-card__title ${simpleProductTitleLine ? 'wrap-line-ellipsis-2' : '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 mb-1"> + <p className="text-caption-2 text-gray_r-11 line-through">{currencyFormat(product.lowest_price.price)}</p> + <span className="badge-solid-red">{product.lowest_price.discount_percentage}%</span> + </div> + ) : ''} + + {product.lowest_price.price_discount > 0 ? ( + <p className="text-caption-1 text-gray_r-12 font-bold"> + {currencyFormat(product.lowest_price.price_discount)} + </p> + ) : ( + <a + href="https://wa.me" + target="_blank" + rel="noreferrer" + className="flex items-center gap-x-1 text-caption-1" + > + Tanya Harga <ChevronRightIcon className="text-yellow_r-11 w-5 h-5" /> + </a> + )} + + {product.stock_total > 0 ? ( + <div className="flex gap-x-1 mt-2"> + <div className="badge-solid-red">Ready Stock</div> + <div className="badge-gray">{product.stock_total > 5 ? '> 5' : '< 5'}</div> + </div> + ) : ''} + </div> + </div> + </div> + ) +}
\ No newline at end of file |
