/home/techb158/balavpn.abdallabala.com/src/app/signup
Edit: /home/techb158/balavpn.abdallabala.com/src/app/signup/page.jsx (3424B)
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
export default function SignupPage() {
const router = useRouter();
const [email, setEmail] = useState("");
const [displayName, setDisplayName] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
async function handleSubmit(event) {
event.preventDefault();
setError("");
setLoading(true);
try {
const res = await fetch("/api/auth/signup", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, displayName, password })
});
if (!res.ok) {
const data = await res.json();
throw new Error(data.error || "Signup failed");
}
router.push("/dashboard");
} catch (err) {
setError(err.message);
setLoading(false);
}
}
return (
COSMIC AI-Risk SaaS
Create account
Sign up for a new workspace
{error &&
{error}
}
Already have an account?
);
}