import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { supabase } from '../lib/supabase' import { useAuth } from '../lib/useSession' export default function LoginCompact() { const navigate = useNavigate() const { session, user, loading, signOut } = useAuth() const [isSigningIn, setIsSigningIn] = useState(false) const [error, setError] = useState(null) // Show logged in state if authenticated if (session && !loading) { return (

YOU ARE LOGGED IN

Email: {user?.email}

) } const signInWithProvider = async (provider: 'github' | 'google' | 'facebook' | 'linkedin_oidc') => { try { setIsSigningIn(true) setError(null) const redirectTo = `${window.location.origin}/auth/callback` console.log(`[LoginCompact] Signing in with ${provider}`) const oauthOptions: any = { redirectTo } if (provider === 'facebook') { oauthOptions.queryParams = { scope: 'email' } } else if (provider === 'linkedin_oidc') { oauthOptions.queryParams = { scope: 'openid profile email' } } else { oauthOptions.queryParams = { access_type: 'offline', prompt: 'consent', } } const { error } = await supabase.auth.signInWithOAuth({ provider, options: oauthOptions }) if (error) { console.error(`[LoginCompact] ${provider} error:`, error) setError(`Failed to sign in with ${provider}: ${error.message}`) } } catch (err) { console.error(`[LoginCompact] Unexpected error:`, err) setError(`Unexpected error: ${err instanceof Error ? err.message : 'Unknown error'}`) } finally { setIsSigningIn(false) } } if (loading) { return (

Loading...

) } return (
{/* Header */}
🔐

Sign In

Choose your authentication method

{/* Error */} {error && (

{error}

)} {/* Buttons */}
{/* GitHub */} {/* Google */} {/* Facebook */} {/* LinkedIn */}
{/* Footer */}

Powered by Supabase Auth

) }