"use client" import { useState } from "react" import { useRouter } from "next/navigation" import Link from "next/link" export default function SignupPage() { const router = useRouter() const [form, setForm] = useState({ name: "", email: "", password: "", confirmPassword: "" }) const [loading, setLoading] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() if (form.password !== form.confirmPassword) { setError("Passwords don't match") return } setLoading(true) setError("") try { const res = await fetch("/api/auth/signup", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: form.name, email: form.email, password: form.password }) }) if (res.ok) { router.push("/autojobs/profile-setup") } else { const data = await res.json() setError(data.error || "Signup failed") } } catch { setError("Network error") } setLoading(false) } return (
Create your account
Already have an account? Sign in