summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-04-24 15:16:10 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-04-24 15:16:10 +0700
commitd9dd7fd69d2f895f8e503f8d6becd4be3af18b15 (patch)
tree58b4f1f97b9c43e24697137ef73553af922d4518
parent81abbbabd11df17b5fe795e725f5841273fbf125 (diff)
Remove session storage
-rw-r--r--src-migrate/modules/popup-information/index.tsx29
1 files changed, 7 insertions, 22 deletions
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'