34 Commits

Author SHA1 Message Date
Tyrannuss 6fcd5592e4 se agregaron vistas de graficas 2026-03-25 16:47:19 -06:00
Tyrannuss 13cdfce656 se agrego graficas por periferico 2026-03-23 18:54:53 -06:00
IO 797b3f6815 fixed grammar and deleted toggle button 2026-03-23 15:36:18 -05:00
IO 1219ca1e91 Merge branch 'Carlos' of https://repositorio.acatlan.unam.mx/IO/front-Censo into Lino 2026-03-20 17:57:33 -05:00
frcarlos 7ee30a6f20 biblioteca_hotmap 2026-03-20 15:33:32 -04:00
IO 179a968e3e added dependencies 2026-03-20 13:48:48 -05:00
IO bae1f99e5c Merge branch 'Carlos' of repositorio.acatlan.unam.mx:IO/front-Censo into Lino 2026-03-20 13:48:18 -05:00
frcarlos 725bc15f63 hotmap 2026-03-20 14:47:09 -04:00
IO 2dfeea0cb4 merge carlos and fixed table 2026-03-20 13:43:38 -05:00
IO 811f5e7c0e Merge branch 'Carlos' of repositorio.acatlan.unam.mx:IO/front-Censo into Lino 2026-03-20 11:54:51 -05:00
frcarlos 7833d38b3e poligonos_edificios 2026-03-19 20:43:46 -04:00
frcarlos 08bca7742b cedetec 2026-03-19 19:01:47 -04:00
frcarlos 48885dd8e7 a6-a15 2026-03-19 16:38:48 -04:00
IO 7b2f33b2b4 added option todos to filter 2026-03-19 10:54:30 -05:00
frcarlos c400623c25 a1-a10 2026-03-18 20:36:29 -04:00
IO 6c7be89a01 new tabla and new dowload 2026-03-18 18:38:01 -05:00
frcarlos a6ef226bec cordenadas a1-a6 2026-03-18 18:14:24 -04:00
frcarlos c444b9f37a cordenasdeedf a1-a6 2026-03-18 18:10:54 -04:00
frcarlos deae0cde7c hotmap 2026-03-13 21:32:26 -04:00
IO c1a9e5d195 added something 2026-03-13 19:57:24 -05:00
IO 9b203020f6 npm audit fixed 2026-03-13 19:48:02 -05:00
IO 451915e858 added new colors to know that is what adscription 2026-03-13 19:46:49 -05:00
IO 1a0c7917b7 working and builded 2026-03-13 19:00:27 -05:00
IO 685d513838 modified grafigs 2026-03-13 18:49:55 -05:00
IO e698a54dc2 added filter and grafics 2026-03-13 15:15:24 -05:00
frcarlos 188fb18b51 hotmap 2026-03-12 20:11:45 -04:00
IO d02fd04edf added new grafics 2026-03-12 18:45:04 -05:00
IO fbac1e4000 npm audit fix 2026-03-06 18:00:40 -06:00
IO cb8598e7dd fixed order 2026-02-16 19:24:05 -06:00
IO a286b6bc32 added sarabia 2026-02-13 17:47:39 -06:00
IO d313b7f2d0 added ep creadores 2026-02-13 16:09:18 -06:00
IO 62214405cc add submit 2026-02-04 19:04:34 -06:00
IO 5715c2802b changed Antiquity 2026-02-04 15:53:31 -06:00
IO 9dcfa91095 fixed antiguedad perifericos 2026-01-23 15:31:33 -06:00
42 changed files with 3542 additions and 158 deletions
+901 -112
View File
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -15,14 +15,20 @@
"axios": "^1.13.2",
"js-cookie": "^3.0.5",
"jwt-decode": "^4.0.0",
"leaflet": "^1.9.4",
"leaflet.heat": "^0.2.0",
"next": "^16.0.7",
"react": "19.2.0",
"react-dom": "19.2.0",
"react-hot-toast": "^2.6.0"
"react-hot-toast": "^2.6.0",
"react-leaflet": "^5.0.0",
"react-select": "^5.10.2",
"recharts": "^3.8.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/js-cookie": "^3.0.6",
"@types/leaflet": "^1.9.21",
"@types/node": "^24",
"@types/react": "^19",
"@types/react-dom": "^19",
@@ -32,4 +38,4 @@
"sass": "^1.94.0",
"typescript": "^5"
}
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

@@ -0,0 +1,10 @@
import "../../styles/layout/reporte.scss";
export default function Page() {
return (
<div className="scanView_reporte">
<div className="container_reporte">
</div>
</div>
);
}
+3 -1
View File
@@ -1,13 +1,15 @@
"use client";
import { useState } from "react";
import Pregunta7 from "@/components/Equipo_Computo/Pregunta7";
import Pregunta1EP from "@/components/Perifericos/Pregunta1EP";
import Pregunta2EP from "@/components/Perifericos/Pregunta2EP";
import Pregunta4EP from "@/components/Perifericos/Pregunta4EP";
import Pregunta5EP from "@/components/Perifericos/Pregunta5EP";
import "../../styles/layout/reporte.scss";
import DownloadReporteXLSX from "@/components/Dowload/Reporte";
import Pregunta7 from "@/components/Equipo_Computo/Pregunta7";
type PreguntaKey = "pregunta1" | "pregunta4" | "pregunta7";
@@ -0,0 +1,64 @@
"use client";
import Reporte from "@/components/reporteGraficas/reporte";
import ReportePerifericos from "@/components/reporte_graficas_perifericos/reporte";
import "../../styles/layout/reporte.scss";
import { useState } from "react";
type PreguntaKey = "reporteGraficas" | "reporte_graficas_perifericos";
const LABELS: Record<PreguntaKey, string> = {
reporteGraficas: "Reporte por equipos",
reporte_graficas_perifericos: "Reporte por perifericos",
};
export default function Page() {
const [activeTab, setActiveTab] = useState<PreguntaKey>("reporteGraficas");
const renderPregunta = () => {
switch (activeTab) {
case "reporteGraficas":
return (
<>
<Reporte />
</>
);
case "reporte_graficas_perifericos":
return (
<>
<ReportePerifericos />
</>
);
default:
return (
<div className="p-6 text-center text-gray-500">
Contenido no disponible aún.
</div>
);
}
};
return (
<div className="scanView_reporte">
<div className="container_reporte">
<div className="main-content_reporte">
<div className="tabs_reporte">
{Object.entries(LABELS).map(([key, label]) => (
<button
key={key}
className={`tab_reporte ${activeTab === key ? "active" : ""}`}
onClick={() => setActiveTab(key as PreguntaKey)}
aria-selected={activeTab === key}
role="tab"
>
{label}
</button>
))}
</div>
<div className={`data-table_reporte`}>{renderPregunta()}</div>
</div>
</div>
</div>
);
}
+5 -4
View File
@@ -16,7 +16,8 @@ export default function Page() {
const api_url = process.env.NEXT_PUBLIC_API_URL;
const buscarEquipo = async () => {
const buscarEquipo = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (!search) return toast.error("Ingresa un número de inventario");
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
@@ -96,17 +97,17 @@ export default function Page() {
{isScanning ? "Cancelar" : "Escanear"}
</button>
<div className="searchBox">
<form className="searchBox" onSubmit={buscarEquipo}>
<input
type="text"
placeholder="Buscar por inventario..."
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
<button onClick={buscarEquipo} className="searchButton">
<button className="searchButton" type="submit">
<Image src="/search.png" alt="Buscar" width={50} height={50} />
</button>
</div>
</form>
</main>
</div>
);
+26
View File
@@ -0,0 +1,26 @@
import Image from "next/image";
import "./creadores.css";
interface props{
title:string;
img:string;
width:number;
height:number;
}
export default function CreatorCard({title,img,width,height}:props) {
return (
<div className="card">
<div className="imageWrapper">
<Image
src={img}
alt="IO"
width={width}
height={height}
className="creators"
/>
</div>
<h1 className="title">{title}</h1>
</div>
)
}
+79
View File
@@ -0,0 +1,79 @@
.mainContainer {
height: 100%;
width: 100%;
display: grid;
position: relative;
place-items: center;
}
.container {
display: flex;
gap: 6rem;
align-items: end;
justify-content: center;
align-items: center;
width: 100%;
flex-wrap: wrap;
}
.imageWrapper {
position: relative;
animation: slideIn 1s ease-out forwards;
transform: translateX(-120px) rotate(12deg);
opacity: 0;
}
.card {
display: flex;
flex-direction: column;
align-items: center;
animation: slideIn 1s ease-out forwards;
opacity: 0;
}
.card:hover .creators {
transform: rotateY(360deg) rotate(12deg) scale(1.05);
box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}
.creators {
object-fit: cover;
border-radius: 16px;
background-color: rgba(255, 255, 255, 0.6);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25);
transition: transform 1s ease, box-shadow 0.4s ease;
}
.imageWrapper:hover .creators {
transform: rotateY(180deg) rotate(24deg) scale(1.05);
box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}
@keyframes slideIn {
to {
transform: translateX(0) rotate(12deg);
opacity: 1;
}
}
.title {
margin-left: 40px;
font-size: 3rem;
font-weight: 600;
opacity: 0;
animation: fadeIn 1s ease forwards;
animation-delay: 0.5s;
color: #1E3A8A;
}
.card:hover .title {
transform: translateY(-5px);
color: #163172;
}
@keyframes fadeIn {
to {
opacity: 1;
}
}
+17
View File
@@ -0,0 +1,17 @@
import "./creadores.css";
import CreatorCard from "./CreatorCard";
export default function Page() {
return (
<div className="mainContainer">
<div className="container">
<CreatorCard title="IO" img="/IO.png" width={150} height={200} />
<CreatorCard title="Sarabia" img="/SARABIA.jpeg" width={150} height={150} />
<CreatorCard title="CarloSpak" img="/SPAK.png" width={160} height={100} />
</div>
</div>
);
}
+3 -3
View File
@@ -1,13 +1,13 @@
"use client";
import { useState } from "react";
import "../styles/layout/login.scss";
import "../styles/base/globales.scss";
import Image from "next/image";
import axios from "axios";
import { useRouter } from "next/navigation";
import toast from "react-hot-toast";
import { jwtDecode } from "jwt-decode";
import "../styles/layout/login.scss";
import "../styles/base/globales.scss";
export default function Login() {
const [nombre, setNombre] = useState("");
@@ -39,7 +39,7 @@ export default function Login() {
if (tipo === 2) {
router.push("/escaner");
} else if (tipo === 1) {
router.push("/equipoComputo");
router.push("/reportesGraficas");
} else {
toast.error("Tipo de usuario no válido");
}
@@ -0,0 +1,18 @@
export default function FormEquipo() {
return (
<form>
<label >Selecciona la antiguedad</label>
<select>
<option value=""></option>
</select>
<label>Selecciona la adscripcion</label>
<select>
<option value=""></option>
</select>
<label >Selecciona el edificio</label>
<select>
<option value=""></option>
</select>
</form>
)
}
+7 -2
View File
@@ -41,12 +41,17 @@ function BarNavigation() {
</li> */}
<li className="subMenu" onClick={toggleMenu}>
<Link href="/equipoComputo" className="links">
<span>Equipo de Computo</span>
<span>Equipo de Cómputo</span>
</Link>
</li>
<li className="subMenu" onClick={toggleMenu}>
<Link href="/perifericos" className="links">
<span>Perifericos</span>
<span>Periféricos</span>
</Link>
</li>
<li className="subMenu" onClick={toggleMenu}>
<Link href="/reportesGraficas" className="links">
<span>Reportes y Gráficas</span>
</Link>
</li>
<li className="subMenu">
+4 -4
View File
@@ -8,7 +8,7 @@ export default function DownloadReporteXLSX() {
const [loading, setLoading] = useState(false);
const handleDownload = async () => {
setLoading(true); // 🔹 Activa loader
setLoading(true);
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
@@ -37,7 +37,7 @@ export default function DownloadReporteXLSX() {
console.error(error);
alert("Hubo un problema al descargar el archivo.");
} finally {
setLoading(false); // 🔹 Reactiva botón y oculta loader
setLoading(false);
}
};
@@ -45,10 +45,10 @@ export default function DownloadReporteXLSX() {
<button
className={styles.downloadBtn}
onClick={handleDownload}
disabled={loading} // 🔹 Botón deshabilitado
disabled={loading}
>
{loading ? (
<div className={styles.loader}></div> // 🔹 Icono de cargando
<div className={styles.loader}></div>
) : (
<img src="/excel.svg" alt="Excel" className={styles.iconExcel} width={30} height={30}/>
)}
+75
View File
@@ -0,0 +1,75 @@
"use client";
import styles from "./style.module.css";
import Cookies from "js-cookie";
import { useState } from "react";
import axios from "axios";
interface Props {
filtros: any;
count?: boolean;
}
export default function DownloadTable({ filtros,count }: Props) {
const [loading, setLoading] = useState(false);
const handleDownload = async () => {
if(!filtros.length){return}
setLoading(true);
const token = Cookies.get("token");
try {
const endpoint = count
? "/equipos/excel/tabla/count"
: "/equipos/excel/tabla";
const response = await axios.post(
`${process.env.NEXT_PUBLIC_API_URL}${endpoint}`,
filtros,
{
headers: {
Authorization: `Bearer ${token}`,
},
responseType: "blob",
}
);
const url = window.URL.createObjectURL(new Blob([response.data]));
const a = document.createElement("a");
a.href = url;
a.download = "reporte.xlsx";
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
} catch (error) {
console.error(error);
alert("Hubo un problema al descargar el archivo.");
} finally {
setLoading(false);
}
};
return (
<button
className={styles.downloadBtn}
onClick={handleDownload}
disabled={loading}
>
{loading ? (
<div className={styles.loader}></div>
) : (
<img
src="/excel.svg"
alt="Excel"
className={styles.iconExcel}
width={30}
height={30}
/>
)}
</button>
);
}
+57
View File
@@ -0,0 +1,57 @@
"use client";
import styles from "./style.module.css";
import Cookies from "js-cookie";
import { useState } from "react";
export default function DownloadTableCount() {
const [loading, setLoading] = useState(false);
const handleDownload = async () => {
setLoading(true);
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/equipos/excel/tabla/count`,
{ headers }
);
if (!response.ok) {
throw new Error("Error al descargar el archivo");
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "reporte.xlsx";
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
} catch (error) {
console.error(error);
alert("Hubo un problema al descargar el archivo.");
} finally {
setLoading(false);
}
};
return (
<button
className={styles.downloadBtn}
onClick={handleDownload}
disabled={loading}
>
{loading ? (
<div className={styles.loader}></div>
) : (
<img src="/excel.svg" alt="Excel" className={styles.iconExcel} width={30} height={30}/>
)}
</button>
);
}
+157
View File
@@ -0,0 +1,157 @@
"use client";
import { MapContainer, ImageOverlay, useMap } from "react-leaflet";
import L, { LatLngBoundsExpression } from "leaflet";
import "leaflet/dist/leaflet.css";
import "leaflet.heat";
import { useEffect } from "react";
// Ajustar vista automáticamente
function AjustarVista({ bounds }: { bounds: LatLngBoundsExpression }) {
const map = useMap();
useEffect(() => {
map.fitBounds(bounds);
}, [map, bounds]);
return null;
}
function HeatLayer() {
const map = useMap();
useEffect(() => {
// A 4768x3368
const edificios = {
A1: [[1407, 3054], [1470, 3054], [1470, 3360], [1407, 3360]],
A2: [[1570, 3130], [1570, 3190], [1850, 3190], [1850, 3130]],
A3: [[1640, 2650], [1705, 2650], [1705, 2950], [1640, 2950]],
A4: [[1268, 2765], [1268, 2830], [1540, 2830], [1540, 2765]],
A5: [[995, 2405], [1295, 2405], [1295, 2470], [995, 2470]],
A6: [[1390, 2385], [1450, 2385], [1450, 2655], [1390, 2655]],
A7: [[1234, 2014], [1296, 2014], [1296, 2317], [1234, 2317]],
A8: [[1390, 2055], [1700, 2055], [1700, 2118], [1390, 2118]],
A9: [[1215, 1825], [1480, 1825], [1480, 1890], [1215, 1890]],
A10: [[1570, 1695], [1635, 1695], [1635, 1960], [1570, 1960]],
A11: [[1475, 1510], [1780, 1510], [1780, 1570], [1475, 1570]],
A12: [[1310, 1395], [1375, 1395], [1375, 1700], [1310, 1700]],
A13: [[1780, 810], [1845, 810], [1845, 1020], [1780, 1020]],
A14: [[1505, 775], [1713, 775], [1713, 840], [1505, 840]],
A15: [[2027, 2580], [2087, 2580], [2087, 2900], [2027, 2900]],
AEROGRAFIA: [[1157, 3308], [1254, 3308], [1254, 3369], [1157, 3369]],
ALMACEN: [[989, 1523], [1027, 1523], [1027, 1749], [989, 1749]],
APOYO_DOC: [[1115, 1222], [1475, 1222], [1475, 1293], [1115, 1293]],
BIBLIOTECA: [[1578, 2372], [1578, 2199], [1593, 2213], [1739, 2213],[1835, 2114], [1889, 2168], [1889, 2345], [1860, 2375],[1888, 2407], [1844, 2450], [1830, 2435], [1814, 2451],[1799, 2435], [1772, 2466], [1766, 2460], [1703, 2523],[1686, 2506], [1645, 2505], [1645, 2465], [1630, 2466],[1629, 2402], [1677, 2402], [1677, 2372], [1666, 2360], [1591, 2360]],
CEI: [[1570, 990], [1767, 990], [1767, 1155], [1570, 1155]],
INVEST: [[1570, 1240], [1727, 1240], [1727, 1400], [1570, 1400]],
CEDTEC: [[885, 2900], [1080, 2900], [1080, 3200], [885, 3200]],
CEMM: [[2167, 863], [2453, 863], [2453, 1458], [2167, 1458]],
CAFETERIA_Y_LIBRERIA: [[2027, 1483], [2158, 1483], [2158, 1600], [2027, 1600]],
CTED: [[1802, 1063], [1908, 1128], [1888, 1179], [1772, 1151]],
POSGRADO: [[857, 1472], [1004, 1471],[1004, 1327],[1086, 1325],[1086, 1512], [860, 1512]],
UNIDAD_SEMINA: [[1145, 2894], [1320, 2894], [1320, 3070], [1145, 3070]],
TALLS_Y_LAB: [[1085, 3209], [1292, 3209], [1292, 3307], [1085, 3307]],
UNIDAD_DE_TALLERES_MULTIDISC: [[1624, 3244], [1920, 3240], [1954, 3476], [1622, 3477]],
USC: [[992, 2656], [1029, 2656], [1029, 2828], [992, 2828]],
UIM: [[294, 3224], [901, 3257], [899, 3358], [312, 3386]],
GOB: [[950, 2068], [1104, 2068], [1104, 2218], [950, 2218]],
SERV_GRALES: [[1024, 882], [1089, 882], [1089, 1138], [1024, 1138]],
SM: [[893, 1789], [935, 1789], [935, 1891], [893, 1891]]
};
const puntos: any[] = [];
Object.entries(edificios).forEach(([nombre, poligono]) => {
for (let i = 0; i < 15; i++) {
const x = poligono[0][0] + Math.random() * (poligono[1][0] - poligono[0][0]);
const y = poligono[0][1] + Math.random() * (poligono[2][1] - poligono[0][1]);
const intensidad = Math.random();
puntos.push([x, y, intensidad]);
}
});
const heat = (L as any).heatLayer(puntos, {
radius: 35,
blur: 25,
maxZoom: 2,
gradient: {
0.2: "#00f",
0.4: "#0ff",
0.6: "#0f0",
0.8: "#ff0",
1.0: "#f00"
}
});
heat.addTo(map);
Object.entries(edificios).forEach(([nombre, coords]: any) => {
L.polygon((coords), {
color: "#77ee9f",
weight: 2,
fillOpacity: 0.25
})
.bindPopup(`🏢 ${nombre}`)
.addTo(map);
});
// DEBUG PRO (CLICK PARA COORDENADAS EXACTAS)
map.on("click", function (e) {
console.log(" Coordenadas exactas:", e.latlng);
});
return () => {
map.removeLayer(heat);
};
}, [map]);
return null;
}
export default function MapaCalor() {
const bounds: LatLngBoundsExpression = [
[0, 0],
[3368, 4768]
];
return (
<div style={{
width: "100%",
height: "650px",
marginTop: "40px",
borderRadius: "12px",
overflow: "hidden",
boxShadow: "0 6px 25px rgba(0,0,0,0.3)"
}}>
<MapContainer
crs={L.CRS.Simple}
minZoom={-2}
style={{ height: "100%", width: "100%" }}
>
<ImageOverlay
url="/plano.png"
bounds={bounds}
/>
<AjustarVista bounds={bounds} />
<HeatLayer />
</MapContainer>
</div>
);
}
+33 -23
View File
@@ -1,10 +1,17 @@
"use client";
import { useState, useEffect } from "react";
import Cookies from "js-cookie";
import axios from "axios";
import "./pregunta7.css";
import ToggleButton from "../Toggle/ToggleButton";
import dynamic from "next/dynamic";
const MapaCalor = dynamic(
() => import("./MapaCalor"),
{ ssr: false }
);
type AntiguedadItem = {
antiguedad: string | null;
@@ -29,47 +36,47 @@ export default function Pregunta7() {
const api_url = process.env.NEXT_PUBLIC_API_URL;
// ------------------------------
// TRANSFORMADOR (maneja null)
// ------------------------------
const transformarDatos = (items: AntiguedadItem[]): string[] => {
let menores2 = 0;
let menor2 = 0;
let entre2_3 = 0;
let entre4_5 = 0;
let mayores6 = 0;
let notfound = 0;
let mayor6 = 0;
for (const item of items) {
const total = Number(item.total) || 0;
const antig = item.antiguedad
? item.antiguedad.toUpperCase().trim()
: null;
const antig = item.antiguedad?.toLowerCase().trim();
switch (antig) {
case "MENORES DE 2":
menores2 += total;
case "menor a 2 años":
menor2 += total;
break;
case "ENTRE 2 Y 3":
case "entre 2 y 3 años":
entre2_3 += total;
break;
case "ENTRE 4 Y 5":
case "entre 4 y 5 años":
entre4_5 += total;
break;
case "ENTRE 6 Y MAYORES":
mayores6 += total;
case "mayor a 6 años":
mayor6 += total;
break;
default:
notfound += total; // incluye null
}
}
const total = menores2 + entre2_3 + entre4_5 + mayores6 + notfound;
const suma = menor2 + entre2_3 + entre4_5 + mayor6;
if (total === 0) return ["0.00", "0.00", "0.00", "0.00"];
if (suma === 0) return ["0.00", "0.00", "0.00", "0.00"];
const pct = (v: number) => ((v / total) * 100).toFixed(2);
const pct = (v: number) => ((v / suma) * 100).toFixed(2);
return [pct(menores2), pct(entre2_3), pct(entre4_5), pct(mayores6)];
return [
pct(menor2), // Menor a 2
pct(entre2_3), // Entre 2 y 3
pct(entre4_5), // Entre 4 y 5
pct(mayor6), // Mayor a 6
];
};
const cargarDatos = async (baja: boolean) => {
@@ -83,7 +90,7 @@ export default function Pregunta7() {
body,
{
headers: { Authorization: `Bearer ${token}` },
}
},
)
.then((res) => {
const { impresion, digitalizacion } = res.data;
@@ -166,6 +173,9 @@ export default function Pregunta7() {
</tbody>
</table>
</div>
<MapaCalor />
</div>
);
}
}
+4 -4
View File
@@ -50,16 +50,16 @@ export default function Pregunta9() {
const total = Number(item.total) || 0;
switch (item.antiguedad) {
case "MENORES DE 2":
case "Menor a 2 años":
menores2 += total;
break;
case "ENTRE 2 Y 3":
case "Entre 2 y 3 años":
entre2_3 += total;
break;
case "ENTRE 4 Y 5":
case "Entre 4 y 5 años":
entre4_6 += total;
break;
case "ENTRE 6 Y MAYORES":
case "Mayor a 6 años":
mayores6 += total;
break;
// Cualquier otro valor (aunque no debería haber) lo meteríamos en mayores6
+1 -1
View File
@@ -18,7 +18,7 @@ function Header() {
"/ranking",
];
const privateNav = ["/equipoComputo", "/crearCuenta", "/perifericos"];
const privateNav = ["/equipoComputo", "/crearCuenta", "/perifericos","/reportesGraficas"];
return (
<header className={header.header}>
@@ -0,0 +1,138 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import {
Bar,
BarChart,
CartesianGrid,
Legend,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis
} from "recharts";
import Cookies from "js-cookie";
interface Props {
filtros: any
}
interface AntiguedadData {
adscripcion: string
antiguedad: string
total: number
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function Antiguedad({ filtros }: Props) {
const [data, setData] = useState<AntiguedadData[]>([])
useEffect(() => {
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
const getAntiguedad = async () => {
const response = await axios.post(
`${api_url}/equipos/grafica/antiguedad`,
filtros,
{ headers }
)
setData(response.data)
}
getAntiguedad()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.antiguedad]) {
acc[item.antiguedad] = { antiguedad: item.antiguedad }
}
acc[item.antiguedad][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div
style={{
minWidth: "570px",
background: "white",
borderRadius: "10px",
padding: "1rem",
maxWidth: "100%"
}}
>
<h1 style={{ margin: "0" }}>Antigüedad por equipo</h1>
<ResponsiveContainer width="100%" aspect={2.5}>
<BarChart
data={dataTransformada}
margin={{ top: 20 }}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="antiguedad" fontSize={12} />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
@@ -0,0 +1,105 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
interface Props {
filtros: any
}
interface procesador {
adscripcion: string
procesador: string;
total: number;
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function Procesador({ filtros }: Props) {
const [data, setData] = useState<procesador[]>([])
useEffect(() => {
const getAntiguedad = async () => {
const response = await axios.post(`${api_url}/equipos/grafica/procesador`, filtros)
setData(response.data)
}
getAntiguedad()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.procesador]) {
acc[item.procesador] = { procesador: item.procesador }
}
acc[item.procesador][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div style={{ width: "100%", background: "white", borderRadius: "10px", margin: "5px auto", padding: "1rem" }}>
<h1 style={{ margin: "0" }}>Procesador por equipo</h1>
<ResponsiveContainer width="100%" aspect={3.5}>
<BarChart data={dataTransformada}
width={500}
height={300}
margin={{
top: 20,
bottom: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="procesador" fontSize={12} angle={40} textAnchor="start" hide />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
@@ -0,0 +1,104 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
interface Props {
filtros: any
}
interface so {
adscripcion: string
so: string;
total: number;
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function SistemaOperativo({ filtros }: Props) {
const [data, setData] = useState<so[]>([])
useEffect(() => {
const getAntiguedad = async () => {
const response = await axios.post(`${api_url}/equipos/grafica/so`, filtros)
setData(response.data)
}
getAntiguedad()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.so]) {
acc[item.so] = { so: item.so }
}
acc[item.so][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div style={{ width: "100%", background: "white", borderRadius: "10px", margin: "5px auto", padding: "1rem" }}>
<h1 style={{ margin: "0" }}>SistemaOperativo por equipo</h1>
<ResponsiveContainer width="100%" aspect={3.5}>
<BarChart data={dataTransformada}
width={500}
height={300}
margin={{
top: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="so" fontSize={12} angle={30} textAnchor="start" hide />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
@@ -0,0 +1,107 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
interface Props {
filtros: any
}
interface UsoData {
uso: string
adscripcion: string
total: number
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function Uso({ filtros }: Props) {
const [data, setData] = useState<UsoData[]>([])
useEffect(() => {
const getUso = async () => {
const response = await axios.post(
`${api_url}/equipos/grafica/uso`, filtros
)
setData(response.data)
}
getUso()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.uso]) {
acc[item.uso] = { uso: item.uso }
}
acc[item.uso][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div style={{ minWidth: "570px", background: "white", borderRadius: "10px", padding: "1rem" }}>
<h1 style={{ margin: "0" }}>Uso por equipo</h1>
<ResponsiveContainer width="100%" aspect={2.5} minHeight={220}>
<BarChart data={dataTransformada}
width={500}
height={300}
margin={{
top: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="uso" fontSize={12} />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
//IO
@@ -0,0 +1,122 @@
.container {
width: 100%;
margin: 0 auto;
padding: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
.title {
font-size: 18px;
margin-bottom: 15px;
}
.label {
font-size: 13px;
color: #444;
}
.listaContainer {
margin-top: 20px;
}
.subtitle {
font-size: 14px;
margin-bottom: 10px;
}
.empty {
font-size: 13px;
color: #777;
}
.lista {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.chip {
display: flex;
align-items: center;
background: linear-gradient(135deg, #2563eb, #7c3aed);
border-radius: 6px;
padding: 5px 10px;
font-size: 13px;
text-align: start;
color: white;
}
.remove {
border: none;
background: rgba(255,255,255,0.2);
margin-left: 8px;
cursor: pointer;
color: white;
border-radius: 50%;
width: 18px;
height: 18px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
transition: all 0.2s ease;
}
.remove:hover {
background: rgba(255,255,255,0.4);
}
.button {
margin-top: 20px;
padding: 12px 20px;
border: none;
border-radius: 10px;
background: linear-gradient(135deg, #2563eb, #4f46e5);
color: white;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.25s ease;
box-shadow: 0 6px 15px rgba(37, 99, 235, 0.3);
}
.button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
}
.graficas {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 1rem;
}
.graficas > div {
background: white;
border-radius: 16px !important;
padding: 15px !important;
box-shadow: 0 10px 25px rgba(0,0,0,0.08);
transition: all 0.3s ease;
}
.graficas > div:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(0,0,0,0.12);
}
.filtro {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: start;
justify-content: space-between;
}
.containerSelection {
width: 100%;
width: 200px
}
@@ -0,0 +1,83 @@
'use client'
import { useEffect, useState } from 'react'
import styles from './TableAntiguedad.module.css'
import axios from 'axios'
import DownloadTable from '@/components/Dowload/tabla'
interface Props {
filtros: any
count: boolean
}
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function TableAntiguedad({ filtros, count }: Props) {
const [data, setData] = useState<any[]>([])
useEffect(() => {
const getUso = async () => {
const endpoint = count
? `${api_url}/equipos/tabla/count`
: `${api_url}/equipos/tabla`
const response = await axios.post(endpoint, filtros)
setData(response.data)
}
getUso()
}, [filtros, count])
const columnas = data.length > 0 ? Object.keys(data[0]) : []
return (
<div className={styles.container}>
{count ? <DownloadTable filtros={filtros} count={true} /> : <DownloadTable filtros={filtros} count={false} />}
<table className={styles.table}>
<thead>
<tr>
{columnas.map((col) => (
<th key={col}>{formatearTitulo(col)}</th>
))}
</tr>
</thead>
<tbody>
{data.length === 0 ? (
<tr>
<td colSpan={columnas.length} className={styles.empty}>
No hay datos
</td>
</tr>
) : (
data.map((item, index) => (
<tr key={index}>
{columnas.map((col) => (
<td key={col}>
{item[col] ?? '-'}
</td>
))}
</tr>
))
)}
</tbody>
</table>
</div>
)
}
function formatearTitulo(col: string) {
const nombres: any = {
inventario: 'No. Inventario',
adscripcion: 'Adscripción',
antiguedad: 'Antigüedad',
procesador: 'Procesador',
sistema_operativo: 'Sistema Operativo',
uso: 'Uso'
}
return nombres[col] || col
}
@@ -0,0 +1,44 @@
.container {
width: 100%;
overflow-x: auto;
}
.table {
width: 100%;
border-collapse: collapse;
font-size: 14px;
background: #ffffff;
border-radius: 12px;
overflow: hidden;
}
.table thead {
background: linear-gradient(135deg, #a5a5a5, #878787);
color: white;
}
.table th {
padding: 12px;
text-align: center;
}
.table td {
padding: 10px 12px;
border-bottom: 1px solid #eee;
}
.table tbody tr:hover {
background-color: #f5f8ff;
transition: 0.2s;
}
.total {
font-weight: bold;
color: #095bd6;
}
.empty {
text-align: center;
padding: 20px;
color: #999;
}
+393
View File
@@ -0,0 +1,393 @@
"use client"
import Select from "react-select"
import { useEffect, useState } from "react"
import styles from "./Reporte.module.css"
import axios from "axios"
import Antiguedad from "./Graficas/Antiguedad"
import Procesador from "./Graficas/Procesador"
import SistemaOperativo from "./Graficas/SistemaOperativo"
import Uso from "./Graficas/Uso"
import Cookies from "js-cookie";
import TableAntiguedad from "./Tablas/Antiguedad"
const api_url = process.env.NEXT_PUBLIC_API_URL;
type AdscripcionOption = {
id_adscripcion: string
adscripcion: string
}
type UsoOption = {
id_uso: string
tipo_uso: string
}
type SoOption = {
id_sistema_operativo: string
sistema_operativo: string
}
type ProcesadorOption = {
id_procesador: string
procesador: string
}
type AntiguedadOption = {
antiguedad: string
}
export default function Reporte() {
const [adscripciones, setAdscripciones] = useState<AdscripcionOption[]>([])
const [adscripcionesSeleccionadas, setAdscripcionesSeleccionadas] = useState<AdscripcionOption[]>([])
const [procesadores, setProcesadores] = useState<ProcesadorOption[]>([])
const [procesadorSeleccionado, setProcesadorSeleccionado] = useState<ProcesadorOption[]>([])
const [sistemasOperativos, setSistemasOperativos] = useState<SoOption[]>([])
const [soSeleccionado, setSoSeleccionado] = useState<SoOption[]>([])
const [usos, setUsos] = useState<UsoOption[]>([{ id_uso: "0", tipo_uso: "Todos" }])
const [usoSeleccionado, setUsoSeleccionado] = useState<UsoOption[]>([])
const [antiguedad, setAntiguedad] = useState<AntiguedadOption[]>([{ antiguedad: "Todos" }, { antiguedad: "Menor a 2 años" }, { antiguedad: "Entre 2 y 3 años" }, { antiguedad: "Entre 4 y 5 años" }, { antiguedad: "Mayor a 6 años" }])
const [antiguedadSeleccionada, setAntiguedadSeleccionada] = useState<AntiguedadOption[]>([])
const [filtros, setFiltros] = useState<any>(null)
const [filtrosTable, setFiltrosTable] = useState<any>(null)
useEffect(() => {
const cargarDatos = async () => {
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
const [
adscripcionRes,
procesadorRes,
usoRes,
soRes,
] = await Promise.all([
axios.get(`${api_url}/equipos/adscripciones`, { headers }),
axios.get(`${api_url}/equipos/procesador-tipo-equipos`, { headers }),
axios.get(`${api_url}/equipos/usos`, { headers }),
axios.get(`${api_url}/equipos/sistemas-operativos`, { headers }),
])
setAdscripciones([
{ id_adscripcion: "0", adscripcion: "Todos" },
...adscripcionRes.data
])
setProcesadores([
{ id_procesador: "0", procesador: "Todos" },
...procesadorRes.data
])
setUsos([
{ id_uso: "0", tipo_uso: "Todos" },
...usoRes.data
])
setSistemasOperativos([
{ id_sistema_operativo: "0", sistema_operativo: "Todos" },
...soRes.data
])
}
cargarDatos()
}, [])
function agregar<T>(option: T | null, lista: T[], setLista: (v: T[]) => void, key: keyof T) {
if (!option) return
const existe = lista.some((item) => item[key] === option[key])
if (!existe) {
setLista([...lista, option])
}
}
function eliminar<T>(id: string, lista: T[], setLista: (v: T[]) => void, key: keyof T) {
setLista(
lista.filter((item) => item[key] !== id)
)
}
const generarReporte = () => {
const limpiar = (arr: string[]) => {
if (arr.includes("0")) return []
return arr
}
const filtrosTable = {
adscripciones: adscripcionesSeleccionadas.map(a => String(a.id_adscripcion)),
procesadores: procesadorSeleccionado.map(p => String(p.id_procesador)),
sistemas: soSeleccionado.map(s => String(s.id_sistema_operativo)),
usos: usoSeleccionado.map(u => String(u.id_uso)),
antiguedad: antiguedadSeleccionada.map(u => String(u.antiguedad))
}
const filtros = {
adscripciones: limpiar(adscripcionesSeleccionadas.map(a => String(a.id_adscripcion))),
procesadores: limpiar(procesadorSeleccionado.map(p => String(p.id_procesador))),
sistemas: limpiar(soSeleccionado.map(s => String(s.id_sistema_operativo))),
usos: limpiar(usoSeleccionado.map(u => String(u.id_uso))),
antiguedad: limpiar(antiguedadSeleccionada.map(a => String(a.antiguedad)))
}
setFiltros(filtros)
setFiltrosTable(filtrosTable)
}
return (
<>
<div className={styles.container}>
<section className={styles.filtro}>
{/* ADSCRIPCION */}
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Adscripción</label>
<Select
options={adscripciones}
getOptionLabel={(o) => o.adscripcion}
getOptionValue={(o) => o.id_adscripcion}
onChange={(o) => agregar(o, adscripcionesSeleccionadas, setAdscripcionesSeleccionadas, "id_adscripcion")}
/>
<div className={styles.lista}>
{adscripcionesSeleccionadas.map((a) => (
<div key={a.id_adscripcion} className={styles.chip}>
<span>{a.adscripcion}</span>
<button
className={styles.remove}
onClick={() => eliminar(a.id_adscripcion, adscripcionesSeleccionadas, setAdscripcionesSeleccionadas, "id_adscripcion")}
>
</button>
</div>
))}
</div>
</div>
{/* PROCESADOR */}
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Procesador</label>
<Select
options={procesadores}
getOptionLabel={(o) => o.procesador}
getOptionValue={(o) => o.id_procesador}
onChange={(o) =>
agregar(o, procesadorSeleccionado, setProcesadorSeleccionado, "id_procesador")
}
/>
<div className={styles.lista}>
{procesadorSeleccionado.map((p) => (
<div key={p.id_procesador} className={styles.chip}>
<span>{p.procesador}</span>
<button
className={styles.remove}
onClick={() =>
eliminar(p.id_procesador, procesadorSeleccionado, setProcesadorSeleccionado, "id_procesador")
}
>
</button>
</div>
))}
</div>
</div>
{/* SISTEMA OPERATIVO */}
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Sistema Operativo</label>
<Select
options={sistemasOperativos}
getOptionLabel={(o) => o.sistema_operativo}
getOptionValue={(o) => o.id_sistema_operativo}
onChange={(o) =>
agregar(o, soSeleccionado, setSoSeleccionado, "id_sistema_operativo")
}
/>
<div className={styles.lista}>
{soSeleccionado.map((s) => (
<div key={s.id_sistema_operativo} className={styles.chip}>
<span>{s.sistema_operativo}</span>
<button
className={styles.remove}
onClick={() =>
eliminar(s.id_sistema_operativo, soSeleccionado, setSoSeleccionado, "id_sistema_operativo")
}
>
</button>
</div>
))}
</div>
</div>
{/* USO */}
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Uso</label>
<Select
options={usos}
getOptionLabel={(o) => o.tipo_uso}
getOptionValue={(o) => o.id_uso}
onChange={(o) =>
agregar(o, usoSeleccionado, setUsoSeleccionado, "id_uso")
}
/>
<div className={styles.lista}>
{usoSeleccionado.map((u) => (
<div key={u.id_uso} className={styles.chip}>
<span>{u.tipo_uso}</span>
<button
className={styles.remove}
onClick={() =>
eliminar(u.id_uso, usoSeleccionado, setUsoSeleccionado, "id_uso")
}
>
</button>
</div>
))}
</div>
</div>
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Antiguedad</label>
<Select
options={antiguedad}
getOptionLabel={(o) => o.antiguedad}
getOptionValue={(o) => o.antiguedad}
onChange={(o) =>
agregar(o, antiguedadSeleccionada, setAntiguedadSeleccionada, "antiguedad")
}
/>
<div className={styles.lista}>
{antiguedadSeleccionada.map((p) => (
<div key={p.antiguedad} className={styles.chip}>
<span>{p.antiguedad}</span>
<button
className={styles.remove}
onClick={() =>
eliminar(p.antiguedad, antiguedadSeleccionada, setAntiguedadSeleccionada, "antiguedad")
}
>
</button>
</div>
))}
</div>
</div>
</section>
<button
className={styles.button}
onClick={generarReporte}
>
Buscar
</button>
</div>
<section className={styles.graficas}>
<Antiguedad
filtros={filtros}
/>
<Uso
filtros={filtros}
/>
<Procesador
filtros={filtros}
/>
<SistemaOperativo
filtros={filtros}
/>
<TableAntiguedad filtros={filtros} count={true} />
<TableAntiguedad filtros={filtrosTable} count={false} />
</section>
</>
)
}
@@ -0,0 +1,138 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import {
Bar,
BarChart,
CartesianGrid,
Legend,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis
} from "recharts";
import Cookies from "js-cookie";
interface Props {
filtros: any
}
interface AntiguedadData {
adscripcion: string
antiguedad: string
total: number
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function Antiguedad({ filtros }: Props) {
const [data, setData] = useState<AntiguedadData[]>([])
useEffect(() => {
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
const getAntiguedad = async () => {
const response = await axios.post(
`${api_url}/equipos/graficaPerifericos/antiguedad`,
filtros,
{ headers }
)
setData(response.data)
}
getAntiguedad()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.antiguedad]) {
acc[item.antiguedad] = { antiguedad: item.antiguedad }
}
acc[item.antiguedad][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div
style={{
minWidth: "570px",
background: "white",
borderRadius: "10px",
padding: "1rem",
maxWidth: "100%"
}}
>
<h1 style={{ margin: "0" }}>Antigüedad por equipo</h1>
<ResponsiveContainer width="100%" aspect={2.5}>
<BarChart
data={dataTransformada}
margin={{ top: 20 }}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="antiguedad" fontSize={12} />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
@@ -0,0 +1,105 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
interface Props {
filtros: any
}
interface procesador {
adscripcion: string
procesador: string;
total: number;
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function Procesador({ filtros }: Props) {
const [data, setData] = useState<procesador[]>([])
useEffect(() => {
const getAntiguedad = async () => {
const response = await axios.post(`${api_url}/equipos/graficaPerifericos/procesador`, filtros)
setData(response.data)
}
getAntiguedad()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.procesador]) {
acc[item.procesador] = { procesador: item.procesador }
}
acc[item.procesador][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div style={{ width: "100%", background: "white", borderRadius: "10px", margin: "5px auto", padding: "1rem" }}>
<h1 style={{ margin: "0" }}>Procesador por equipo</h1>
<ResponsiveContainer width="100%" aspect={3.5}>
<BarChart data={dataTransformada}
width={500}
height={300}
margin={{
top: 20,
bottom: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="procesador" fontSize={12} angle={40} textAnchor="start" hide />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
@@ -0,0 +1,104 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
interface Props {
filtros: any
}
interface so {
adscripcion: string
so: string;
total: number;
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function SistemaOperativo({ filtros }: Props) {
const [data, setData] = useState<so[]>([])
useEffect(() => {
const getAntiguedad = async () => {
const response = await axios.post(`${api_url}/equipos/graficaPerifericos/so`, filtros)
setData(response.data)
}
getAntiguedad()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.so]) {
acc[item.so] = { so: item.so }
}
acc[item.so][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div style={{ width: "100%", background: "white", borderRadius: "10px", margin: "5px auto", padding: "1rem" }}>
<h1 style={{ margin: "0" }}>SistemaOperativo por equipo</h1>
<ResponsiveContainer width="100%" aspect={3.5}>
<BarChart data={dataTransformada}
width={500}
height={300}
margin={{
top: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="so" fontSize={12} angle={30} textAnchor="start" hide />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
@@ -0,0 +1,107 @@
'use client'
import axios from "axios";
import { useEffect, useState } from "react";
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
interface Props {
filtros: any
}
interface UsoData {
uso: string
adscripcion: string
total: number
}
const colores = [
"#818CF8",
"#34D399",
"#FBBF24",
"#F87171",
"#67E8F9",
"#C084FC"
]
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function Uso({ filtros }: Props) {
const [data, setData] = useState<UsoData[]>([])
useEffect(() => {
const getUso = async () => {
const response = await axios.post(
`${api_url}/equipos/graficaPerifericos/uso`, filtros
)
setData(response.data)
}
getUso()
}, [filtros])
const tieneAdscripciones = data.some(d => d.adscripcion)
let dataTransformada = data
let adscripciones: string[] = []
if (tieneAdscripciones) {
adscripciones = [...new Set(data.map(d => d.adscripcion))]
dataTransformada = Object.values(
data.reduce((acc: any, item: any) => {
if (!acc[item.uso]) {
acc[item.uso] = { uso: item.uso }
}
acc[item.uso][item.adscripcion] = Number(item.total)
return acc
}, {})
)
}
return (
<div style={{ minWidth: "570px", background: "white", borderRadius: "10px", padding: "1rem" }}>
<h1 style={{ margin: "0" }}>Uso por equipo</h1>
<ResponsiveContainer width="100%" aspect={2.5} minHeight={220}>
<BarChart data={dataTransformada}
width={500}
height={300}
margin={{
top: 20,
}}
>
<CartesianGrid strokeDasharray="3 3" />
<XAxis dataKey="uso" fontSize={12} />
<YAxis />
<Tooltip
formatter={(value) => [`${value}`]}
/>
<Legend />
{tieneAdscripciones ? (
adscripciones.map((ads, i) => (
<Bar
key={ads}
dataKey={ads}
fill={colores[i % colores.length]}
/>
))
) : (
<Bar
dataKey="total"
fill="#095bd6"
/>
)}
</BarChart>
</ResponsiveContainer>
</div>
)
}
//IO
@@ -0,0 +1,122 @@
.container {
width: 100%;
margin: 0 auto;
padding: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
.title {
font-size: 18px;
margin-bottom: 15px;
}
.label {
font-size: 13px;
color: #444;
}
.listaContainer {
margin-top: 20px;
}
.subtitle {
font-size: 14px;
margin-bottom: 10px;
}
.empty {
font-size: 13px;
color: #777;
}
.lista {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.chip {
display: flex;
align-items: center;
background: linear-gradient(135deg, #2563eb, #7c3aed);
border-radius: 6px;
padding: 5px 10px;
font-size: 13px;
text-align: start;
color: white;
}
.remove {
border: none;
background: rgba(255,255,255,0.2);
margin-left: 8px;
cursor: pointer;
color: white;
border-radius: 50%;
width: 18px;
height: 18px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
transition: all 0.2s ease;
}
.remove:hover {
background: rgba(255,255,255,0.4);
}
.button {
margin-top: 20px;
padding: 12px 20px;
border: none;
border-radius: 10px;
background: linear-gradient(135deg, #2563eb, #4f46e5);
color: white;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.25s ease;
box-shadow: 0 6px 15px rgba(37, 99, 235, 0.3);
}
.button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
}
.graficas {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 1rem;
}
.graficas > div {
background: white;
border-radius: 16px !important;
padding: 15px !important;
box-shadow: 0 10px 25px rgba(0,0,0,0.08);
transition: all 0.3s ease;
}
.graficas > div:hover {
transform: translateY(-5px);
box-shadow: 0 15px 35px rgba(0,0,0,0.12);
}
.filtro {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: start;
justify-content: space-between;
}
.containerSelection {
width: 100%;
width: 200px
}
@@ -0,0 +1,83 @@
'use client'
import { useEffect, useState } from 'react'
import styles from './TableAntiguedad.module.css'
import axios from 'axios'
import DownloadTable from '@/components/Dowload/tabla'
interface Props {
filtros: any
count: boolean
}
const api_url = process.env.NEXT_PUBLIC_API_URL;
export default function TableAntiguedad({ filtros, count }: Props) {
const [data, setData] = useState<any[]>([])
useEffect(() => {
const getUso = async () => {
const endpoint = count
? `${api_url}/equipos/tabla/count`
: `${api_url}/equipos/tabla`
const response = await axios.post(endpoint, filtros)
setData(response.data)
}
getUso()
}, [filtros, count])
const columnas = data.length > 0 ? Object.keys(data[0]) : []
return (
<div className={styles.container}>
{count ? <DownloadTable filtros={filtros} count={true} /> : <DownloadTable filtros={filtros} count={false} />}
<table className={styles.table}>
<thead>
<tr>
{columnas.map((col) => (
<th key={col}>{formatearTitulo(col)}</th>
))}
</tr>
</thead>
<tbody>
{data.length === 0 ? (
<tr>
<td colSpan={columnas.length} className={styles.empty}>
No hay datos
</td>
</tr>
) : (
data.map((item, index) => (
<tr key={index}>
{columnas.map((col) => (
<td key={col}>
{item[col] ?? '-'}
</td>
))}
</tr>
))
)}
</tbody>
</table>
</div>
)
}
function formatearTitulo(col: string) {
const nombres: any = {
inventario: 'No. Inventario',
adscripcion: 'Adscripción',
antiguedad: 'Antigüedad',
procesador: 'Procesador',
sistema_operativo: 'Sistema Operativo',
uso: 'Uso'
}
return nombres[col] || col
}
@@ -0,0 +1,44 @@
.container {
width: 100%;
overflow-x: auto;
}
.table {
width: 100%;
border-collapse: collapse;
font-size: 14px;
background: #ffffff;
border-radius: 12px;
overflow: hidden;
}
.table thead {
background: linear-gradient(135deg, #a5a5a5, #878787);
color: white;
}
.table th {
padding: 12px;
text-align: center;
}
.table td {
padding: 10px 12px;
border-bottom: 1px solid #eee;
}
.table tbody tr:hover {
background-color: #f5f8ff;
transition: 0.2s;
}
.total {
font-weight: bold;
color: #095bd6;
}
.empty {
text-align: center;
padding: 20px;
color: #999;
}
@@ -0,0 +1,269 @@
"use client"
import Select from "react-select"
import { useEffect, useState } from "react"
import styles from "./Reporte.module.css"
import axios from "axios"
import Antiguedad from "./Graficas/Antiguedad"
import Uso from "./Graficas/Uso"
import Cookies from "js-cookie";
const api_url = process.env.NEXT_PUBLIC_API_URL;
type AdscripcionOption = {
id_adscripcion: string
adscripcion: string
}
type UsoOption = {
id_uso: string
tipo_uso: string
}
type AntiguedadOption = {
antiguedad: string
}
export default function ReportePerifericos() {
const [adscripciones, setAdscripciones] = useState<AdscripcionOption[]>([])
const [adscripcionesSeleccionadas, setAdscripcionesSeleccionadas] = useState<AdscripcionOption[]>([])
const [usos, setUsos] = useState<UsoOption[]>([{ id_uso: "0", tipo_uso: "Todos" }])
const [usoSeleccionado, setUsoSeleccionado] = useState<UsoOption[]>([])
const [antiguedad, setAntiguedad] = useState<AntiguedadOption[]>([{ antiguedad: "Todos" }, { antiguedad: "Menor a 2 años" }, { antiguedad: "Entre 2 y 3 años" }, { antiguedad: "Entre 4 y 5 años" }, { antiguedad: "Mayor a 6 años" }])
const [antiguedadSeleccionada, setAntiguedadSeleccionada] = useState<AntiguedadOption[]>([])
const [filtros, setFiltros] = useState<any>(null)
const [filtrosTable, setFiltrosTable] = useState<any>(null)
useEffect(() => {
const cargarDatos = async () => {
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
const [
adscripcionRes,
procesadorRes,
usoRes,
soRes,
] = await Promise.all([
axios.get(`${api_url}/equipos/adscripciones`, { headers }),
axios.get(`${api_url}/equipos/procesador-tipo-equipos`, { headers }),
axios.get(`${api_url}/equipos/usos`, { headers }),
axios.get(`${api_url}/equipos/sistemas-operativos`, { headers }),
])
setAdscripciones([
{ id_adscripcion: "0", adscripcion: "Todos" },
...adscripcionRes.data
])
setUsos([
{ id_uso: "0", tipo_uso: "Todos" },
...usoRes.data
])
}
cargarDatos()
}, [])
function agregar<T>(option: T | null, lista: T[], setLista: (v: T[]) => void, key: keyof T) {
if (!option) return
const existe = lista.some((item) => item[key] === option[key])
if (!existe) {
setLista([...lista, option])
}
}
function eliminar<T>(id: string, lista: T[], setLista: (v: T[]) => void, key: keyof T) {
setLista(
lista.filter((item) => item[key] !== id)
)
}
const generarReporte = () => {
const limpiar = (arr: string[]) => {
if (arr.includes("0")) return []
return arr
}
const filtrosTable = {
adscripciones: adscripcionesSeleccionadas.map(a => String(a.id_adscripcion)),
usos: usoSeleccionado.map(u => String(u.id_uso)),
antiguedad: antiguedadSeleccionada.map(u => String(u.antiguedad))
}
const filtros = {
adscripciones: limpiar(adscripcionesSeleccionadas.map(a => String(a.id_adscripcion))),
usos: limpiar(usoSeleccionado.map(u => String(u.id_uso))),
antiguedad: limpiar(antiguedadSeleccionada.map(a => String(a.antiguedad)))
}
setFiltros(filtros)
setFiltrosTable(filtrosTable)
}
return (
<>
<div className={styles.container}>
<section className={styles.filtro}>
{/* ADSCRIPCION */}
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Adscripción</label>
<Select
options={adscripciones}
getOptionLabel={(o) => o.adscripcion}
getOptionValue={(o) => o.id_adscripcion}
onChange={(o) => agregar(o, adscripcionesSeleccionadas, setAdscripcionesSeleccionadas, "id_adscripcion")}
/>
<div className={styles.lista}>
{adscripcionesSeleccionadas.map((a) => (
<div key={a.id_adscripcion} className={styles.chip}>
<span>{a.adscripcion}</span>
<button
className={styles.remove}
onClick={() => eliminar(a.id_adscripcion, adscripcionesSeleccionadas, setAdscripcionesSeleccionadas, "id_adscripcion")}
>
</button>
</div>
))}
</div>
</div>
{/* USO */}
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Uso</label>
<Select
options={usos}
getOptionLabel={(o) => o.tipo_uso}
getOptionValue={(o) => o.id_uso}
onChange={(o) =>
agregar(o, usoSeleccionado, setUsoSeleccionado, "id_uso")
}
/>
<div className={styles.lista}>
{usoSeleccionado.map((u) => (
<div key={u.id_uso} className={styles.chip}>
<span>{u.tipo_uso}</span>
<button
className={styles.remove}
onClick={() =>
eliminar(u.id_uso, usoSeleccionado, setUsoSeleccionado, "id_uso")
}
>
</button>
</div>
))}
</div>
</div>
<div className={styles.containerSelection}>
<label className={styles.adscripcion}>Antiguedad</label>
<Select
options={antiguedad}
getOptionLabel={(o) => o.antiguedad}
getOptionValue={(o) => o.antiguedad}
onChange={(o) =>
agregar(o, antiguedadSeleccionada, setAntiguedadSeleccionada, "antiguedad")
}
/>
<div className={styles.lista}>
{antiguedadSeleccionada.map((p) => (
<div key={p.antiguedad} className={styles.chip}>
<span>{p.antiguedad}</span>
<button
className={styles.remove}
onClick={() =>
eliminar(p.antiguedad, antiguedadSeleccionada, setAntiguedadSeleccionada, "antiguedad")
}
>
</button>
</div>
))}
</div>
</div>
</section>
<button
className={styles.button}
onClick={generarReporte}
>
Buscar
</button>
</div>
<section className={styles.graficas}>
<Antiguedad
filtros={filtros}
/>
<Uso
filtros={filtros}
/>
</section>
</>
)
}
+2 -2
View File
@@ -3,8 +3,8 @@ import type { NextRequest } from "next/server";
import { jwtDecode } from "jwt-decode";
const permisos: Record<number, string[]> = {
1: ["/crearCuenta", "/equipoComputo", "/perifericos","/escaner", "/agregarEquipo", "/editar","/historial","/ranking","/cambiarPass"],
2: ["/escaner", "/agregarEquipo", "/editar","/historial","/ranking","/cambiarPass"],
1: ["/crearCuenta", "/equipoComputo", "/perifericos", "/escaner", "/hotmap", "/agregarEquipo", "/editar", "/historial", "/ranking", "/cambiarPass", "/reportesGraficas"],
2: ["/escaner", "/agregarEquipo", "/editar", "/historial", "/ranking", "/cambiarPass"],
};
export function proxy(request: NextRequest) {