From a20fd43f0cafe86444605c3bb8f2a998e1b9dbe6 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 19 Aug 2024 11:03:58 +0700
Subject: <iman> update link lihat semua non display voucher

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

(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 fb9017f4..09727e81 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -40,6 +40,24 @@ const ProductSearch = ({
   const [limit, setLimit] = useState(query?.limit || 30);
   const [orderBy, setOrderBy] = useState(router.query?.orderBy);
   if (defaultBrand) query.brand = defaultBrand.toLowerCase();
+
+  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: { ...query, q, limit, orderBy },
     operation: 'AND',
-- 
cgit v1.2.3

