diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-12-04 12:05:23 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-12-04 12:05:23 +0700 |
| commit | 23d6791006c3179bb3cbccef13f6d6a2a4f39c93 (patch) | |
| tree | d0e2e27b3e192a55a1f79630b8aa926c4a578878 | |
| parent | 4c8d08def514cb441007c0bd2bc78e105e6d0153 (diff) | |
update get popup information
| -rw-r--r-- | src-migrate/modules/popup-information/index.tsx | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src-migrate/modules/popup-information/index.tsx b/src-migrate/modules/popup-information/index.tsx index 20afa902..5acdb068 100644 --- a/src-migrate/modules/popup-information/index.tsx +++ b/src-migrate/modules/popup-information/index.tsx @@ -6,25 +6,25 @@ import Link from 'next/link'; import { Modal } from '~/components/ui/modal'; import { getAuth } from '~/libs/auth'; -const PagePopupInformation = ({data} : {data: any[]}) => { +const PagePopupInformation = () => { const router = useRouter(); const isHomePage = router.pathname === '/'; const auth = getAuth(); const [active, setActive] = useState<boolean>(false); - // const [data, setData] = useState<any>(null); + const [data, setData] = useState<any>(null); useEffect(() => { - // const getData = async () => { - // const res = await fetch(`/api/hero-banner?type=popup-banner`); - // const { data } = await res.json(); - // if (data) { - // setData(data); - // } - // }; + const getData = async () => { + const res = await fetch(`/api/hero-banner?type=popup-banner`); + const { data } = await res.json(); + if (data) { + setData(data); + } + }; if (isHomePage && !auth) { setActive(true); - // getData(); + getData(); } }, [isHomePage, auth]); return ( @@ -46,6 +46,7 @@ const PagePopupInformation = ({data} : {data: any[]}) => { alt={data[0]?.name} width={1152} height={768} + loading='eager' sizes='(max-width: 768px) 100vw, 50vw' priority={true} /> @@ -56,11 +57,5 @@ const PagePopupInformation = ({data} : {data: any[]}) => { </div> ); }; -export async function getServerSideProps() { - const res = await fetch(`/api/hero-banner?type=popup-banner`); - const { data } = await res.json(); - return { props: { data } }; -} - export default PagePopupInformation; |
