diff options
Diffstat (limited to 'src-migrate/modules/popup-information')
| -rw-r--r-- | src-migrate/modules/popup-information/index.tsx | 29 |
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' |
