import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; import Image from 'next/image'; import Link from 'next/link'; import { Modal } from '~/components/ui/modal'; import { getAuth } from '~/libs/auth'; import dynamic from 'next/dynamic'; const PagePopupInformation = () => { const router = useRouter(); const isHomePage = router.pathname === '/'; const auth = getAuth(); const [active, setActive] = useState(false); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const getData = async () => { const res = await fetch(`/api/hero-banner?type=popup-banner`); const { data } = await res.json(); if (data) { setData(data); } setLoading(false); }; if (isHomePage && !auth) { setActive(true); getData(); } }, [isHomePage, auth]); return (
{data && !loading && ( setActive(false)} mode='desktop' >
setActive(false)} > {data[0]?.name}
)}
); }; export default PagePopupInformation;