dimensionalpulsar commited on
Commit
dcbba65
·
verified ·
1 Parent(s): d3ab8d1

Upload 35 files

Browse files
Files changed (2) hide show
  1. app/login/page.tsx +25 -2
  2. app/register/page.tsx +136 -0
app/login/page.tsx CHANGED
@@ -7,6 +7,8 @@ import { useRouter } from "next/navigation";
7
  import { motion } from "framer-motion";
8
  import { Lock, User, ArrowRight, ShieldCheck } from "lucide-react";
9
 
 
 
10
  export default function LoginPage() {
11
  const [email, setEmail] = useState("admin@erp.com");
12
  const [password, setPassword] = useState("admin123");
@@ -22,7 +24,21 @@ export default function LoginPage() {
22
  await signInWithEmailAndPassword(auth, email, password);
23
  router.push("/");
24
  } catch (err: any) {
25
- setError("Credenciales inválidas. Intente de nuevo.");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  setLoading(false);
27
  }
28
  };
@@ -105,7 +121,7 @@ export default function LoginPage() {
105
  </button>
106
  </form>
107
 
108
- <div className="mt-8 pt-8 border-t border-white/5">
109
  <div className="bg-blue-500/5 border border-blue-500/10 rounded-2xl p-4 flex items-center gap-4">
110
  <div className="w-8 h-8 rounded-full bg-blue-500/10 flex items-center justify-center">
111
  <ShieldCheck size={14} className="text-blue-400" />
@@ -115,6 +131,13 @@ export default function LoginPage() {
115
  <p className="text-[10px] text-gray-500 font-medium">Haga clic en 'Entrar' para acceder rápidamente.</p>
116
  </div>
117
  </div>
 
 
 
 
 
 
 
118
  </div>
119
  </motion.div>
120
  </div>
 
7
  import { motion } from "framer-motion";
8
  import { Lock, User, ArrowRight, ShieldCheck } from "lucide-react";
9
 
10
+ import Link from "next/link";
11
+
12
  export default function LoginPage() {
13
  const [email, setEmail] = useState("admin@erp.com");
14
  const [password, setPassword] = useState("admin123");
 
24
  await signInWithEmailAndPassword(auth, email, password);
25
  router.push("/");
26
  } catch (err: any) {
27
+ // Auto-create admin if it doesn't exist
28
+ if (err.code === "auth/user-not-found" && email === "admin@erp.com") {
29
+ try {
30
+ const { createUserWithEmailAndPassword } = await import("firebase/auth");
31
+ await createUserWithEmailAndPassword(auth, email, password);
32
+ router.push("/");
33
+ return;
34
+ } catch (regErr: any) {
35
+ setError("Error al crear cuenta administrativa automática.");
36
+ }
37
+ } else if (err.code === "auth/invalid-credential" || err.code === "auth/wrong-password") {
38
+ setError("Credenciales inválidas. Intente de nuevo.");
39
+ } else {
40
+ setError("Error de conexión. Intente de nuevo.");
41
+ }
42
  setLoading(false);
43
  }
44
  };
 
121
  </button>
122
  </form>
123
 
124
+ <div className="mt-8 pt-8 border-t border-white/5 flex flex-col gap-4">
125
  <div className="bg-blue-500/5 border border-blue-500/10 rounded-2xl p-4 flex items-center gap-4">
126
  <div className="w-8 h-8 rounded-full bg-blue-500/10 flex items-center justify-center">
127
  <ShieldCheck size={14} className="text-blue-400" />
 
131
  <p className="text-[10px] text-gray-500 font-medium">Haga clic en 'Entrar' para acceder rápidamente.</p>
132
  </div>
133
  </div>
134
+
135
+ <p className="text-center text-xs text-gray-500 font-medium">
136
+ ¿No tienes una cuenta? {" "}
137
+ <Link href="/register" className="text-blue-400 font-black hover:text-blue-300 transition-colors">
138
+ Regístrate aquí
139
+ </Link>
140
+ </p>
141
  </div>
142
  </motion.div>
143
  </div>
app/register/page.tsx ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+
3
+ import React, { useState } from "react";
4
+ import { createUserWithEmailAndPassword } from "firebase/auth";
5
+ import { auth } from "@/lib/firebase";
6
+ import { useRouter } from "next/navigation";
7
+ import { motion } from "framer-motion";
8
+ import { Lock, User, ArrowRight, ShieldCheck, Mail, UserPlus } from "lucide-react";
9
+ import Link from "next/link";
10
+
11
+ export default function RegisterPage() {
12
+ const [email, setEmail] = useState("");
13
+ const [password, setPassword] = useState("");
14
+ const [name, setName] = useState("");
15
+ const [error, setError] = useState("");
16
+ const [loading, setLoading] = useState(false);
17
+ const router = useRouter();
18
+
19
+ const handleRegister = async (e: React.FormEvent) => {
20
+ e.preventDefault();
21
+ setLoading(true);
22
+ setError("");
23
+ try {
24
+ await createUserWithEmailAndPassword(auth, email, password);
25
+ router.push("/");
26
+ } catch (err: any) {
27
+ setError(err.message || "Error al crear la cuenta.");
28
+ setLoading(false);
29
+ }
30
+ };
31
+
32
+ return (
33
+ <div className="fixed inset-0 bg-[#020617] flex items-center justify-center p-6 z-[100]">
34
+ {/* Background Decorative Elements */}
35
+ <div className="absolute top-[-10%] left-[-10%] w-[40%] h-[40%] bg-blue-600/20 rounded-full blur-[120px] animate-pulse"></div>
36
+ <div className="absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] bg-indigo-600/20 rounded-full blur-[120px] animate-pulse delay-1000"></div>
37
+
38
+ <motion.div
39
+ initial={{ opacity: 0, y: 20 }}
40
+ animate={{ opacity: 1, y: 0 }}
41
+ className="w-full max-w-md bg-white/5 border border-white/10 rounded-[2.5rem] p-10 backdrop-blur-3xl shadow-2xl relative overflow-hidden"
42
+ >
43
+ <div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-blue-500 via-indigo-500 to-purple-500"></div>
44
+
45
+ <div className="flex flex-col items-center mb-10">
46
+ <div className="w-16 h-16 bg-gradient-to-br from-indigo-600 to-purple-600 rounded-[1.5rem] flex items-center justify-center shadow-2xl shadow-indigo-500/20 mb-6">
47
+ <UserPlus size={32} className="text-white" />
48
+ </div>
49
+ <h1 className="text-3xl font-black tracking-tighter italic uppercase text-white">
50
+ NEXUS <span className="text-indigo-500 italic">REGISTRO</span>
51
+ </h1>
52
+ <p className="text-gray-500 font-bold mt-2 uppercase text-[10px] tracking-[0.3em]">Crea tu cuenta empresarial</p>
53
+ </div>
54
+
55
+ <form onSubmit={handleRegister} className="space-y-4">
56
+ <div className="space-y-2">
57
+ <label className="text-[10px] font-black uppercase tracking-widest text-gray-400 ml-4">Nombre Completo</label>
58
+ <div className="relative group">
59
+ <User className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500 group-focus-within:text-indigo-400 transition-colors" size={18} />
60
+ <input
61
+ type="text"
62
+ value={name}
63
+ onChange={(e) => setName(e.target.value)}
64
+ 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-indigo-500/50 outline-none transition-all focus:bg-white/10"
65
+ placeholder="Juan Pérez"
66
+ required
67
+ />
68
+ </div>
69
+ </div>
70
+
71
+ <div className="space-y-2">
72
+ <label className="text-[10px] font-black uppercase tracking-widest text-gray-400 ml-4">Correo Electrónico</label>
73
+ <div className="relative group">
74
+ <Mail className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500 group-focus-within:text-indigo-400 transition-colors" size={18} />
75
+ <input
76
+ type="email"
77
+ value={email}
78
+ onChange={(e) => setEmail(e.target.value)}
79
+ 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-indigo-500/50 outline-none transition-all focus:bg-white/10"
80
+ placeholder="usuario@empresa.com"
81
+ required
82
+ />
83
+ </div>
84
+ </div>
85
+
86
+ <div className="space-y-2">
87
+ <label className="text-[10px] font-black uppercase tracking-widest text-gray-400 ml-4">Contraseña</label>
88
+ <div className="relative group">
89
+ <Lock className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500 group-focus-within:text-indigo-400 transition-colors" size={18} />
90
+ <input
91
+ type="password"
92
+ value={password}
93
+ onChange={(e) => setPassword(e.target.value)}
94
+ 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-indigo-500/50 outline-none transition-all focus:bg-white/10"
95
+ placeholder="••••••••"
96
+ required
97
+ />
98
+ </div>
99
+ </div>
100
+
101
+ {error && (
102
+ <motion.p
103
+ initial={{ opacity: 0, x: -10 }}
104
+ animate={{ opacity: 1, x: 0 }}
105
+ className="text-red-400 text-xs font-bold text-center bg-red-500/10 py-3 rounded-xl border border-red-500/20"
106
+ >
107
+ {error}
108
+ </motion.p>
109
+ )}
110
+
111
+ <button
112
+ type="submit"
113
+ disabled={loading}
114
+ className="w-full bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-500 hover:to-purple-500 text-white font-black py-4 rounded-2xl shadow-xl shadow-indigo-900/40 flex items-center justify-center gap-2 group transition-all active:scale-[0.98] disabled:opacity-50"
115
+ >
116
+ {loading ? "Creando Cuenta..." : (
117
+ <>
118
+ Unirme a Nexus
119
+ <ArrowRight size={18} className="group-hover:translate-x-1 transition-transform" />
120
+ </>
121
+ )}
122
+ </button>
123
+ </form>
124
+
125
+ <div className="mt-8 pt-8 border-t border-white/5 text-center">
126
+ <p className="text-xs text-gray-500 font-medium">
127
+ ¿Ya tienes una cuenta? {" "}
128
+ <Link href="/login" className="text-indigo-400 font-black hover:text-indigo-300 transition-colors">
129
+ Inicia Sesión
130
+ </Link>
131
+ </p>
132
+ </div>
133
+ </motion.div>
134
+ </div>
135
+ );
136
+ }