Agregar axio a login

This commit is contained in:
jls846
2025-10-28 14:43:18 -06:00
parent f201c6e201
commit 8457542e8b
4 changed files with 69 additions and 25 deletions
-9
View File
@@ -50,16 +50,7 @@ export default function Dashboard() {
router.push(`/Editar?equipoId=${encontrado.id}`);
} else {
// 🚫 Si no existe, se puede registrar
<<<<<<< HEAD:src/app/Escaner/page.tsx
const marca = prompt("Equipo no registrado. Ingresa la marca:");
if (marca) {
const nuevoEquipo = { id: code, marca, estado: "Desactivado" };
setEquipos([...equipos, nuevoEquipo]);
alert("Equipo agregado al inventario");
}
=======
router.push(`/AgregarEquipo`);
>>>>>>> 374ce02350db05430bc40286bdff9fe767e82eae:src/app/(Operador)/Escaner/page.tsx
}
};
+14 -2
View File
@@ -5,15 +5,27 @@ import "../app/styles/layout/login.scss";
import "../app/styles/base/globales.scss";
import Image from "next/image";
import Link from "next/link";
import axios from "axios";
export default function Login() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
// Autenticacion simulada
setError("");
setLoading(true);
try{
const response = await axios.post('/api/login', { email, password });
} catch (err) {
console.error("Error en la solicitud:", err);
setError("Error al conectar con el servidor");
} finally {
setLoading(false);
}
};
return (