From 0a548e87febeab3d25ba7d5270b73b757f130b26 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 26 Apr 2023 11:39:23 +0700
Subject: fix bug on update qty cart and create quotation page

---
 src/lib/cart/components/Cart.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/lib/cart/components/Cart.jsx')

diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx
index d0685fe3..b0de5168 100644
--- a/src/lib/cart/components/Cart.jsx
+++ b/src/lib/cart/components/Cart.jsx
@@ -72,7 +72,7 @@ const Cart = () => {
   }, [products])
 
   useEffect(() => {
-    const LoadProductSImilar = async () => {
+    const LoadProductSimilar = async () => {
       const randProductIndex = Math.floor(Math.random() * products.length)
       const productLoad = await productSearchApi({
         query: `q=${products?.[randProductIndex].parent.name}&limit=10`
@@ -80,8 +80,8 @@ const Cart = () => {
 
       setProductRecomendation(productLoad)
     }
-    if (products?.length > 0) LoadProductSImilar()
-  }, [products])
+    if (products?.length > 0 && !productRecomendation) LoadProductSimilar()
+  }, [products, productRecomendation])
 
   const updateQuantity = (value, productId, operation = '') => {
     let productIndex = products.findIndex((product) => product.id == productId)
-- 
cgit v1.2.3

