"use client"; import { useState } from "react"; import { signIn } from "next-auth/react"; export default function SignupPage() { const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [slug, setSlug] = useState("storeshifted"); const [message, setMessage] = useState(""); const [loading, setLoading] = useState(false); async function handleSignup(e: React.FormEvent) { e.preventDefault(); setLoading(true); setMessage(""); try { const res = await fetch("/api/auth/signup", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name, email, password, slug }), }); const data = await res.json(); if (!res.ok) throw new Error(data.error || "Sign up failed"); await signIn("credentials", { email, password, redirect: true, callbackUrl: "/connect", }); } catch (err: any) { setMessage(err.message || "Sign up failed."); } finally { setLoading(false); } } return (

Create Account

setName(e.target.value)} /> setEmail(e.target.value)} /> setPassword(e.target.value)} /> setSlug(e.target.value)} /> {message ?
{message}
: null}
Already have an account? Sign in
); }