summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-10-19 16:51:37 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-10-19 16:51:37 +0700
commitbf33b9a9493aeab84e72647fad384bed43feabd5 (patch)
tree54c8432bf9b1ec21648c6fae9faf94066c96987f
parent0a88ef1da1c04f4d40c0133edb7d27701c7a9746 (diff)
Fix set lowest price on product page
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx16
1 files changed, 2 insertions, 14 deletions
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 () => {