"use client" import * as React from "react" import Link from "next/link" import { useRouter } from "next/navigation" import { toast } from "sonner" import { Button } from "@/shared/components/ui/button" import { Input } from "@/shared/components/ui/input" import { Label } from "@/shared/components/ui/label" import { cn } from "@/shared/lib/utils" import { Loader2, Github } from "lucide-react" import type { ActionState } from "@/shared/types/action-state" type RegisterFormProps = React.HTMLAttributes & { registerAction: (formData: FormData) => Promise } export function RegisterForm({ className, registerAction, ...props }: RegisterFormProps) { const [isLoading, setIsLoading] = React.useState(false) const router = useRouter() async function onSubmit(event: React.SyntheticEvent) { event.preventDefault() setIsLoading(true) try { const form = event.currentTarget as HTMLFormElement const formData = new FormData(form) const res = await registerAction(formData) if (res.success) { toast.success(res.message || "Account created") router.push("/login") router.refresh() } else { toast.error(res.message || "Failed to create account") } } catch { toast.error("Failed to create account") } finally { setIsLoading(false) } } return (

Create an account

Enter your email below to create your account

Or continue with

Already have an account?{" "} Sign in

) }