"use client" import { useState } from "react" import { getSession, signIn } from "next-auth/react" import { useRouter } from "next/navigation" import { AlertCircle, Eye, EyeOff, ShieldCheck } from "lucide-react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { ThemeToggle } from "@/components/theme-toggle" import { useAppName } from "@/components/providers/app-config-provider" export default function SignInPage() { const appName = useAppName() const [email, setEmail] = useState("") const [password, setPassword] = useState("") const [showPassword, setShowPassword] = useState(false) const [isLoading, setIsLoading] = useState(false) const [error, setError] = useState("") const router = useRouter() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setIsLoading(true) setError("") try { const result = await signIn("credentials", { email, password, redirect: false, }) if (result?.error) { setError("Ungültige Anmeldedaten") } else { const session = await getSession() if (session) { router.push("/admin") router.refresh() } } } catch { setError("Ein Fehler ist aufgetreten") } finally { setIsLoading(false) } } return (

{appName}

Anmeldung zum Admin-Portal

{error && (
{error}
)}
setEmail(e.target.value)} placeholder="name@firma.de" required disabled={isLoading} />
setPassword(e.target.value)} placeholder="••••••••" required disabled={isLoading} className="pr-10" />

Zugang nur für berechtigte Administratoren

) }