diff options
Diffstat (limited to 'src/lib/product/components/Product/ProductDesktop.jsx')
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktop.jsx | 27 |
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> |
