diff --git a/pledge-now-pay-later/src/app/(auth)/signup/page.tsx b/pledge-now-pay-later/src/app/(auth)/signup/page.tsx index 39dac8a..a7dfe72 100644 --- a/pledge-now-pay-later/src/app/(auth)/signup/page.tsx +++ b/pledge-now-pay-later/src/app/(auth)/signup/page.tsx @@ -6,137 +6,115 @@ import { useRouter } from "next/navigation" import Link from "next/link" export default function SignupPage() { + const [step, setStep] = useState<"form" | "loading">("form") const [charityName, setCharityName] = useState("") - const [name, setName] = useState("") const [email, setEmail] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState("") - const [loading, setLoading] = useState(false) const router = useRouter() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() + if (!charityName.trim() || !email.trim() || !password) return setError("") - setLoading(true) + setStep("loading") try { const res = await fetch("/api/auth/signup", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ email, password, name, charityName }), + body: JSON.stringify({ email, password, charityName, name: "" }), }) - const data = await res.json() if (!res.ok) { - setError(data.error || "Failed to create account") - setLoading(false) + setError(data.error || "Something went wrong") + setStep("form") return } - // Auto sign in - const result = await signIn("credentials", { - email, - password, - redirect: false, - }) - + // Auto sign in and go straight to dashboard + const result = await signIn("credentials", { email, password, redirect: false }) if (result?.error) { - setError("Account created but couldn't sign in. Try logging in.") - setLoading(false) + setError("Account created — please sign in") + setStep("form") } else { - router.push("/dashboard/setup") + router.push("/dashboard") } } catch { - setError("Something went wrong. Please try again.") - setLoading(false) + setError("Connection error. Try again.") + setStep("form") } } + if (step === "loading") { + return ( +
Setting up your charity...
+Set up your charity in 2 minutes
+Free. 30 seconds. No card.
- Already have an account?{" "} - - Sign In - +
+ Already have an account? Sign in
- Start by configuring your organisation's bank details, then create your first event. -
-4 quick steps, then you're collecting pledges
{ob.completed} of {ob.total} done
+ +{step.label}
+{step.desc}
++ 💡 Tip: Add your bank details first — that's the only thing you need before donors can pledge. +
+