diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-12-16 17:42:31 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-12-16 17:42:31 +0700 |
| commit | 0178a1f88d7d34824562e1413be073c0795a47cf (patch) | |
| tree | 20a26bd36d2c8e0c3e09681836eea9f403519f70 /src/pages/my/tempo/index.jsx | |
| parent | 4711fff3bf3b07c50f353a7c5956055a37a5e4d2 (diff) | |
<iman> update code
Diffstat (limited to 'src/pages/my/tempo/index.jsx')
| -rw-r--r-- | src/pages/my/tempo/index.jsx | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/pages/my/tempo/index.jsx b/src/pages/my/tempo/index.jsx index 365986f4..f52fe960 100644 --- a/src/pages/my/tempo/index.jsx +++ b/src/pages/my/tempo/index.jsx @@ -5,8 +5,27 @@ import DesktopView from '@/core/components/views/DesktopView'; import MobileView from '@/core/components/views/MobileView'; import IsAuth from '@/lib/auth/components/IsAuth'; import InvoicesComponent from '@/lib/tempo/components/Tempo'; - +import { getAuth } from '~/libs/auth'; +import { useRouter } from 'next/router'; +import { useEffect, useState } from 'react'; export default function MyTempo() { + const auth = getAuth(); + const router = useRouter(); + const [isLoading, setIsLoading] = useState(true); + useEffect(() => { + if (!auth) { + const nextUrl = encodeURIComponent(router.asPath); + router.push(`/login?next=${nextUrl}`); + } else if (auth.tempoProgres === '' || auth.tempoProgres === 'rejected') { + 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 ( <IsAuth> <Seo title='Tempo - Indoteknik.com' /> |
