summaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-12-11 11:51:45 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-12-11 11:51:45 +0700
commit0f84963214ee6dc5b5a44d945540826a66bec9e0 (patch)
tree4011423ed5147059f40afa873f87e167202f5f79 /src/pages
parentcecccfaf318e0e7c52132cf1d04c90c0df745d14 (diff)
<iman> update pengajuan tempo
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/pengajuan-tempo/[status].jsx20
-rw-r--r--src/pages/pengajuan-tempo/index.jsx15
2 files changed, 28 insertions, 7 deletions
diff --git a/src/pages/pengajuan-tempo/[status].jsx b/src/pages/pengajuan-tempo/[status].jsx
index 1ebf167b..c97b5897 100644
--- a/src/pages/pengajuan-tempo/[status].jsx
+++ b/src/pages/pengajuan-tempo/[status].jsx
@@ -3,7 +3,9 @@ import IsAuth from '@/lib/auth/components/IsAuth';
import FinishTempoComponent from '@/lib/pengajuan-tempo/component/FinishTempo';
import { useRouter } from 'next/router';
import axios from 'axios';
+import { useState, useEffect } from 'react';
import Seo from '@/core/components/Seo';
+import { getAuth } from '~/libs/auth';
export async function getServerSideProps(context) {
const { tempo_id } = context.query;
@@ -16,8 +18,26 @@ export async function getServerSideProps(context) {
}
export default function Finish() {
+ const [isLoading, setIsLoading] = useState(true);
const router = useRouter();
+ const auth = getAuth();
+ useEffect(() => {
+ if (!auth) {
+ const nextUrl = encodeURIComponent(router.asPath);
+ router.push(`/login?next=${nextUrl}`);
+ } else if (
+ (router.query.status == 'approve' || router.query.status == 'review') &&
+ auth.tempoProgres === ''
+ ) {
+ router.push('/pengajuan-tempo');
+ } else {
+ setIsLoading(false);
+ }
+ }, [auth]);
+ if (isLoading || !auth) {
+ return null; // Tidak render apa pun selama loading atau auth/tempo belum tersedia
+ }
return (
<>
<Seo title='Pengajuan Tempo Indoteknik.com' />
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