From a5a87e78e8e9f0b6c40843c5666c62ae4bba3a09 Mon Sep 17 00:00:00 2001 From: AutonetSellCar Deploy Date: Fri, 27 Mar 2026 16:44:08 +0900 Subject: [PATCH] fix: Prevent redirect to login on dealer apply page during auth loading Wait for isLoading to complete before checking user state to avoid premature redirect when navigating from profile page. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/app/dealer/apply/page.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 (