import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { useAuth } from '@/contexts/AuthContext' import { ApiError } from '@/lib/api' import { useState } from 'react' import { OAuthButtons } from './OAuthButtons' export function LoginForm() { const { login } = useAuth() const [formData, setFormData] = useState({ email: '', password: '', }) const [loading, setLoading] = useState(false) const [error, setError] = useState('') const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError('') try { await login(formData) } catch (err) { if (err instanceof ApiError) { setError(err.message) } else { setError('An unexpected error occurred') } } finally { setLoading(false) } } const handleChange = (e: React.ChangeEvent) => { setFormData(prev => ({ ...prev, [e.target.name]: e.target.value, })) } return ( Sign in Enter your email and password to sign in to your account
{error && (
{error}
)}
) }