From d17ffb456830fc597fdbdc5c41231923051e5d6c Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Wed, 3 Dec 2025 19:01:47 -0600 Subject: [PATCH] added ranking --- src/app/(Operador)/ranking/page.tsx | 5 ++ src/app/styles/layout/history.scss | 24 ++++++++ src/components/BarNavigation.tsx | 5 ++ src/components/History.tsx | 9 ++- src/components/Ranking.tsx | 85 +++++++++++++++++++++++++++++ src/components/header.tsx | 2 +- 6 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 src/app/(Operador)/ranking/page.tsx create mode 100644 src/components/Ranking.tsx diff --git a/src/app/(Operador)/ranking/page.tsx b/src/app/(Operador)/ranking/page.tsx new file mode 100644 index 0000000..a439fba --- /dev/null +++ b/src/app/(Operador)/ranking/page.tsx @@ -0,0 +1,5 @@ +import Ranking from "@/components/Ranking"; + +export default function Page() { + return ; +} diff --git a/src/app/styles/layout/history.scss b/src/app/styles/layout/history.scss index f820ddd..7771296 100644 --- a/src/app/styles/layout/history.scss +++ b/src/app/styles/layout/history.scss @@ -76,3 +76,27 @@ background: #fff; border-radius: 4px; } + +.total{ + background-color: #fff; + justify-content: space-evenly; +} + +.rowTotal{ + box-shadow: 0 2px 8px #00000045; +} + +.primer-lugar { + background-color: #bd8c01 !important; // Oro + font-weight: bold; +} + +.segundo-lugar { + background-color: #cfcfcf !important; // Plata + font-weight: bold; +} + +.tercer-lugar { + background-color: #ddb288 !important; // Bronce + font-weight: bold; +} diff --git a/src/components/BarNavigation.tsx b/src/components/BarNavigation.tsx index 50c146b..ef342f1 100644 --- a/src/components/BarNavigation.tsx +++ b/src/components/BarNavigation.tsx @@ -44,6 +44,11 @@ function BarNavigation() { Historial +
  • + + Ranking + +
  • Cambiar datos diff --git a/src/components/History.tsx b/src/components/History.tsx index 1df104e..4a1c099 100644 --- a/src/components/History.tsx +++ b/src/components/History.tsx @@ -13,7 +13,6 @@ export default function History() { const api_url = process.env.NEXT_PUBLIC_API_URL; const router = useRouter(); - useEffect(() => { const fetchHistorial = async () => { try { @@ -42,6 +41,14 @@ export default function History() {
    + + + + diff --git a/src/components/Ranking.tsx b/src/components/Ranking.tsx new file mode 100644 index 0000000..15b87d3 --- /dev/null +++ b/src/components/Ranking.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 Ranking() { + const [ranking, setRanking] = useState([]); + const api_url = process.env.NEXT_PUBLIC_API_URL; + + useEffect(() => { + const fetchRanking = async () => { + try { + const token = Cookies.get("token"); + const headers = { Authorization: `Bearer ${token}` }; + + const response = await axios.get(`${api_url}/equipos/ranking`, { + headers, + }); + + setRanking(response.data); + } catch (error) { + toast.error("No se pudo cargar el ranking"); + } + }; + + fetchRanking(); + }, []); + + return ( +
    +
    + Numero total modificado: + + {historial.length} +
    Inventario Tipo de Equipo
    + + + + + + + + + + + + + + + {ranking.length > 0 ? ( + ranking.map((item: any, index: number) => ( + + + + + + )) + ) : ( + + + + )} + +
    + Total de equipos censados: + + {ranking.reduce((acc, r) => acc + r.total, 0)} +
    UsuarioTotal CensadoRanking
    {item.nombre}{item.total}#{index + 1}
    + No hay datos de ranking disponibles +
    +
    + ); +} diff --git a/src/components/header.tsx b/src/components/header.tsx index f50b0d3..b6615f1 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","/historial"]; + const publicNav = ["/escaner", "/agregarEquipo", "/editar", "/cambiarPass","/historial","/ranking"]; const privateNav = ["/equipoComputo", "/crearCuenta", "/perifericos"]; return (