33 lines
992 B
TypeScript
33 lines
992 B
TypeScript
"use client";
|
|
import React, { FormEvent } from "react";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Button } from "@/components/ui/button";
|
|
import { signIn } from "next-auth/react";
|
|
|
|
const LoginForm = () => {
|
|
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
|
|
e.preventDefault();
|
|
const formData = new FormData(e.currentTarget);
|
|
const response = await signIn("credentials", {
|
|
email: formData.get("email"),
|
|
password: formData.get("password"),
|
|
redirect: false,
|
|
});
|
|
|
|
console.log({ response });
|
|
};
|
|
return (
|
|
<div className="w-full h-full">
|
|
<form
|
|
onSubmit={handleSubmit}
|
|
className="flex flex-col gap-2 mx-auto max-w-md mt-20"
|
|
>
|
|
<Input name="email" type="email" placeholder="email" />
|
|
<Input name="password" type="password" placeholder="password" />
|
|
<Button className="bg-blue-500 text-white text-lg">Login</Button>
|
|
</form>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default LoginForm; |