'use client' import React, { useEffect, useState } from 'react' import { Label } from '../ui/label' import { Input } from '../ui/input' import Link from 'next/link' import { Button } from '../ui/button' import { getProviders, signIn } from 'next-auth/react' import { useRouter } from 'next/navigation' import { Separator } from '../ui/separator' import KeyIcon from '../icons/KeyIcon' import OpenIDIcon from '../icons/OpenIDIcon' interface Provider { id: string name: string } export default function LoginForm() { const [email, setEmail] = useState(''); const [password, setPassword] = useState('') const [error, setError] = useState(''); const [providers, setProviders] = useState([]) const router = useRouter(); useEffect(() => { // Fetch available auth providers const fetchProviders = async () => { const authProviders = await getProviders() if (authProviders) { // Filter out credentials provider (email/password) const filtered = Object.values(authProviders).filter( p => p.id !== 'credentials' ) setProviders(filtered) } } fetchProviders() }, []) async function handleSubmit(e: React.FormEvent) { e.preventDefault(); const result = await signIn('credentials', { redirect: false, email, password, }) console.log('[CLIENT] signIn result:', result) if (result?.error) { setError(result.error) } else { router.push('/dashboard') } } const handleOidcLogin = (providerId: string) => { signIn(providerId, { callbackUrl: '/dashboard' }) } return (
{/* OIDC Providers Section {providers.length > 0 && ( <>

Sign in with

{providers.map((provider) => ( ))}
Or continue with email
)} */} {/* Email/Password Form */}
setEmail(e.target.value)} required />
Forgot your password?
setPassword(e.target.value)} required />
{error &&

{error}

}
) }