"use client"; import { useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { toast } from "sonner"; import { useTranslations } from "next-intl"; import { authClient } from "@/lib/auth/client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; export default function SignupPage() { const router = useRouter(); const t = useTranslations("auth"); const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setLoading(true); const { error } = await authClient.signUp.email({ name, email, password, callbackURL: "/recipes", }); setLoading(false); if (error) { toast.error(error.message ?? "Sign up failed"); } else { toast.success("Account created — check your email to verify"); router.push("/login"); } } async function handleGoogle() { await authClient.signIn.social({ provider: "google", callbackURL: "/recipes" }); } return ( {t("signUpTitle")} {t("signUpSubtitle")}
{t("or")}
setName(e.target.value)} required />
setEmail(e.target.value)} required />
setPassword(e.target.value)} required minLength={8} />

{t("alreadyHaveAccount")}{" "} {t("signIn")}

); }