-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaef43c
commit 1940d24
Showing
12 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { Loader2 } from "lucide-react"; | ||
import { useForm } from "react-hook-form"; | ||
import { z } from "zod"; | ||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Button } from "@components/ui/button.tsx"; | ||
|
||
const formSchema = z.object({ | ||
email: z.string().email({ message: "Enter a valid email." }), | ||
password: z.string().min(1, { message: "Enter a password." }), | ||
}); | ||
|
||
export function RegisterForm() { | ||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
mode: "onSubmit", | ||
defaultValues: { | ||
email: "", | ||
password: "", | ||
}, | ||
}); | ||
|
||
const onSubmit = async (values: z.infer<typeof formSchema>) => { | ||
console.log(values); | ||
}; | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-3 py-4"> | ||
<FormField | ||
control={form.control} | ||
name="email" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Username</FormLabel> | ||
<FormControl> | ||
<Input placeholder="[email protected]" type="email" {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<FormField | ||
control={form.control} | ||
name="password" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Password</FormLabel> | ||
<FormControl> | ||
<Input placeholder="Your password" type="password" {...field} /> | ||
</FormControl> | ||
<FormDescription>Make sure to always keep your password safe.</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
|
||
<Button type="submit" disabled={false}> | ||
{false && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} | ||
Create | ||
</Button> | ||
</form> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { RegisterForm } from "@components/Register/RegisterForm.tsx"; | ||
|
||
export default function Register() { | ||
return ( | ||
<div className="flex min-h-screen w-screen items-center justify-center flex-col"> | ||
<h1>Create your account</h1> | ||
|
||
<RegisterForm /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters