insanely simple onboarding: 1-screen signup → dashboard checklist

OLD FLOW (8+ screens):
  signup (4 fields) → auto-login → setup wizard step 1 → step 2 → step 3 → step 4 → dashboard

NEW FLOW (2 screens):
  signup (3 fields) → dashboard with inline checklist

- Signup page: just charity name + email + password. No 'your name' field. One button.
- Dashboard: shows getting-started checklist when org has no pledges yet
- /api/onboarding: returns setup progress (bank, event, qr, pledge)
- Checklist: progress bar, next-step highlighting, done states with strikethrough
- Each step links directly to the right page (settings, events, pledges)
- Tip shown for brand new orgs: 'Add bank details first'
- No more separate setup wizard — guidance is inline on the dashboard
- Signup loading state: pulsing emoji while account creates
This commit is contained in:
2026-03-03 06:05:10 +08:00
parent 12ea9691c4
commit 369860d8b9
3 changed files with 156 additions and 99 deletions

View File

@@ -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 (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-trust-blue/5 via-white to-warm-amber/5">
<div className="text-center space-y-4">
<div className="inline-flex h-14 w-14 rounded-2xl bg-gradient-to-br from-trust-blue to-blue-600 items-center justify-center shadow-lg shadow-trust-blue/20 animate-pulse">
<span className="text-white text-2xl">🤲</span>
</div>
<p className="text-sm font-medium text-trust-blue animate-pulse">Setting up your charity...</p>
</div>
</div>
)
}
return (
<div className="min-h-screen flex items-center justify-center bg-gradient-to-br from-trust-blue/5 via-white to-warm-amber/5 p-4">
<div className="w-full max-w-sm space-y-6">
<div className="w-full max-w-sm space-y-5">
<div className="text-center">
<div className="inline-flex h-12 w-12 rounded-2xl bg-gradient-to-br from-trust-blue to-blue-600 items-center justify-center shadow-lg shadow-trust-blue/20 mb-4">
<div className="inline-flex h-12 w-12 rounded-2xl bg-gradient-to-br from-trust-blue to-blue-600 items-center justify-center shadow-lg shadow-trust-blue/20 mb-3">
<span className="text-white text-xl">🤲</span>
</div>
<h1 className="text-2xl font-black text-gray-900">Get Started Free</h1>
<p className="text-sm text-muted-foreground mt-1">Set up your charity in 2 minutes</p>
<h1 className="text-2xl font-black text-gray-900">Start collecting pledges</h1>
<p className="text-sm text-muted-foreground mt-1">Free. 30 seconds. No card.</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<form onSubmit={handleSubmit} className="space-y-3">
{error && (
<div className="rounded-xl bg-danger-red/10 border border-danger-red/20 p-3 text-sm text-danger-red text-center">
{error}
</div>
<div className="rounded-xl bg-danger-red/10 border border-danger-red/20 p-2.5 text-sm text-danger-red text-center">{error}</div>
)}
<div>
<label className="text-sm font-medium text-gray-700">Charity / Organisation Name</label>
<input
type="text"
value={charityName}
onChange={(e) => setCharityName(e.target.value)}
className="mt-1 w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="e.g. Islamic Relief UK"
required
/>
</div>
<input
type="text"
value={charityName}
onChange={(e) => setCharityName(e.target.value)}
className="w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="Your charity or mosque name"
required
autoFocus
/>
<div>
<label className="text-sm font-medium text-gray-700">Your Name</label>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
className="mt-1 w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="e.g. Fatima Khan"
/>
</div>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="Your email"
required
/>
<div>
<label className="text-sm font-medium text-gray-700">Email</label>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="mt-1 w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="you@charity.org"
required
/>
</div>
<div>
<label className="text-sm font-medium text-gray-700">Password</label>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="mt-1 w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="Min 8 characters"
required
minLength={8}
/>
</div>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full rounded-xl border border-gray-200 px-4 py-3 text-sm focus:border-trust-blue focus:ring-2 focus:ring-trust-blue/20 outline-none transition-all"
placeholder="Pick a password (8+ chars)"
required
minLength={8}
/>
<button
type="submit"
disabled={loading}
className="w-full rounded-xl bg-trust-blue px-4 py-3 text-sm font-semibold text-white hover:bg-trust-blue/90 disabled:opacity-50 transition-all"
className="w-full rounded-xl bg-trust-blue px-4 py-3.5 text-sm font-bold text-white hover:bg-trust-blue/90 transition-all shadow-lg shadow-trust-blue/20"
>
{loading ? "Creating your account..." : "Create Account & Set Up →"}
Create Account
</button>
<p className="text-[10px] text-center text-muted-foreground">
Free forever. No credit card needed. Takes 2 minutes.
</p>
</form>
<p className="text-center text-sm text-muted-foreground">
Already have an account?{" "}
<Link href="/login" className="text-trust-blue font-semibold hover:underline">
Sign In
</Link>
<p className="text-center text-xs text-muted-foreground">
Already have an account? <Link href="/login" className="text-trust-blue font-semibold hover:underline">Sign in</Link>
</p>
</div>
</div>