'use client'; import { useState } from 'react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { Eye, EyeOff, Mail, Lock } from 'lucide-react'; import { useAuthStore } from '@/lib/auth-store'; import toast from 'react-hot-toast'; export default function ConnexionPage() { const router = useRouter(); const { login } = useAuthStore(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); try { await login(email, password); toast.success('Connexion réussie !'); router.push('/dashboard'); } catch (error: unknown) { const axiosError = error as import('axios').AxiosError<{ message?: string }>; const message = axiosError.response?.data?.message || 'Identifiants incorrects'; toast.error(message); } finally { setLoading(false); } }; return (
Connectez-vous à votre compte