init
This commit is contained in:
35
frontend/components/auth/signup-form.tsx
Normal file
35
frontend/components/auth/signup-form.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { signup } from "./actions";
|
||||
import { useActionState } from "react";
|
||||
|
||||
export default function SignupForm() {
|
||||
const [state, action, pending] = useActionState(signup, undefined);
|
||||
|
||||
return (
|
||||
<form action={action}>
|
||||
<div>
|
||||
<label htmlFor="name">Name</label>
|
||||
<input id="name" name="name" placeholder="Name" />
|
||||
</div>
|
||||
{state?.errors?.name && <p>{state.errors.name}</p>}
|
||||
<div>
|
||||
<label htmlFor="password">Password</label>
|
||||
<input id="password" name="password" type="password" />
|
||||
</div>
|
||||
{state?.errors?.password && (
|
||||
<div>
|
||||
<p>Password must:</p>
|
||||
<ul>
|
||||
{state.errors.password.map((error) => (
|
||||
<li key={error}>- {error}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
<button disabled={pending} type="submit">
|
||||
Sign Up
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user