"use client"; import React, { useState } from "react"; import { signInWithEmailAndPassword } from "firebase/auth"; import { auth } from "@/lib/firebase"; import { useRouter } from "next/navigation"; import { motion } from "framer-motion"; import { Lock, User, ArrowRight, ShieldCheck } from "lucide-react"; import Link from "next/link"; export default function LoginPage() { const [email, setEmail] = useState("admin@erp.com"); const [password, setPassword] = useState("admin123"); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const router = useRouter(); const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(""); try { await signInWithEmailAndPassword(auth, email, password); router.push("/"); } catch (err: any) { // Auto-create admin if it doesn't exist if (err.code === "auth/user-not-found" && email === "admin@erp.com") { try { const { createUserWithEmailAndPassword } = await import("firebase/auth"); await createUserWithEmailAndPassword(auth, email, password); router.push("/"); return; } catch (regErr: any) { setError("Error al crear cuenta administrativa automática."); } } else if (err.code === "auth/invalid-credential" || err.code === "auth/wrong-password") { setError("Credenciales inválidas. Intente de nuevo."); } else { setError("Error de conexión. Intente de nuevo."); } setLoading(false); } }; return (
{/* Background Decorative Elements */}

NEXUS ERP

Acceso Seguro al Panel de Control

setEmail(e.target.value)} className="w-full bg-white/5 border border-white/10 rounded-2xl py-4 pl-12 pr-4 text-sm font-medium focus:ring-2 focus:ring-blue-500/50 outline-none transition-all focus:bg-white/10" placeholder="usuario@empresa.com" required />
setPassword(e.target.value)} className="w-full bg-white/5 border border-white/10 rounded-2xl py-4 pl-12 pr-4 text-sm font-medium focus:ring-2 focus:ring-blue-500/50 outline-none transition-all focus:bg-white/10" placeholder="••••••••" required />
{error && ( {error} )}

Modo Demo Activado

Haga clic en 'Entrar' para acceder rápidamente.

¿No tienes una cuenta? {" "} Regístrate aquí

); }