feat: improve setup page navigation logic to handle loading state and redirect based on authentication

This commit is contained in:
Wikid82
2025-11-21 11:58:25 -05:00
parent b7aff5a944
commit 5db59291f4
+11 -4
View File
@@ -36,14 +36,21 @@ const Setup: React.FC = () => {
}, [formData.email]);
useEffect(() => {
if (isAuthenticated) {
navigate('/');
// Wait for setup status to load
if (statusLoading) return;
// If setup is required, stay on this page (ignore stale auth)
if (status?.setupRequired) {
return;
}
if (status && !status.setupRequired) {
// If setup is NOT required, redirect based on auth
if (isAuthenticated) {
navigate('/');
} else {
navigate('/login');
}
}, [status, isAuthenticated, navigate]);
}, [status, statusLoading, isAuthenticated, navigate]);
const mutation = useMutation({
mutationFn: async (data: SetupRequest) => {