From e9cd13307f0095dc4edc5048752675d80c551564 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 6 Dec 2024 17:06:26 +0700
Subject: <iman> pengajuan tempo

---
 src/pages/pengajuan-tempo/index.jsx | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

(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 25db0c4b..271914c3 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -14,19 +14,24 @@ const PagePengajuanTempo = dynamic(() =>
 
 export default function TrackingOrder() {
   const auth = getAuth();
+  console.log('auth', auth);
   const router = useRouter();
   const [isLoading, setIsLoading] = useState(true); // Set default isLoading to true
 
   useEffect(() => {
-    if (!auth) return; // Prevent unnecessary processing if auth is not ready
+    // if (!auth) return; // Prevent unnecessary processing if auth is not ready
 
-    if (auth.tempoProgres === 'review') {
-      router.push('/pengajuan-tempo/review');
-    } else if (!auth.parentId) {
-      router.push('/pengajuan-tempo/switch-account');
-    } else if (!auth) {
+    if (!auth) {
       const nextUrl = encodeURIComponent(router.asPath);
       router.push(`/login?next=${nextUrl}`);
+    } else if (!auth.parentId) {
+      router.push('/pengajuan-tempo/switch-account');
+    } else if (auth.tempoProgres === 'review') {
+      router.push('/pengajuan-tempo/review');
+    } else if (auth.tempoProgres === 'approve') {
+      router.push('/pengajuan-tempo/approve');
+    } else if (auth.tempoProgres === 'rejected') {
+      router.push('/pengajuan-tempo/rejected');
     } else {
       setIsLoading(false); // Set isLoading to false only when routing is not required
     }
-- 
cgit v1.2.3

