+
import("@/components/Editar"), {
+ ssr: false,
+});
- useEffect(() => {
- const fetchEquipo = async () => {
- try {
- const response = await axios.get(
- `${process.env.NEXT_PUBLIC_API_URL}/equipos/${equipoId}`
- );
-
- setFormData(response.data);
- } catch (error) {
- console.error("Error al obtener el equipo:", error);
- alert("No se pudo cargar la información del equipo.");
- }
- };
-
- if (equipoId) {
- fetchEquipo();
- }
- }, [equipoId]);
-
- const mostrarCamposComputadora = formData.tipoEquipo !== "Impresora";
-
- const handleGuardar = async () => {
- try {
- await axios.patch(
- `${process.env.NEXT_PUBLIC_API_URL}/equipos/update/${equipoId}`,
- formData
- );
- alert("Equipo actualizado correctamente");
- } catch (error) {
- console.error("Error al guardar:", error);
- alert("Hubo un error al guardar el equipo.");
- }
- };
-
- const handleCancelar = () => {
- alert("Acción cancelada");
- };
-
- return (
-
-
-
- {equipoId ? `Editar Equipo (${equipoId})` : "Agregar Equipo"}
- Inventario:
- Fecha de censo:
-
-
-
-
-
- );
+export default function Page() {
+ return
;
}
diff --git a/src/app/(Operador)/Escaner/page.tsx b/src/app/(Operador)/Escaner/page.tsx
index fdf5936..82bfbf2 100644
--- a/src/app/(Operador)/Escaner/page.tsx
+++ b/src/app/(Operador)/Escaner/page.tsx
@@ -5,13 +5,12 @@ import { useRouter } from "next/navigation";
import "../../styles/layout/escaner.scss"; // Importación global
import BarcodeScanner from "@/components/BarcodeScanner";
import axios from "axios";
+import Image from "next/image";
export default function Dashboard() {
const router = useRouter();
const [isScanning, setIsScanning] = useState(false);
- const [equipos, setEquipos] = useState();
const [search, setSearch] = useState("");
- const [lastScan, setLastScan] = useState
(null);
interface equipo {
id: number;
@@ -29,7 +28,6 @@ export default function Dashboard() {
};
const handleScan = async (code: string) => {
- setLastScan(code);
setIsScanning(false);
const encontrado: equipo = await axios.get("");
@@ -41,12 +39,6 @@ export default function Dashboard() {
}
};
- // 🔒 Cerrar sesión
- const cerrarSesion = () => {
- localStorage.removeItem("loggedIn");
- router.push("/");
- };
-
return (
@@ -56,7 +48,12 @@ export default function Dashboard() {
) : (
-

+
)}
diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx
deleted file mode 100644
index a04e1f4..0000000
--- a/src/app/dashboard/page.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import { useRouter } from "next/navigation";
-import BarcodeScanner from "../../components/BarcodeScanner";
-import "../styles/components/dashboard.scss";
-
-type Equipo = {
- id: string;
- nombre: string;
- estado: string;
-};
-
-const initialEquipos: Equipo[] = [
- { id: "001", nombre: "PC Aula 1", estado: "Disponible" },
- { id: "002", nombre: "PC Aula 2", estado: "En reparación" },
-];
-
-export default function Dashboard() {
- const router = useRouter();
- const [equipos, setEquipos] = useState(initialEquipos);
- const [search, setSearch] = useState("");
- const [lastScan, setLastScan] = useState("");
-
- useEffect(() => {
- const loggedIn = localStorage.getItem("loggedIn");
- if (!loggedIn) router.push("/");
- }, [router]);
-
- const buscarEquipo = () => {
- const resultado = equipos.filter(
- e => e.id.includes(search) || e.nombre.toLowerCase().includes(search.toLowerCase())
- );
- setEquipos(resultado);
- };
-
- const cerrarSesion = () => {
- localStorage.removeItem("loggedIn");
- router.push("/");
- };
-
- const handleScan = (code: string) => {
- setLastScan(code);
-
- const encontrado = equipos.find(e => e.id === code);
- if (encontrado) {
- alert(`Equipo encontrado: ${encontrado.nombre} (${encontrado.estado})`);
- } else {
- const nombre = prompt("Equipo no registrado. Ingresa el nombre:");
- if (nombre) {
- setEquipos([...equipos, { id: code, nombre, estado: "Disponible" }]);
- alert("Equipo agregado al inventario");
- }
- }
- };
-
- return (
-
-
-
Dashboard Inventario Escolar
-
-
-
-
-
Buscar equipo
-
- setSearch(e.target.value)} />
-
-
-
-
-
-
Escanear código de barras
-
- {lastScan &&
Último código escaneado: {lastScan}
}
-
-
-
-
Equipos
-
- {equipos.map((e) => (
- -
- {e.id} - {e.nombre}
- {e.estado}
-
- ))}
-
-
-
- );
-}
diff --git a/src/app/login/Login.tsx b/src/app/login/Login.tsx
index 1e9d988..f96ae52 100644
--- a/src/app/login/Login.tsx
+++ b/src/app/login/Login.tsx
@@ -12,13 +12,11 @@ import toast from "react-hot-toast";
export default function Login() {
const [nombre, setNombre] = useState("");
const [password, setPassword] = useState("");
- const [loading, setLoading] = useState(false);
const router = useRouter();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
- setLoading(true);
try {
const response = await axios.post(
@@ -32,7 +30,7 @@ export default function Login() {
document.cookie = `token=${token}; path=/; SameSite=Strict`;
router.push("/Escaner");
- } catch (err: any) {
+ } catch (err) {
if (axios.isAxiosError(err)) {
if (err.response) {
toast.error(
@@ -46,8 +44,6 @@ export default function Login() {
} else {
toast.error("Ocurrió un error inesperado");
}
- } finally {
- setLoading(false);
}
};
diff --git a/src/app/reporte/page.tsx b/src/app/reporte/page.tsx
index 6405220..9d0982c 100644
--- a/src/app/reporte/page.tsx
+++ b/src/app/reporte/page.tsx
@@ -1,13 +1,10 @@
-import './reporte.css';
+import "./reporte.css";
export default function Reporte() {
return (