"use client"; import React, { useState, useEffect } from "react"; import { auth } from "@/lib/firebase"; import { signInWithEmailAndPassword, onAuthStateChanged } from "firebase/auth"; import { useRouter } from "next/navigation"; export default function LoginPage() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); useEffect(() => { const unsub = onAuthStateChanged(auth, (user) => { if (user) router.push("/"); }); return () => unsub(); }, [router]); const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(""); try { await signInWithEmailAndPassword(auth, email, password); router.push("/"); } catch (err: any) { setError(err.message || "Error al iniciar sesión"); } finally { setLoading(false); } }; return (
{/* Background Decor */}

ERP System

Panel de control empresarial premium

setEmail(e.target.value)} className="w-full bg-white/5 border border-white/10 rounded-2xl px-6 py-4 outline-none focus:border-blue-500/50 focus:bg-white/10 transition-all placeholder:text-gray-600" />
setPassword(e.target.value)} className="w-full bg-white/5 border border-white/10 rounded-2xl px-6 py-4 outline-none focus:border-blue-500/50 focus:bg-white/10 transition-all placeholder:text-gray-600" />
{error && (
{error}
)}

Acceso restringido para administradores autorizados

); }