From 8f8269e5ccfe4abb70867fdb7b823bb3d2281fd9 Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Mon, 12 Jan 2026 13:33:48 -0600 Subject: [PATCH] modified ranking --- src/app/styles/layout/history.scss | 59 +++++++++++-- src/components/Ranking.tsx | 133 +++++++++++++++++------------ 2 files changed, 130 insertions(+), 62 deletions(-) diff --git a/src/app/styles/layout/history.scss b/src/app/styles/layout/history.scss index 014c331..201b417 100644 --- a/src/app/styles/layout/history.scss +++ b/src/app/styles/layout/history.scss @@ -13,11 +13,10 @@ color: #e5e5e5; } -.history-table td{ - color: black; +.history-table td { + color: black; } - .history-table thead { background: linear-gradient(90deg, #015cb8, #003e79); border-radius: 4px; @@ -40,7 +39,7 @@ .history-table tbody tr { background: rgba(255, 255, 255, 0.06); - transition: all 0.30s ease; + transition: all 0.3s ease; box-shadow: 0 2px 8px #00000045; border-radius: 4px; } @@ -77,12 +76,12 @@ border-radius: 4px; } -.total{ +.total { background-color: #fff; justify-content: space-evenly; } -.rowTotal{ +.rowTotal { box-shadow: 0 2px 8px #00000045; } @@ -227,7 +226,7 @@ padding: 12px 14px; border-radius: 10px; text-align: center; - box-shadow: 0 1px 3px rgba(0,0,0,0.08); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); } .headerCard .label { @@ -245,14 +244,13 @@ color: #222; } - /* Sección de texto largo */ .sectionCard { background: #f8f8f8; padding: 14px 16px; border-radius: 10px; margin-bottom: 15px; - box-shadow: 0 1px 3px rgba(0,0,0,0.07); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07); } .sectionLabel { @@ -272,3 +270,46 @@ white-space: pre-wrap; word-break: break-word; } + +.year-selector { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; + margin-top: 1rem; +} + +.year-selector div { + width: min(95%, 1000px); + display: flex; + align-items: center; + justify-content: end; +} + +.year-selector label { + text-align: end; + font-weight: 600; + color: #333; + margin-right: 10px; +} + +.year-selector select { + width: 55px; + padding: 6px 10px; + font-size: 14px; + border-radius: 6px; + border: 1px solid #ccc; + background-color: #fff; + cursor: pointer; + transition: border-color 0.2s ease, box-shadow 0.2s ease; +} + +.year-selector select:hover { + border-color: #999; +} + +.year-selector select:focus { + outline: none; + border-color: #4a90e2; + box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2); +} diff --git a/src/components/Ranking.tsx b/src/components/Ranking.tsx index 15b87d3..52bbf03 100644 --- a/src/components/Ranking.tsx +++ b/src/components/Ranking.tsx @@ -1,7 +1,6 @@ "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"; @@ -9,17 +8,28 @@ 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; + const currentYear = new Date().getFullYear(); + + const [year, setYear] = useState(currentYear); + + const [ranking, setRanking] = useState([]); + + const years = []; + for (let y = 2025; y <= currentYear; y++) { + years.push(y); + } + 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, + const response = await axios.get(`${api_url}/equipos/ranking/${year}`, { + headers: { + Authorization: `Bearer ${token}`, + }, }); setRanking(response.data); @@ -29,57 +39,74 @@ export default function Ranking() { }; fetchRanking(); - }, []); + }, [year, api_url]); return ( -
- - - - - - - - - - - - - - - - {ranking.length > 0 ? ( - ranking.map((item: any, index: number) => ( - - - - - - )) - ) : ( - - + + + + + + + + {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 +
+
+
+ + +
+
+
+ + + + + - )} - -
+ 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 +
+
+ ); }