"use client"; import { useState, FormEvent } from "react"; import { useAuth } from "@/lib/AuthContext"; import { useRouter } from "next/navigation"; import Link from "next/link"; export default function RegisterPage() { const { register } = useAuth(); const router = useRouter(); const [name, setName] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); setError(""); if (!name.trim() || !email.trim() || !password.trim()) { setError("Please fill in all fields"); return; } if (password.length < 6) { setError("Password must be at least 6 characters"); return; } setLoading(true); try { await register(email.trim(), name.trim(), password); router.push("/"); } catch (err: unknown) { const message = err instanceof Error ? err.message : "Registration failed. Please try again."; setError(message); } finally { setLoading(false); } }; return (
{/* Logo / Brand */}
☪️

Join Falah

Start your Islamic lifestyle journey

{/* Error */} {error && (
{error}
)} {/* Form */}
setName(e.target.value)} placeholder="Your name" autoComplete="name" autoFocus className="w-full bg-[#111118] border border-gray-800/60 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-[#D4AF37]/50 focus:ring-1 focus:ring-[#D4AF37]/30 transition" />
setEmail(e.target.value)} placeholder="you@example.com" autoComplete="email" className="w-full bg-[#111118] border border-gray-800/60 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-[#D4AF37]/50 focus:ring-1 focus:ring-[#D4AF37]/30 transition" />
setPassword(e.target.value)} placeholder="At least 6 characters" autoComplete="new-password" className="w-full bg-[#111118] border border-gray-800/60 rounded-xl px-4 py-3 text-white placeholder-gray-600 focus:outline-none focus:border-[#D4AF37]/50 focus:ring-1 focus:ring-[#D4AF37]/30 transition" />
{/* Sign in link */}

Already have an account?{" "} Sign in

{/* Bonus info */}

New Member Bonus

Get 5,000 FLH{" "} free on sign up + 7-day premium trial

); }