From abcce110895d767a16fb961a65e7c78f9213ca0d Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 24 Oct 2024 17:11:32 +0700
Subject: <iman> update pengajuan tempo

---
 src/pages/pengajuan-tempo/index.jsx | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 src/pages/pengajuan-tempo/index.jsx

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

diff --git a/src/pages/pengajuan-tempo/index.jsx b/src/pages/pengajuan-tempo/index.jsx
new file mode 100644
index 00000000..23d7aaba
--- /dev/null
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -0,0 +1,29 @@
+import Seo from '@/core/components/Seo';
+import dynamic from 'next/dynamic';
+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';
+const PagePengajuanTempo = dynamic(() =>
+  import('@/lib/pengajuan-tempo/component/PengajuanTempo')
+);
+
+export default function TrackingOrder() {
+  return (
+    <>
+      <Seo title='Pengajuan Tempo - Indoteknik.com' />
+
+      <DesktopView>
+        <BasicLayout>
+          <PagePengajuanTempo />
+        </BasicLayout>
+      </DesktopView>
+
+      <MobileView>
+        <BasicLayout>
+          <PagePengajuanTempo />
+        </BasicLayout>
+      </MobileView>
+    </>
+  );
+}
-- 
cgit v1.2.3


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


From 9a49b8d84761781531cb417731cb9ef802f63541 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 4 Dec 2024 10:59:21 +0700
Subject: <iman> update pengajuan tempo

---
 src/pages/pengajuan-tempo/index.jsx | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 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 9f772ddd..25db0c4b 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -6,7 +6,7 @@ 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';
+import { useEffect, useState } from 'react';
 
 const PagePengajuanTempo = dynamic(() =>
   import('@/lib/pengajuan-tempo/component/PengajuanTempo')
@@ -15,30 +15,35 @@ const PagePengajuanTempo = dynamic(() =>
 export default function TrackingOrder() {
   const auth = getAuth();
   const router = useRouter();
+  const [isLoading, setIsLoading] = useState(true); // Set default isLoading to true
 
   useEffect(() => {
-    if (!auth) {
+    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) {
       const nextUrl = encodeURIComponent(router.asPath);
       router.push(`/login?next=${nextUrl}`);
-    } else if (!auth?.parentId) {
-      router.push('/pengajuan-tempo/switch-account');
+    } else {
+      setIsLoading(false); // Set isLoading to false only when routing is not required
     }
   }, [auth, router]);
 
-  if (!auth?.parentId) {
-    return null;
+  if (isLoading || !auth) {
+    return null; // Show nothing while loading or if auth is not ready
   }
 
   return (
     <>
       <Seo title='Pengajuan Tempo - Indoteknik.com' />
-
       <DesktopView>
         <BasicLayout>
           <PagePengajuanTempo />
         </BasicLayout>
       </DesktopView>
-
       <MobileView>
         <BasicLayout>
           <PagePengajuanTempo />
-- 
cgit v1.2.3


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


From f2451beed670dc697aa2026b2df6ad1ad1e90da2 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 9 Dec 2024 15:00:45 +0700
Subject: <iman> update pengajuan tempo

---
 src/pages/pengajuan-tempo/index.jsx | 44 ++++++++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 10 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 271914c3..f0681663 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -7,38 +7,62 @@ import MobileView from '@/core/components/views/MobileView';
 import { getAuth } from '~/libs/auth';
 import { useRouter } from 'next/router';
 import { useEffect, useState } from 'react';
+import odooApi from '@/core/api/odooApi';
 
 const PagePengajuanTempo = dynamic(() =>
   import('@/lib/pengajuan-tempo/component/PengajuanTempo')
 );
 
 export default function TrackingOrder() {
+  const [tempo, setTempo] = useState(null);
+  const [isLoading, setIsLoading] = useState(true);
   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
+    const loadTempo = async () => {
+      try {
+        if (auth?.partnerId) {
+          const dataTempo = await odooApi(
+            'GET',
+            `/api/v1/check/${auth.partnerId}/tempo`
+          );
+          setTempo(dataTempo);
+        }
+      } catch (error) {
+        console.error('Error fetching tempo data:', error);
+      } finally {
+        setIsLoading(false);
+      }
+    };
 
+    if (auth) {
+      loadTempo();
+    } else {
+      setIsLoading(false);
+    }
+  }, [auth]);
+
+  useEffect(() => {
     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') {
+    } else if (auth.tempoProgres === 'review' && !tempo?.paymentTerm) {
       router.push('/pengajuan-tempo/review');
-    } else if (auth.tempoProgres === 'approve') {
+    } else if (
+      auth.tempoProgres === 'approve' &&
+      tempo?.paymentTerm?.toLowerCase().includes('tempo')
+    ) {
       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
     }
-  }, [auth, router]);
+  }, [auth, router, tempo]);
 
-  if (isLoading || !auth) {
-    return null; // Show nothing while loading or if auth is not ready
+  if (isLoading || !auth || !tempo) {
+    return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
   }
 
   return (
-- 
cgit v1.2.3


From 0f84963214ee6dc5b5a44d945540826a66bec9e0 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 11 Dec 2024 11:51:45 +0700
Subject: <iman> update pengajuan tempo

---
 src/pages/pengajuan-tempo/index.jsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 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 f0681663..d485c721 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -41,25 +41,26 @@ export default function TrackingOrder() {
     } else {
       setIsLoading(false);
     }
-  }, [auth]);
-
+  }, []);
   useEffect(() => {
     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' && !tempo?.paymentTerm) {
-      router.push('/pengajuan-tempo/review');
     } else if (
       auth.tempoProgres === 'approve' &&
       tempo?.paymentTerm?.toLowerCase().includes('tempo')
     ) {
       router.push('/pengajuan-tempo/approve');
+    } else if (!auth.parentId) {
+      router.push('/pengajuan-tempo/switch-account');
+    } else if (auth.tempoProgres === 'review' && !tempo?.paymentTerm) {
+      router.push('/pengajuan-tempo/review');
     } else if (auth.tempoProgres === 'rejected') {
       router.push('/pengajuan-tempo/rejected');
+    } else {
+      setIsLoading(false);
     }
-  }, [auth, router, tempo]);
+  }, [tempo]);
 
   if (isLoading || !auth || !tempo) {
     return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
-- 
cgit v1.2.3


From 40f762589601de0fe1d5b06164b2553ebdbf5ecd Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 11 Jan 2025 09:27:46 +0700
Subject: <iman> update code

---
 src/pages/pengajuan-tempo/index.jsx | 5 +----
 1 file changed, 1 insertion(+), 4 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 d485c721..6987bd29 100644
--- a/src/pages/pengajuan-tempo/index.jsx
+++ b/src/pages/pengajuan-tempo/index.jsx
@@ -46,10 +46,7 @@ export default function TrackingOrder() {
     if (!auth) {
       const nextUrl = encodeURIComponent(router.asPath);
       router.push(`/login?next=${nextUrl}`);
-    } else if (
-      auth.tempoProgres === 'approve' &&
-      tempo?.paymentTerm?.toLowerCase().includes('tempo')
-    ) {
+    } else if (auth.tempoProgres === 'approve' || auth?.partnerTempo) {
       router.push('/pengajuan-tempo/approve');
     } else if (!auth.parentId) {
       router.push('/pengajuan-tempo/switch-account');
-- 
cgit v1.2.3

