From 7f5b0518474f702b68ca459e5cb531212504472d Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 3 Aug 2023 14:22:27 +0700
Subject: flash sale

---
 .../components/elements/CountDown/CountDown2.jsx   | 48 ++++++++++++++++++----
 1 file changed, 41 insertions(+), 7 deletions(-)

(limited to 'src/core/components/elements/CountDown/CountDown2.jsx')

diff --git a/src/core/components/elements/CountDown/CountDown2.jsx b/src/core/components/elements/CountDown/CountDown2.jsx
index 61503d17..5dafb790 100644
--- a/src/core/components/elements/CountDown/CountDown2.jsx
+++ b/src/core/components/elements/CountDown/CountDown2.jsx
@@ -1,7 +1,7 @@
 import { useEffect, useState } from 'react'
 
 const CountDown2 = ({ initialTime }) => {
-  const hours = Math.floor(initialTime / 3600)
+  /*const hours = Math.floor(initialTime / 3600)
   const minutes = Math.floor((initialTime % 3600) / 60)
   const seconds = initialTime % 60
 
@@ -25,24 +25,58 @@ const CountDown2 = ({ initialTime }) => {
       }
     }, 1000)
     return () => clearInterval(timer)
+  }, [timeLeft])*/
+  
+  const days = Math.floor(initialTime / 86400)
+  const hours = Math.floor((initialTime % 86400) / 3600)
+  const minutes = Math.floor((initialTime % 3600) / 60)
+  const seconds = initialTime % 60
+
+  const [timeLeft, setTimeLeft] = useState({
+    day: days,
+    hour: hours,
+    minute: minutes,
+    second: seconds
+  })
+
+  useEffect(() => {
+    const timer = setInterval(() => {
+      const totalSeconds =
+        timeLeft.day * 86400 + timeLeft.hour * 3600 + timeLeft.minute * 60 + timeLeft.second
+      const secondsLeft = totalSeconds - 1
+      if (secondsLeft < 0) {
+        clearInterval(timer)
+      } else {
+        const days = Math.floor(secondsLeft / 86400)
+        const hours = Math.floor((secondsLeft % 86400) / 3600)
+        const minutes = Math.floor((secondsLeft % 3600) / 60)
+        const seconds = secondsLeft % 60
+        setTimeLeft({ day: days, hour: hours, minute: minutes, second: seconds })
+      }
+    }, 1000)
+    return () => clearInterval(timer)
   }, [timeLeft])
 
+
   return (
     <div className='flex justify-between gap-x-2'>
       <div className='flex flex-col items-center'>
-        <span className='bg-red-200 border border-red-500 text-black font-sm w-10 h-8 flex items-center justify-center rounded'>
-          {timeLeft.hour.toString().padStart(2, '0')}
+        <span className='bg-yellow-400 border border-yellow-400 text-black font-sm w-10 h-7 flex items-center justify-center rounded-lg'>
+          {timeLeft.day.toString().padStart(2, '0')}
         </span>
+        <span className='text-xs text-white'>Hari</span>
       </div>
       <div className='flex flex-col items-center'>
-        <span className='bg-red-200 border border-red-500 text-black  font-sm w-10 h-8 flex items-center justify-center rounded'>
-          {timeLeft.minute.toString().padStart(2, '0')}
+        <span className='bg-yellow-400 border border-yellow-400 text-black  font-sm w-10 h-7 flex items-center justify-center rounded-lg'>
+          {timeLeft.hour.toString().padStart(2, '0')}
         </span>
+        <span className='text-xs text-white'>Jam</span>
       </div>
       <div className='flex flex-col items-center'>
-        <span className='bg-red-200 border border-red-500 text-black font-sm w-10 h-8 flex items-center justify-center rounded'>
-          {timeLeft.second.toString().padStart(2, '0')}
+        <span className='bg-yellow-400 border border-yellow-400 text-black font-sm w-10 h-7 flex items-center justify-center rounded-lg'>
+          {timeLeft.minute.toString().padStart(2, '0')}
         </span>
+        <span className='text-xs text-white'>Menit</span>
       </div>
     </div>
   )
-- 
cgit v1.2.3


From d9652e77733a24b329f8d849e700222f06c4331e Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 4 Aug 2023 13:24:58 +0700
Subject: add image backgournd

---
 src/core/components/elements/CountDown/CountDown2.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/core/components/elements/CountDown/CountDown2.jsx')

diff --git a/src/core/components/elements/CountDown/CountDown2.jsx b/src/core/components/elements/CountDown/CountDown2.jsx
index 5dafb790..e85a22cb 100644
--- a/src/core/components/elements/CountDown/CountDown2.jsx
+++ b/src/core/components/elements/CountDown/CountDown2.jsx
@@ -59,7 +59,7 @@ const CountDown2 = ({ initialTime }) => {
 
 
   return (
-    <div className='flex justify-between gap-x-2'>
+    <div className='flex justify-between gap-x-2 mt-18'>
       <div className='flex flex-col items-center'>
         <span className='bg-yellow-400 border border-yellow-400 text-black font-sm w-10 h-7 flex items-center justify-center rounded-lg'>
           {timeLeft.day.toString().padStart(2, '0')}
-- 
cgit v1.2.3

