"use client"; import { useState } from "react"; import { signIn } from "next-auth/react"; import Link from "next/link"; export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(""); setLoading(true); try { const res = await signIn("credentials", { email, password, redirect: false, }); if (res?.error) { setError("Email ou mot de passe incorrect"); return; } window.location.href = "/"; } catch { setError("Erreur de connexion"); } finally { setLoading(false); } } return (
Pas de compte ?{" "} S'inscrire