"use client" import { useState } from "react" import { signIn } from "next-auth/react" import { useRouter } from "next/navigation" export default function LoginPage() { const router = useRouter() const [email, setEmail] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState("") const [loading, setLoading] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") setLoading(true) try { const result = await signIn("credentials", { email, password, redirect: false, }) if (result?.error) { setError("Invalid email or password") } else { router.push("/photos") router.refresh() } } catch { setError("An error occurred. Please try again.") } finally { setLoading(false) } } return (

Sign in to MirrorMatch

setEmail(e.target.value)} className="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 bg-white text-gray-900 rounded-t-md focus:outline-none focus:ring-purple-500 focus:border-purple-500 focus:z-10 sm:text-sm" placeholder="Email address" />
setPassword(e.target.value)} className="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 bg-white text-gray-900 rounded-b-md focus:outline-none focus:ring-purple-500 focus:border-purple-500 focus:z-10 sm:text-sm" placeholder="Password" />
{error && (

{error}

)}
) }