diff --git a/frontend/src/app/dealer/apply/page.tsx b/frontend/src/app/dealer/apply/page.tsx index a9c893f..8338d76 100644 --- a/frontend/src/app/dealer/apply/page.tsx +++ b/frontend/src/app/dealer/apply/page.tsx @@ -27,7 +27,7 @@ interface DealerApplication { export default function DealerApplyPage() { const { t, language } = useTranslation(); - const { user, token } = useAuthStore(); + const { user, token, isLoading } = useAuthStore(); const router = useRouter(); const [loading, setLoading] = useState(false); @@ -53,6 +53,8 @@ export default function DealerApplyPage() { }); useEffect(() => { + if (isLoading) return; + if (!user) { router.push('/login'); return; @@ -65,7 +67,7 @@ export default function DealerApplyPage() { // Check for existing application checkExistingApplication(); - }, [user, router]); + }, [user, router, isLoading]); const checkExistingApplication = async () => { if (!token) return; @@ -121,7 +123,7 @@ export default function DealerApplyPage() { } }; - if (!user || checkingApplication) { + if (isLoading || !user || checkingApplication) { return (