From d9dd7fd69d2f895f8e503f8d6becd4be3af18b15 Mon Sep 17 00:00:00 2001
From: Miqdad <ahmadmiqdad27@gmail.com>
Date: Thu, 24 Apr 2025 15:16:10 +0700
Subject: Remove session storage

---
 src-migrate/modules/popup-information/index.tsx | 29 ++++++-------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

(limited to 'src-migrate/modules/popup-information/index.tsx')

diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx
index 5c3bc8fa..68e0805b 100644
--- a/src-migrate/modules/popup-information/index.tsx
+++ b/src-migrate/modules/popup-information/index.tsx
@@ -10,21 +10,11 @@ import dynamic from 'next/dynamic';
 const PagePopupInformation = () => {
   const router = useRouter();
   const isHomePage = router.pathname === '/';
-  // Updated to match your URL structure with /shop/product/
   const isProductDetail = router.pathname.includes('/shop/product/');
   const auth = getAuth();
   const [active, setActive] = useState<boolean>(false);
   const [data, setData] = useState<any>(null);
   const [loading, setLoading] = useState(true);
-  const [hasClosedPopup, setHasClosedPopup] = useState<boolean>(false);
-
-  useEffect(() => {
-    // Check if user has closed the popup in this session
-    const popupClosed = sessionStorage.getItem('popupClosed');
-    if (popupClosed) {
-      setHasClosedPopup(true);
-    }
-  }, []);
 
   useEffect(() => {
     const getData = async () => {
@@ -36,29 +26,24 @@ const PagePopupInformation = () => {
       setLoading(false);
     };
 
-    // Show popup if user is on homepage OR product detail page AND not authenticated AND hasn't closed popup
-    if ((isHomePage || isProductDetail) && !auth && !hasClosedPopup) {
+    if ((isHomePage || isProductDetail) && !auth) {
       setActive(true);
       getData();
     }
-  }, [isHomePage, isProductDetail, auth, hasClosedPopup]);
-
-  const handleClose = () => {
-    setActive(false);
-    // Set session storage to remember user closed the popup
-    sessionStorage.setItem('popupClosed', 'true');
-  };
-
+  }, [isHomePage, isProductDetail, auth]);
   return (
     <div className='group'>
       {data && !loading && (
         <Modal
           active={active}
           className='!w-fit !bg-transparent !border-none overflow-hidden'
-          close={handleClose}
+          close={() => setActive(false)}
           mode='desktop'
         >
-          <div className='w-[350px] md:w-[530px]' onClick={handleClose}>
+          <div
+            className='w-[350px] md:w-[530px]'
+            onClick={() => setActive(false)}
+          >
             <Link
               href={data[0].url === false ? '/' : data[0].url}
               aria-label='popup'
-- 
cgit v1.2.3

