fix: additional fields default values not being applied (#663)

This commit is contained in:
Bereket Engida
2024-11-26 15:11:05 +03:00
committed by GitHub
parent f7a32a5af8
commit 23ff6039ba
17 changed files with 140 additions and 96 deletions

View File

@@ -1,18 +0,0 @@
"use server";
import { auth } from "@/lib/auth";
export const singInAction = async (previousState: any, data: FormData) => {
const email = data.get("email")?.toString();
const password = data.get("password")?.toString();
if (!email || !password) {
return null;
}
const res = await auth.api.signInEmail({
body: {
email,
password,
},
});
return res;
};

View File

@@ -1,26 +0,0 @@
"use client";
import { useActionState } from "react";
import { auth } from "@/lib/auth";
import { singInAction } from "./action";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
export default function SignInForm() {
const [state, action, isPending] = useActionState(singInAction, null);
return (
<form action={action}>
<div>
<Input type="email" name="email" placeholder="Email" />
</div>
<div>
<Input type="password" name="password" placeholder="Password" />
</div>
<Button type="submit" disabled={isPending}>
{isPending ? "Logging in..." : "Log in"}
</Button>
</form>
);
}