From 76e798e1266c1d888a97c6f866ae782dd6f0045f Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 19 Aug 2024 14:02:10 +0700
Subject: <iman> update position code

---
 src/lib/product/components/ProductSearch.jsx | 34 +++++++++++++++-------------
 1 file changed, 18 insertions(+), 16 deletions(-)

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

diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index 07398795..b799d533 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -52,6 +52,24 @@ const ProductSearch = ({
   const [orderBy, setOrderBy] = useState(router.query?.orderBy);
   if (defaultBrand) query.brand = defaultBrand.toLowerCase();
   const dataIdCategories = []
+
+  useEffect(() => {
+    const checkIfPenawaran = async () => {
+      if (router.asPath.includes('penawaran')) {
+        query = {
+          ...query,
+          fq: [
+            `-flashsale_id_i:${router.query.penawaran}`,
+            `flashsale_price_f:[1 TO *]`
+          ],
+          orderBy: 'flashsale-discount-desc'
+        };
+        setOrderBy('flashsale-discount-desc')
+      }
+    };
+    checkIfPenawaran();
+  }, [router]);
+  
   useEffect(() => {
     if(prefixUrl.includes('category')){
       const loadProduct = async () => {
@@ -142,22 +160,6 @@ const ProductSearch = ({
     }
   }, [prefixUrl,dataCategoriesProduct, query, finalQuery]);
 
-  useEffect(() => {
-    const checkIfPenawaran = async () => {
-      if (router.asPath.includes('penawaran')) {
-        query = {
-          ...query,
-          fq: [
-            `-flashsale_id_i:${router.query.penawaran}`,
-            `flashsale_price_f:[1 TO *]`
-          ],
-          orderBy: 'flashsale-discount-desc'
-        };
-        setOrderBy('flashsale-discount-desc')
-      }
-    };
-    checkIfPenawaran();
-  }, [router]);
 
   const { productSearch } = useProductSearch({
     query: queryFinal,
-- 
cgit v1.2.3

