From 23d6791006c3179bb3cbccef13f6d6a2a4f39c93 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Wed, 4 Dec 2024 12:05:23 +0700
Subject: update get popup information

---
 src-migrate/modules/popup-information/index.tsx | 27 ++++++++++---------------
 1 file changed, 11 insertions(+), 16 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 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;
-- 
cgit v1.2.3

