summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-03-30 13:23:33 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-03-30 13:23:33 +0700
commitf23d32a4b8402904e8daa7b906c03a64104ed253 (patch)
tree2f21cba42cef6d3d654defc937fdc9901e864d7e /src
parent44d0de6d483a762f7967f4fadf71b210aaab3ba5 (diff)
product desktop variant
Diffstat (limited to 'src')
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 0866bffa..c7554242 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -8,7 +8,6 @@ import LazyLoad from 'react-lazy-load'
import ProductSimilar from '../ProductSimilar'
import { toast } from 'react-hot-toast'
import { updateItemCart } from '@/core/utils/cart'
-import useVariantPrice from '@/lib/variant/hooks/useVariantPrice'
import useProductPrice from '../../hooks/useProductPrice'
import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton'
import { useRouter } from 'next/router'
@@ -193,7 +192,23 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
<td>{variant.code}</td>
<td>{variant.attributes.join(', ') || '-'}</td>
<td>
- <VariantPrice id={variant.id} />
+ {variant.price.discountPercentage > 0 && variant.price.priceDiscount > 0 && (
+ <>
+ <div className='line-through text-caption-1 text-gray_r-11 mb-1'>
+ {currencyFormat(variant.price.price)}
+ </div>{' '}
+ </>
+ )}
+ <div>
+ {variant.price.priceDiscount > 0 ? (
+ currencyFormat(variant.price.priceDiscount)
+ ) : (
+ <a href='https://wa.me/' className='text-red_r-11'>
+ Call for price
+ </a>
+ )}
+ </div>
+ {/* <VariantPrice id={variant.id} /> */}
</td>
<td>
<input
@@ -269,33 +284,6 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
)
}
-const VariantPrice = ({ id }) => {
- const { variantPrice } = useVariantPrice({ id })
-
- if (variantPrice.isLoading) return <PriceSkeleton />
-
- return (
- <>
- {variantPrice?.data?.discount > 0 && variantPrice?.data?.priceExcludeAfterDiscount > 0 && (
- <>
- <div className='line-through text-caption-1 text-gray_r-11 mb-1'>
- {currencyFormat(variantPrice?.data?.priceExclude)}
- </div>{' '}
- </>
- )}
- <div>
- {variantPrice?.data?.priceExcludeAfterDiscount > 0 ? (
- currencyFormat(variantPrice?.data?.priceExcludeAfterDiscount)
- ) : (
- <a href='https://wa.me/' className='text-red_r-11'>
- Call for price
- </a>
- )}
- </div>
- </>
- )
-}
-
const informationTabOptions = [
{ value: 'description', label: 'Deskripsi' },
{ value: 'information', label: 'Info Penting' }