checkout login page from previous attempt
This commit is contained in:
		
							parent
							
								
									2b6125582d
								
							
						
					
					
						commit
						8e5d2d3082
					
				| 
						 | 
					@ -0,0 +1,63 @@
 | 
				
			||||||
 | 
					"use client"
 | 
				
			||||||
 | 
					import { useForm } from "react-hook-form";
 | 
				
			||||||
 | 
					import { z } from "zod";
 | 
				
			||||||
 | 
					import { zodResolver } from "@hookform/resolvers/zod";
 | 
				
			||||||
 | 
					import { toast } from "@/components/ui/use-toast";
 | 
				
			||||||
 | 
					import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
 | 
				
			||||||
 | 
					import { Input } from "@/components/ui/input";
 | 
				
			||||||
 | 
					import { Button } from "@/components/ui/button";
 | 
				
			||||||
 | 
					import { signIn } from "app/api/auth/actions/sign-in";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const formSchema = z.object({
 | 
				
			||||||
 | 
						email: z.string().email(),
 | 
				
			||||||
 | 
						password: z.string().min(6)
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default function LoginForm() {
 | 
				
			||||||
 | 
						const form = useForm<z.infer<typeof formSchema>>({
 | 
				
			||||||
 | 
							resolver: zodResolver(formSchema),
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						function onErrors(errors) {
 | 
				
			||||||
 | 
							toast({
 | 
				
			||||||
 | 
								title: "WHOOPS",
 | 
				
			||||||
 | 
								description: JSON.stringify(errors)
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return (
 | 
				
			||||||
 | 
							<Form {...form}>
 | 
				
			||||||
 | 
								<form action={signIn}>
 | 
				
			||||||
 | 
									<FormField
 | 
				
			||||||
 | 
										control={form.control}
 | 
				
			||||||
 | 
										name="email"
 | 
				
			||||||
 | 
										render={({ field }) => (
 | 
				
			||||||
 | 
											<FormItem>
 | 
				
			||||||
 | 
												<FormLabel>Email Address</FormLabel>
 | 
				
			||||||
 | 
												<FormControl>
 | 
				
			||||||
 | 
													<Input placeholder="email goes here" {...field} />
 | 
				
			||||||
 | 
												</FormControl>
 | 
				
			||||||
 | 
												<FormMessage />
 | 
				
			||||||
 | 
											</FormItem>
 | 
				
			||||||
 | 
										)}
 | 
				
			||||||
 | 
									></FormField>
 | 
				
			||||||
 | 
									<FormField
 | 
				
			||||||
 | 
										control={form.control}
 | 
				
			||||||
 | 
										name="password"
 | 
				
			||||||
 | 
										render={({ field }) => (
 | 
				
			||||||
 | 
											<FormItem>
 | 
				
			||||||
 | 
												<FormLabel>Password</FormLabel>
 | 
				
			||||||
 | 
												<FormControl>
 | 
				
			||||||
 | 
													<Input placeholder="password goes here" type="password"{...field} />
 | 
				
			||||||
 | 
												</FormControl>
 | 
				
			||||||
 | 
												<FormMessage />
 | 
				
			||||||
 | 
											</FormItem>
 | 
				
			||||||
 | 
										)}
 | 
				
			||||||
 | 
									></FormField>
 | 
				
			||||||
 | 
									<Button type="submit">SUBMIT</Button>
 | 
				
			||||||
 | 
								</form>
 | 
				
			||||||
 | 
							</Form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue