From b02510e26e7e9bc292a1779bd23801014b94aad4 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 26 Apr 2023 17:23:52 +0700
Subject: flash sale and countdown

---
 src/lib/flashSale/components/FlashSale.jsx | 37 ++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 src/lib/flashSale/components/FlashSale.jsx

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

diff --git a/src/lib/flashSale/components/FlashSale.jsx b/src/lib/flashSale/components/FlashSale.jsx
new file mode 100644
index 00000000..0167dc57
--- /dev/null
+++ b/src/lib/flashSale/components/FlashSale.jsx
@@ -0,0 +1,37 @@
+import { useEffect, useState } from 'react'
+import flashSaleApi from '../api/flashSaleApi'
+import Image from '@/core/components/elements/Image/Image'
+import CountDown from '@/core/components/elements/CountDown/CountDown'
+
+const FlashSale = () => {
+  const [flashSales, setFlashSales] = useState(null)
+
+  useEffect(() => {
+    const loadFlashSales = async () => {
+      const dataFlashSales = await flashSaleApi()
+      setFlashSales(dataFlashSales)
+    }
+    loadFlashSales()
+  }, [])
+
+  return flashSales?.length > 0 && (
+    <div className='px-4 sm:px-0'>
+      
+      {flashSales.map((flashSale, index) => (
+        <div key={index}>
+          <div className='font-medium sm:text-h-lg mb-4'>{flashSale.name}</div>
+
+          <div className='relative'>
+            <div className='absolute top-0 left-0 p-4'>
+              <CountDown initialTime={flashSale.duration} />
+            </div>
+            <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded' />
+          </div>
+
+        </div>
+      ))}
+    </div>
+  )
+}
+
+export default FlashSale
-- 
cgit v1.2.3


From 5d8ad078bdc735e708654e278b226868dc3bc403 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Thu, 27 Apr 2023 16:45:05 +0700
Subject: flash sale mapping, mobile flash sale

---
 src/lib/flashSale/components/FlashSale.jsx | 48 +++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 14 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 0167dc57..91248c12 100644
--- a/src/lib/flashSale/components/FlashSale.jsx
+++ b/src/lib/flashSale/components/FlashSale.jsx
@@ -2,6 +2,8 @@ import { useEffect, useState } from 'react'
 import flashSaleApi from '../api/flashSaleApi'
 import Image from '@/core/components/elements/Image/Image'
 import CountDown from '@/core/components/elements/CountDown/CountDown'
+import productSearchApi from '@/lib/product/api/productSearchApi'
+import ProductSlider from '@/lib/product/components/ProductSlider'
 
 const FlashSale = () => {
   const [flashSales, setFlashSales] = useState(null)
@@ -14,24 +16,42 @@ const FlashSale = () => {
     loadFlashSales()
   }, [])
 
-  return flashSales?.length > 0 && (
-    <div className='px-4 sm:px-0'>
-      
-      {flashSales.map((flashSale, index) => (
-        <div key={index}>
-          <div className='font-medium sm:text-h-lg mb-4'>{flashSale.name}</div>
-
-          <div className='relative'>
-            <div className='absolute top-0 left-0 p-4'>
+  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='font-medium sm:text-h-lg mt-1.5'>{flashSale.name}</div>
               <CountDown initialTime={flashSale.duration} />
             </div>
-            <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded' />
-          </div>
 
-        </div>
-      ))}
-    </div>
+            <div className='relative'>
+              <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded mb-4' />
+              <FlashSaleProduct flashSaleId={flashSale.pricelistId} />
+            </div>
+          </div>
+        ))}
+      </div>
+    )
   )
 }
 
+const FlashSaleProduct = ({ flashSaleId }) => {
+  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`,
+        operation: 'AND'
+      })
+      setProducts(dataProducts.response)
+    }
+    loadProducts()
+  }, [flashSaleId])
+
+  return <ProductSlider products={products} />
+}
+
 export default FlashSale
-- 
cgit v1.2.3


From a16ce4541aa640fea26ecbe7a88271bc9efda479 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 28 Apr 2023 09:18:05 +0700
Subject: flash sale mobile banner

---
 src/lib/flashSale/components/FlashSale.jsx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(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 91248c12..b580f787 100644
--- a/src/lib/flashSale/components/FlashSale.jsx
+++ b/src/lib/flashSale/components/FlashSale.jsx
@@ -27,7 +27,8 @@ const FlashSale = () => {
             </div>
 
             <div className='relative'>
-              <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded mb-4' />
+              <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded mb-4 hidden' />
+              <Image src={flashSale.bannerMobile} alt={flashSale.name} className='w-full rounded mb-4 sm:hidden' />
               <FlashSaleProduct flashSaleId={flashSale.pricelistId} />
             </div>
           </div>
-- 
cgit v1.2.3


From 8b42783cd838b1da78d3d192860861ada5d13514 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 28 Apr 2023 10:08:34 +0700
Subject: fix banner

---
 src/lib/flashSale/components/FlashSale.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 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 b580f787..f0f95c8b 100644
--- a/src/lib/flashSale/components/FlashSale.jsx
+++ b/src/lib/flashSale/components/FlashSale.jsx
@@ -27,8 +27,8 @@ const FlashSale = () => {
             </div>
 
             <div className='relative'>
-              <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded mb-4 hidden' />
-              <Image src={flashSale.bannerMobile} alt={flashSale.name} className='w-full rounded mb-4 sm:hidden' />
+              <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded mb-4 hidden sm:block' />
+              <Image src={flashSale.bannerMobile} alt={flashSale.name} className='w-full rounded mb-4 block sm:hidden' />
               <FlashSaleProduct flashSaleId={flashSale.pricelistId} />
             </div>
           </div>
-- 
cgit v1.2.3


From b4abdb00ef83aa824e8a05d5b75df48adb7b9629 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 3 May 2023 10:38:52 +0700
Subject: semi dynamic page

---
 src/lib/flashSale/components/FlashSale.jsx | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 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 f0f95c8b..e4a4a25c 100644
--- a/src/lib/flashSale/components/FlashSale.jsx
+++ b/src/lib/flashSale/components/FlashSale.jsx
@@ -27,8 +27,16 @@ const FlashSale = () => {
             </div>
 
             <div className='relative'>
-              <Image src={flashSale.banner} alt={flashSale.name} className='w-full rounded mb-4 hidden sm:block' />
-              <Image src={flashSale.bannerMobile} alt={flashSale.name} className='w-full rounded mb-4 block sm:hidden' />
+              <Image
+                src={flashSale.banner}
+                alt={flashSale.name}
+                className='w-full rounded mb-4 hidden sm:block'
+              />
+              <Image
+                src={flashSale.bannerMobile}
+                alt={flashSale.name}
+                className='w-full rounded mb-4 block sm:hidden'
+              />
               <FlashSaleProduct flashSaleId={flashSale.pricelistId} />
             </div>
           </div>
-- 
cgit v1.2.3

