From 95322b2c473da6160af0e3d685ec3d5eb924df05 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 21 Feb 2025 15:02:27 +0700
Subject: <iman> update code /my/tempo

---
 src/pages/my/tempo/index.jsx | 54 +++++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

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

diff --git a/src/pages/my/tempo/index.jsx b/src/pages/my/tempo/index.jsx
index 5fb9deba..6ca5c718 100644
--- a/src/pages/my/tempo/index.jsx
+++ b/src/pages/my/tempo/index.jsx
@@ -13,39 +13,41 @@ export default function MyTempo() {
   const router = useRouter();
   const [isLoading, setIsLoading] = useState(true);
   useEffect(() => {
+    setIsLoading(true);
     if (!auth) {
       const nextUrl = encodeURIComponent(router.asPath);
       router.push(`/login?next=${nextUrl}`);
-    }
-    // else if (
-    //   (auth.tempoProgres === '' || auth.tempoProgres === 'rejected') &&
-    //   !auth.company
-    // ) {
-    //   router.push('/pengajuan-tempo');
-    // }
-    else {
+    } else {
+      if (
+        !auth.partnerTempo &&
+        (!auth.partnerTempo || auth.tempoProgres === 'review')
+      ) {
+        setIsLoading(true);
+        router.push('/pengajuan-tempo');
+      }
       setIsLoading(false);
     }
   }, [auth]);
 
-  if (isLoading || !auth) {
-    return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
-  }
-  return (
-    <IsAuth>
-      <Seo title='Tempo - Indoteknik.com' />
+  if (isLoading && !auth) {
+    return null;
+  } else {
+    return (
+      <IsAuth>
+        <Seo title='Tempo - Indoteknik.com' />
 
-      <MobileView>
-        <AppLayout title='Pembayaran Tempo'>
-          <InvoicesComponent />
-        </AppLayout>
-      </MobileView>
+        <MobileView>
+          <AppLayout title='Pembayaran Tempo'>
+            <InvoicesComponent />
+          </AppLayout>
+        </MobileView>
 
-      <DesktopView>
-        <BasicLayout>
-          <InvoicesComponent />
-        </BasicLayout>
-      </DesktopView>
-    </IsAuth>
-  );
+        <DesktopView>
+          <BasicLayout>
+            <InvoicesComponent />
+          </BasicLayout>
+        </DesktopView>
+      </IsAuth>
+    );
+  }
 }
-- 
cgit v1.2.3

