import React, { useState } from 'react'; import { useNavigate, Link } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; import { LogIn, Mail, Lock, ShieldCheck } from 'lucide-react'; export default function LoginView() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const { login } = useAuth(); const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setIsSubmitting(true); setError(''); try { const res = await fetch('http://localhost:3001/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ email, password }) }); const data = await res.json(); if (res.ok) { login(data.user); navigate('/'); } else { setError(data.error || 'Identifiants invalides'); } } catch (err) { setError('Erreur de connexion au serveur'); } finally { setIsSubmitting(false); } }; return (

Connexion Sécurisée

Entrez vos identifiants pour accéder aux logs

{error &&
{error}
}
setEmail(e.target.value)} placeholder="votre@email.com" />
setPassword(e.target.value)} placeholder="••••••••" />
Nouveau ici ? Créer un compte
); }