From b22c0e52dc08083025330ef0a501e085cbf434df Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 16 Aug 2024 10:00:38 +0700
Subject: <iman> add button lihat semua

---
 src/lib/flashSale/components/FlashSaleNonDisplay.jsx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'src/lib/flashSale/components/FlashSaleNonDisplay.jsx')

diff --git a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx
index 3218ab35..0068c98d 100644
--- a/src/lib/flashSale/components/FlashSaleNonDisplay.jsx
+++ b/src/lib/flashSale/components/FlashSaleNonDisplay.jsx
@@ -7,33 +7,46 @@ import ProductSlider from '@/lib/product/components/ProductSlider';
 
 import flashSaleApi from '../api/flashSaleApi';
 import { FlashSaleSkeleton } from '../skeleton/FlashSaleSkeleton';
+import Link from 'next/link';
+import { useRouter } from 'next/router'
 
 const FlashSaleNonDisplay = () => {
   const [flashSales, setFlashSales] = useState(null);
   const [isLoading, setIsLoading] = useState(true);
+  const [pencarian, setPencarian] = useState('');
+  const router = useRouter()
 
   useEffect(() => {
     const loadFlashSales = async () => {
       const dataFlashSales = await flashSaleApi();
       setFlashSales(dataFlashSales);
+      setPencarian(`fq=-flashsale_id_i:${dataFlashSales[0]?.pricelistId}&fq=flashsale_price_f:[1 TO *]&orderBy=flashsale-discount-desc`)
       setIsLoading(false);
     };
     loadFlashSales();
   }, []);
 
+  const handleSubmit = () => {
+    router.push(`/shop/search?${pencarian}`)
+  }
+
   if (isLoading) {
     return <FlashSaleSkeleton />;
   }
+ 
 
   return (
     flashSales?.length > 0 && (
       <div className='px-4 sm:px-0 grid grid-cols-1 gap-y-8'>
         {flashSales.map((flashSale, index) => (
           <div key={index}>
-            <div className='flex gap-x-3 mb-4 justify-between sm:justify-start'>
+            <div className='flex items-center mb-4 justify-between '>
               <div className='font-medium sm:text-h-lg mt-1.5'>
                 Penawaran Terbatas
               </div>
+              <div onClick={handleSubmit} className='!text-red-500 font-semibold cursor-pointer'>
+                  Lihat Semua
+              </div>
             </div>
 
             <div className='relative'>
-- 
cgit v1.2.3

