From 910b0eb1f7b8721db995094e49da7ed67b995146 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 28 Feb 2024 11:23:36 +0700
Subject: Add id on flashsale section

---
 src/lib/flashSale/components/FlashSale.jsx | 64 ++++++++++++++++--------------
 1 file changed, 34 insertions(+), 30 deletions(-)

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

diff --git a/src/lib/flashSale/components/FlashSale.jsx b/src/lib/flashSale/components/FlashSale.jsx
index 3d5c4e0e..1a15ba8d 100644
--- a/src/lib/flashSale/components/FlashSale.jsx
+++ b/src/lib/flashSale/components/FlashSale.jsx
@@ -1,35 +1,39 @@
-import { useEffect, useState } from 'react'
-import flashSaleApi from '../api/flashSaleApi'
-import Image from 'next/image'
-import CountDown from '@/core/components/elements/CountDown/CountDown'
-import productSearchApi from '@/lib/product/api/productSearchApi'
-import ProductSlider from '@/lib/product/components/ProductSlider'
-import { FlashSaleSkeleton } from '../skeleton/FlashSaleSkeleton'
+import Image from 'next/image';
+import { useEffect, useState } from 'react';
+
+import CountDown from '@/core/components/elements/CountDown/CountDown';
+import productSearchApi from '@/lib/product/api/productSearchApi';
+import ProductSlider from '@/lib/product/components/ProductSlider';
+
+import flashSaleApi from '../api/flashSaleApi';
+import { FlashSaleSkeleton } from '../skeleton/FlashSaleSkeleton';
 
 const FlashSale = () => {
-  const [flashSales, setFlashSales] = useState(null)
-  const [isLoading, setIsLoading] = useState(true)
+  const [flashSales, setFlashSales] = useState(null);
+  const [isLoading, setIsLoading] = useState(true);
 
   useEffect(() => {
     const loadFlashSales = async () => {
-      const dataFlashSales = await flashSaleApi()
-      setFlashSales(dataFlashSales)
-      setIsLoading(false)
-    }
-    loadFlashSales()
-  }, [])
+      const dataFlashSales = await flashSaleApi();
+      setFlashSales(dataFlashSales);
+      setIsLoading(false);
+    };
+    loadFlashSales();
+  }, []);
 
   if (isLoading) {
-    return <FlashSaleSkeleton />
+    return <FlashSaleSkeleton />;
   }
 
   return (
     flashSales?.length > 0 && (
-      <div className='px-4 sm:px-0 grid grid-cols-1 gap-y-8'>
+      <div className='px-4 sm:px-0 grid grid-cols-1 gap-y-8' id='flashsale'>
         {flashSales.map((flashSale, index) => (
           <div key={index}>
             <div className='flex gap-x-3 mb-4 justify-between sm:justify-start'>
-              <div className='font-medium sm:text-h-lg mt-1.5'>{flashSale.name}</div>
+              <div className='font-medium sm:text-h-lg mt-1.5'>
+                {flashSale.name}
+              </div>
               <CountDown initialTime={flashSale.duration} />
             </div>
 
@@ -54,24 +58,24 @@ const FlashSale = () => {
         ))}
       </div>
     )
-  )
-}
+  );
+};
 
 const FlashSaleProduct = ({ flashSaleId }) => {
-  const [products, setProducts] = useState(null)
+  const [products, setProducts] = useState(null);
 
   useEffect(() => {
     const loadProducts = async () => {
       const dataProducts = await productSearchApi({
         query: `fq=flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale-price-asc`,
-        operation: 'AND'
-      })
-      setProducts(dataProducts.response)
-    }
-    loadProducts()
-  }, [flashSaleId])
+        operation: 'AND',
+      });
+      setProducts(dataProducts.response);
+    };
+    loadProducts();
+  }, [flashSaleId]);
 
-  return <ProductSlider products={products} />
-}
+  return <ProductSlider products={products} />;
+};
 
-export default FlashSale
+export default FlashSale;
-- 
cgit v1.2.3

