From 6bbf1dbd94355f34f58f4b72f134f3dbeac776aa Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 23 Nov 2024 11:55:59 +0700
Subject: <iman> update tempo

---
 src/pages/pengajuan-tempo/index.jsx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'src/pages/pengajuan-tempo/index.jsx')

diff --git a/src/pages/pengajuan-tempo/index.jsx b/src/pages/pengajuan-tempo/index.jsx
index 23d7aaba..9f772ddd 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -4,11 +4,31 @@ import SimpleFooter from '@/core/components/elements/Footer/SimpleFooter';
 import BasicLayout from '@/core/components/layouts/BasicLayout';
 import DesktopView from '@/core/components/views/DesktopView';
 import MobileView from '@/core/components/views/MobileView';
+import { getAuth } from '~/libs/auth';
+import { useRouter } from 'next/router';
+import { useEffect } from 'react';
+
 const PagePengajuanTempo = dynamic(() =>
   import('@/lib/pengajuan-tempo/component/PengajuanTempo')
 );
 
 export default function TrackingOrder() {
+  const auth = getAuth();
+  const router = useRouter();
+
+  useEffect(() => {
+    if (!auth) {
+      const nextUrl = encodeURIComponent(router.asPath);
+      router.push(`/login?next=${nextUrl}`);
+    } else if (!auth?.parentId) {
+      router.push('/pengajuan-tempo/switch-account');
+    }
+  }, [auth, router]);
+
+  if (!auth?.parentId) {
+    return null;
+  }
+
   return (
     <>
       <Seo title='Pengajuan Tempo - Indoteknik.com' />
-- 
cgit v1.2.3

