summaryrefslogtreecommitdiff
path: root/src-migrate
diff options
context:
space:
mode:
authortrisusilo <tri.susilo@altama.co.id>2024-12-04 05:05:58 +0000
committertrisusilo <tri.susilo@altama.co.id>2024-12-04 05:05:58 +0000
commit21e60f62109b04e5fd6deaedbf9beaa192fa18bb (patch)
treed0e2e27b3e192a55a1f79630b8aa926c4a578878 /src-migrate
parent3c8390485d97df88d43728828d8fe816132af793 (diff)
parent23d6791006c3179bb3cbccef13f6d6a2a4f39c93 (diff)
Merged in CR/optimize_performance_2 (pull request #393)
update get popup information
Diffstat (limited to 'src-migrate')
-rw-r--r--src-migrate/modules/popup-information/index.tsx27
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;