"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 (
{/* Logo */}

VinEye Admin

Connectez-vous pour acceder au panel

{/* Form card */}
setEmail(e.target.value)} placeholder="admin@vineye.app" className="h-11 rounded-xl bg-[oklch(0.12_0.005_60)] border-[oklch(0.22_0.005_60)] text-cream placeholder:text-stone-700 focus:border-vine/40 focus:ring-vine/20 transition-colors" autoComplete="email" required />
setPassword(e.target.value)} placeholder="••••••••" className="h-11 rounded-xl bg-[oklch(0.12_0.005_60)] border-[oklch(0.22_0.005_60)] text-cream placeholder:text-stone-700 focus:border-vine/40 focus:ring-vine/20 pr-10 transition-colors" autoComplete="current-password" required />
{/* Footer */}

VinEye — Detection des maladies de la vigne

); }