From 3d4771b755f516de0c4429802a7b2e8a165c3414 Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Tue, 2 Dec 2025 19:31:10 -0600 Subject: [PATCH] added history --- src/app/(Operador)/historial/page.tsx | 5 ++ src/app/styles/layout/escaner.scss | 4 +- src/app/styles/layout/history.scss | 78 ++++++++++++++++++++++++ src/components/BarNavigation.tsx | 5 ++ src/components/History.tsx | 85 +++++++++++++++++++++++++++ src/components/header.tsx | 2 +- 6 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 src/app/(Operador)/historial/page.tsx create mode 100644 src/app/styles/layout/history.scss create mode 100644 src/components/History.tsx diff --git a/src/app/(Operador)/historial/page.tsx b/src/app/(Operador)/historial/page.tsx new file mode 100644 index 0000000..28e8b1a --- /dev/null +++ b/src/app/(Operador)/historial/page.tsx @@ -0,0 +1,5 @@ +import History from "@/components/History"; + +export default function Page() { + return ; +} diff --git a/src/app/styles/layout/escaner.scss b/src/app/styles/layout/escaner.scss index 9b3c639..28a7e1b 100644 --- a/src/app/styles/layout/escaner.scss +++ b/src/app/styles/layout/escaner.scss @@ -37,8 +37,10 @@ h3 { font-size: 16px; - font-weight: 500; margin: 0; + color: #bd8c01; + font-size: 3rem; + font-weight: 700; } } diff --git a/src/app/styles/layout/history.scss b/src/app/styles/layout/history.scss new file mode 100644 index 0000000..f820ddd --- /dev/null +++ b/src/app/styles/layout/history.scss @@ -0,0 +1,78 @@ +.history-table-container { + display: flex; + justify-content: center; + width: 100%; + overflow-x: auto; +} + +.history-table { + width: min(95%, 1000px); + border-collapse: separate; + border-spacing: 0 10px; + font-size: 15px; + color: #e5e5e5; +} + +.history-table td{ + color: black; +} + + +.history-table thead { + background: linear-gradient(90deg, #015cb8, #003e79); + border-radius: 4px; +} + +.history-table thead tr th:first-child { + border-top-left-radius: 4px; +} +.history-table thead tr th:last-child { + border-top-right-radius: 4px; +} + +.history-table th { + padding: 14px; + text-align: center; + font-weight: 600; + letter-spacing: 0.5px; + text-shadow: 0 0 5px #00000060; +} + +.history-table tbody tr { + background: rgba(255, 255, 255, 0.06); + transition: all 0.30s ease; + box-shadow: 0 2px 8px #00000045; + border-radius: 4px; +} + +.history-table tbody tr td:first-child { + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} + +.history-table tbody tr td:last-child { + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} + +.history-table td { + padding: 12px; + text-align: center; + font-weight: 400; +} + +/* Hover mejorado */ +.history-table tbody tr:hover { + background: rgba(1, 92, 184, 0.45); + transform: scale(1.01); + box-shadow: 0 4px 12px #00000070; +} + +/* Fila vacía */ +.empty-row { + text-align: center; + color: black; + font-style: italic; + background: #fff; + border-radius: 4px; +} diff --git a/src/components/BarNavigation.tsx b/src/components/BarNavigation.tsx index 3e8a577..50c146b 100644 --- a/src/components/BarNavigation.tsx +++ b/src/components/BarNavigation.tsx @@ -39,6 +39,11 @@ function BarNavigation() { Agregar equipo +
  • + + Historial + +
  • Cambiar datos diff --git a/src/components/History.tsx b/src/components/History.tsx new file mode 100644 index 0000000..e201337 --- /dev/null +++ b/src/components/History.tsx @@ -0,0 +1,85 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { useRouter } from "next/navigation"; +import Cookies from "js-cookie"; +import axios from "axios"; +import toast from "react-hot-toast"; + +import "../app/styles/layout/history.scss"; + +export default function History() { + const [historial, setHistorial] = useState([]); + const api_url = process.env.NEXT_PUBLIC_API_URL; + const router = useRouter(); + + + useEffect(() => { + const fetchHistorial = async () => { + try { + const token = Cookies.get("token"); + const headers = { Authorization: `Bearer ${token}` }; + + const response = await axios.get(`${api_url}/movimientos/historial`, { + headers, + }); + + setHistorial(response.data); + } catch (error) { + console.error(error); + toast.error("No se pudo cargar el historial"); + } + }; + + fetchHistorial(); + }, []); + + const handleClick = (item: any) => { + const inventario = item.inventario; + router.push(`/editar?equipoId=${inventario}`); + }; + + return ( +
    + + + + + + + + + + + {historial.length > 0 ? ( + historial.map((item: any, index: number) => ( + handleClick(item)} + className="clickable-row" + > + + + + + )) + ) : ( + + + + )} + +
    InventarioTipo de EquipoFecha de Censo
    {item.inventario} + {item.tipo_equipo === "PERIFÉRICO" + ? item.periferico + : item.tipo_equipo} + + {item.fechaMovimiento + ? new Date(item.fechaMovimiento).toLocaleDateString("es-MX") + : "—"} +
    + No hay registros de historial +
    +
    + ); +} diff --git a/src/components/header.tsx b/src/components/header.tsx index 4716498..f50b0d3 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -9,7 +9,7 @@ import { usePathname } from "next/navigation"; function Header() { const pathname = usePathname(); - const publicNav = ["/escaner", "/agregarEquipo", "/editar", "/cambiarPass"]; + const publicNav = ["/escaner", "/agregarEquipo", "/editar", "/cambiarPass","/historial"]; const privateNav = ["/equipoComputo", "/crearCuenta", "/perifericos"]; return (