"use client"; import { useState } from "react"; import { lmsApi } from "@/lib/api"; import { useAuth } from "@/context/AuthContext"; import { useRouter } from "next/navigation"; import Link from "next/link"; import { UserPlus, Mail, Lock, User, Building2 } from "lucide-react"; export default function RegisterPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [fullName, setFullName] = useState(""); const [organizationName, setOrganizationName] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const { login } = useAuth(); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(""); try { const res = await lmsApi.register({ email, password, full_name: fullName, organization_name: organizationName }); login(res.user, res.token); router.push("/"); } catch (err) { const message = err instanceof Error ? err.message : "Registration failed. Please try again."; setError(message); } finally { setLoading(false); } }; return (
Join the next generation of learners
Already have an account? Login here