"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { Grape, Loader2, Eye, EyeOff } from "lucide-react"; import { signIn } from "@/lib/auth-client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { toast } from "sonner"; export default function LoginPage() { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (loading) return; const trimmedEmail = email.trim().toLowerCase(); if (!trimmedEmail || !password) { toast.error("Veuillez remplir tous les champs"); return; } setLoading(true); try { await signIn.email( { email: trimmedEmail, password }, { onSuccess: () => { router.push("/dashboard"); }, onError: (ctx) => { toast.error(ctx.error.message || "Identifiants incorrects"); }, } ); } catch { toast.error("Une erreur est survenue"); } finally { setLoading(false); } } return (
Connectez-vous pour acceder au panel
VinEye — Detection des maladies de la vigne