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 | |
| parent | 4711fff3bf3b07c50f353a7c5956055a37a5e4d2 (diff) | |
<iman> update code
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/my/menu.jsx | 4 | ||||
| -rw-r--r-- | src/pages/my/tempo/index.jsx | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/pages/my/menu.jsx b/src/pages/my/menu.jsx index 4099a935..b626be30 100644 --- a/src/pages/my/menu.jsx +++ b/src/pages/my/menu.jsx @@ -90,8 +90,8 @@ export default function Menu() { <p>Invoice & Faktur Pajak</p> </div> </LinkItem> - {(atuh?.partnerTempo.toLowerCase().includes('tempo') || - atuh.tempoProgres == 'review') && ( + {(auth?.partnerTempo?.toLowerCase().includes('tempo') || + auth?.tempoProgres == 'review') && ( <LinkItem href='/my/tempo'> {' '} <div className='flex gap-x-3 items-center'> 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' /> |
