"use client"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import { useState } from "react"; export default function LoginPage() { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(null); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); const res = await signIn("credentials", { email, password, redirect: false, }); if (res?.error) { setError("로그인 실패: 이메일 또는 비밀번호 확인"); return; } router.push("/dashboard"); } return (

로그인

setEmail(e.target.value)} className="rounded border px-3 py-2" /> setPassword(e.target.value)} className="rounded border px-3 py-2" /> {error != null &&

{error}

}
); }