import { FC, ReactElement, useEffect, useState } from 'react'; import { Button } from '@imphnen-frontend-service/ui/atoms'; import { useNavigate } from 'react-router'; import { useGitHubAuth } from '@imphnen-frontend-service/service'; import { useSession } from '@imphnen-frontend-service/utils'; import { GithubOutlined } from '@ant-design/icons'; const LoginPage: FC = (): ReactElement => { console.log('[LoginPage] Rendering...'); const navigate = useNavigate(); const { signInWithGitHub } = useGitHubAuth(); const [isGithubLoading, setIsGithubLoading] = useState(false); const { isAuthenticated } = useSession(); console.log('[LoginPage] isAuthenticated:', isAuthenticated); useEffect(() => { console.log('[LoginPage] useEffect - isAuthenticated:', isAuthenticated); if (isAuthenticated) { console.log('[LoginPage] Redirecting to dashboard...'); navigate('/dashboard'); } }, [isAuthenticated, navigate]); const handleGithubLogin = async () => { try { setIsGithubLoading(true); console.log('[Login] Initiating GitHub OAuth...'); const result = await signInWithGitHub(); console.log('[Login] OAuth result:', result); // Check if we got a redirect URL if (result?.url) { console.log('[Login] Redirecting to GitHub OAuth:', result.url); // Supabase should handle the redirect automatically // If we're still here after 2 seconds, manually redirect setTimeout(() => { if (result.url) { globalThis.location.href = result.url; } }, 2000); } else { console.error('[Login] No OAuth URL returned'); setIsGithubLoading(false); } } catch (error) { console.error('[Login] GitHub login failed:', error); setIsGithubLoading(false); } }; return (
Sign in with your GitHub account to join or create your hackathon team
By signing in, you agree to our Terms of Service and Privacy Policy