summaryrefslogtreecommitdiff
path: root/src/lib/product/components/Product/ProductDesktop.jsx
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-10-21 10:06:54 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-10-21 10:06:54 +0700
commita001da95b9c03167656aec8a573cf60c12164b3f (patch)
tree54c8432bf9b1ec21648c6fae9faf94066c96987f /src/lib/product/components/Product/ProductDesktop.jsx
parent5c1f114b9e9feb256a49bfd60ed60c72823bca7c (diff)
parentbf33b9a9493aeab84e72647fad384bed43feabd5 (diff)
Merge branch 'master' into refactor/all
Diffstat (limited to 'src/lib/product/components/Product/ProductDesktop.jsx')
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 701750b2..a8cca416 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -25,6 +25,7 @@ import { useProductCartContext } from '@/contexts/ProductCartContext'
import { Box, Skeleton, Tooltip } from '@chakra-ui/react'
import { Info } from 'lucide-react'
import Breadcrumb from './Breadcrumb'
+import { sellingProductFormat } from '@/core/utils/formatValue'
const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
const router = useRouter()
@@ -44,21 +45,9 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
const { setRefreshCart, refreshCart } = useProductCartContext()
- const getLowestPrice = useCallback(() => {
- const prices = product.variants.map((variant) => ({
- price: variant.price,
- isFlashsale: variant.isFlashsale
- }))
- const lowest = prices.reduce((lowest, price) => {
- return price.price < lowest.price ? price : lowest
- }, prices[0])
- return lowest
- }, [product])
-
useEffect(() => {
- const lowest = getLowestPrice()
- setLowestPrice(lowest)
- }, [getLowestPrice])
+ setLowestPrice({ price: product?.lowestPrice })
+ }, [product])
useEffect(() => {
const getBackgound = async () => {
@@ -418,7 +407,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
</div>
</div>
- <div className='w-[25%]'>
+ <div className='w-[30%]'>
{product.variants.length > 1 && product.lowestPrice.priceDiscount > 0 && (
<div className='text-gray_r-12/80'>Harga mulai dari: </div>
)}
@@ -447,7 +436,11 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
)}
</div>
)} */}
-
+ {product?.qtySold > 0 && (
+ <div className='text-gray_r-9'>
+ {sellingProductFormat(product?.qtySold) + ' Terjual'}
+ </div>
+ )}
{lowestPrice?.isFlashsale && lowestPrice?.price.discountPercentage > 0 ? (
<>
<div className='flex gap-x-1 items-center mt-2'>
@@ -632,7 +625,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
rel='noopener noreferrer'
target='_blank'
>
- Call for price
+ Call for Inquiry
</a>
)}
</div>