"use client"; import React, { useState } from "react"; import { signIn } from "next-auth/react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; const LoginPage = () => { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const router = useRouter(); const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); const res = await signIn("credentials", { redirect: false, username, password, }); if (res?.ok) { router.push("/admin"); } else { setError("Invalid credentials"); } }; return (
{error}
}