From 0de043b180c1529b2d57d900523eece703e543a2 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 31 Mar 2023 16:39:25 +0700 Subject: cart, product --- src/lib/product/components/ProductCard.jsx | 99 +++++++++--------------------- 1 file changed, 29 insertions(+), 70 deletions(-) (limited to 'src/lib/product/components/ProductCard.jsx') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index e48ab88a..df709394 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -2,9 +2,6 @@ import Image from '@/core/components/elements/Image/Image' import Link from '@/core/components/elements/Link/Link' import currencyFormat from '@/core/utils/currencyFormat' import { createSlug } from '@/core/utils/slug' -import useProductPrice from '../hooks/useProductPrice' -import { LazyLoadComponent } from 'react-lazy-load-image-component' -import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton' const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { @@ -48,9 +45,23 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { > {product?.name} - - - + {product?.lowestPrice.discountPercentage > 0 && ( +
+
+ {currencyFormat(product.lowestPrice.price)} +
+
{product?.lowestPrice.discountPercentage}%
+
+ )} + +
+ {product?.lowestPrice.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice.priceDiscount) + ) : ( + Call for price + )} +
+ {product?.stockTotal > 0 && (
Ready Stock
@@ -106,83 +117,31 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {product?.name} - - - - {product?.stockTotal > 0 && ( -
-
Ready Stock
-
{product?.stockTotal > 5 ? '> 5' : '< 5'}
-
- )} -
- - ) - } -} - -const ProductCardPrice = ({ variant, id }) => { - const { productPrice } = useProductPrice({ id }) - - if (productPrice.isLoading) return - - if (variant == 'vertical') { - return ( - productPrice.isFetched && ( - <> - {productPrice?.data?.discount > 0 && ( + {product?.lowestPrice?.discountPercentage > 0 && (
-
- {currencyFormat( - productPrice?.data?.priceStartFrom || productPrice?.data?.priceExclude - )} +
{product?.lowestPrice?.discountPercentage}%
+
+ {currencyFormat(product?.lowestPrice?.price)}
-
{productPrice?.data?.discount}%
)}
- {productPrice?.data?.priceExcludeAfterDiscount > 0 ? ( - currencyFormat( - productPrice?.data?.priceDiscStartFrom || - productPrice?.data?.priceExcludeAfterDiscount - ) + {product?.lowestPrice?.priceDiscount > 0 ? ( + currencyFormat(product?.lowestPrice?.priceDiscount) ) : ( Call for price )}
- - ) - ) - } - if (variant == 'horizontal') { - return ( - productPrice.isFetched && ( - <> - {productPrice?.data?.discount > 0 && ( -
-
{productPrice?.data?.discount}%
-
- {currencyFormat( - productPrice?.data?.priceStartFrom || productPrice?.data?.priceExclude - )} -
+ {product?.stockTotal > 0 && ( +
+
Ready Stock
+
{product?.stockTotal > 5 ? '> 5' : '< 5'}
)} - -
- {productPrice?.data?.priceExcludeAfterDiscount > 0 ? ( - currencyFormat( - productPrice?.data?.priceDiscStartFrom || - productPrice?.data?.priceExcludeAfterDiscount - ) - ) : ( - Call for price - )} -
- - ) +
+
) } } -- cgit v1.2.3