From bf33b9a9493aeab84e72647fad384bed43feabd5 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Thu, 19 Oct 2023 16:51:37 +0700
Subject: Fix set lowest price on product page

---
 src/lib/product/components/Product/ProductDesktop.jsx | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

(limited to 'src/lib/product/components/Product/ProductDesktop.jsx')

diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 11c34009..a8cca416 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -45,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 () => {
-- 
cgit v1.2.3

