"use client" import Link from "next/link" import { useState } from "react" import { useRouter } from "next/navigation" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Mail, Lock, AlertCircle, CheckCircle } from "lucide-react" import { useAuth } from "@/lib/auth-context" export default function RegisterPage() { const router = useRouter() const { register, isLoading } = useAuth() const [formData, setFormData] = useState({ firstName: "", lastName: "", email: "", password: "", passwordConfirm: "", }) const [error, setError] = useState("") const [success, setSuccess] = useState(false) const handleChange = (e: React.ChangeEvent) => { const { name, value } = e.target setFormData(prev => ({ ...prev, [name]: value })) } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") setSuccess(false) if (!formData.firstName || !formData.lastName || !formData.email || !formData.password) { setError("Tous les champs sont requis") return } if (formData.password !== formData.passwordConfirm) { setError("Les mots de passe ne correspondent pas") return } if (formData.password.length < 8) { setError("Le mot de passe doit contenir au moins 8 caractères") return } try { await register(formData.email, formData.password, formData.firstName, formData.lastName) setSuccess(true) setTimeout(() => { router.push("/dashboard") }, 500) } catch (err) { setError("Une erreur s'est produite lors de l'inscription") } } return (
{/* Left side - Illustration */}
🗳️

Rejoignez-nous

Créez un compte pour participer à des élections sécurisées et transparentes

Inscription gratuite

Sécurité maximale

Aucune données

{/* Right side - Form */}

S'inscrire

Créez votre compte E-Voting

{error && (

Erreur

{error}

)} {success && (

Succès

Votre compte a été créé avec succès

)}

Déjà un compte?{" "} Se connecter

) }