added censado por and tring to fix reportes
This commit is contained in:
@@ -7,8 +7,9 @@ import style from "./pregunta1_1.module.scss";
|
||||
import ToggleButton from "../Toggle/ToggleButton";
|
||||
|
||||
type RawEntry = {
|
||||
uso: string;
|
||||
categoria: string;
|
||||
tipo_equipo: string;
|
||||
tipo_uso: string;
|
||||
sistema_operativo: string;
|
||||
total: string;
|
||||
};
|
||||
|
||||
@@ -20,14 +21,21 @@ const USO_INDEX: Record<string, number> = {
|
||||
ADMINISTRATIVO: 4,
|
||||
};
|
||||
|
||||
const CATEGORIA_MAP: Record<string, { tabla: number; so: string }> = {
|
||||
"ESCRITORIO PC": { tabla: 0, so: "Windows" },
|
||||
"ESCRITORIO MAC OS": { tabla: 0, so: "Mac OS" },
|
||||
"ESCRITORIO LINUX": { tabla: 0, so: "Linux" },
|
||||
"PORTÁTILES WINDOWS": { tabla: 2, so: "Windows" },
|
||||
"PORTÁTILES MAC OS": { tabla: 2, so: "Mac OS" },
|
||||
"TABLETA iPAD OS": { tabla: 1, so: "Mac OS" },
|
||||
SERVIDOR: { tabla: 3, so: "Linux" },
|
||||
const CATEGORIA_MAP: Record<string, { tabla: number }> = {
|
||||
"ESCRITORIO PC": { tabla: 0 },
|
||||
"ESCRITORIO MAC OS": { tabla: 0 },
|
||||
"ESCRITORIO MAC OS ": { tabla: 0 }, // tiene espacio al final
|
||||
|
||||
"ESCRITORIO LINUX": { tabla: 0 },
|
||||
|
||||
"PORTÁTILES WINDOWS": { tabla: 2 },
|
||||
"PORTÁTILES MAC OS": { tabla: 2 },
|
||||
"PORTÁTILES LINUX": { tabla: 2 },
|
||||
|
||||
"TABLETA IPAD OS": { tabla: 1 },
|
||||
"TABLETA ANDROID": { tabla: 1 },
|
||||
|
||||
SERVIDOR: { tabla: 3 },
|
||||
};
|
||||
|
||||
const TITULOS_TABLAS = [
|
||||
@@ -37,14 +45,37 @@ const TITULOS_TABLAS = [
|
||||
"Alto rendimiento",
|
||||
];
|
||||
|
||||
const SISTEMAS_OPERATIVOS = ["Windows", "Linux", "Mac OS"];
|
||||
const SISTEMAS_POR_TABLA: Record<number, readonly string[]> = {
|
||||
0: ["Windows", "Linux", "Mac OS"],
|
||||
1: ["Android", "iPad OS"],
|
||||
2: ["Windows", "Linux", "Mac OS"],
|
||||
3: ["Servidor"],
|
||||
};
|
||||
|
||||
function normalizarSO(soRaw: string): string {
|
||||
const so = soRaw.trim().toUpperCase();
|
||||
|
||||
if (so.includes("WINDOWS")) return "Windows";
|
||||
if (so.includes("LINUX")) return "Linux";
|
||||
if (so.includes("MAC")) return "Mac OS";
|
||||
if (so.includes("CHROME")) return "Chrome OS";
|
||||
if (so.includes("IOS") || so.includes("IPAD")) return "iPad OS";
|
||||
|
||||
// Servidores
|
||||
if (so.includes("SERVER") || so.includes("UNIX")) return "Servidor";
|
||||
|
||||
return "Otro";
|
||||
}
|
||||
|
||||
export default function Pregunta1() {
|
||||
const [tablas, setTablas] = useState<number[][][]>(
|
||||
Array.from({ length: 4 }, () =>
|
||||
Array.from({ length: 3 }, () => Array(5).fill(0))
|
||||
)
|
||||
);
|
||||
const crearTablas = () =>
|
||||
Array.from({ length: 4 }, (_, tablaIndex) =>
|
||||
Array.from({ length: SISTEMAS_POR_TABLA[tablaIndex].length }, () =>
|
||||
Array(5).fill(0)
|
||||
)
|
||||
);
|
||||
|
||||
const [tablas, setTablas] = useState<number[][][]>(crearTablas());
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@@ -70,19 +101,30 @@ export default function Pregunta1() {
|
||||
);
|
||||
|
||||
for (const item of res.data) {
|
||||
const categoria = item.categoria.trim();
|
||||
const categoria = item.tipo_equipo.trim().toUpperCase();
|
||||
const mapping = CATEGORIA_MAP[categoria];
|
||||
if (!mapping) continue;
|
||||
|
||||
const { tabla, so } = mapping;
|
||||
const soIndex = SISTEMAS_OPERATIVOS.indexOf(so);
|
||||
if (soIndex === -1) continue;
|
||||
const { tabla } = mapping;
|
||||
|
||||
const usoIndex = USO_INDEX[item.uso];
|
||||
let soIndex = -1;
|
||||
|
||||
// 🟦 Caso especial: SERVIDOR → siempre a la fila "Servidor"
|
||||
if (tabla === 3) {
|
||||
soIndex = 0; // único SO disponible en SISTEMAS_POR_TABLA[3]
|
||||
} else {
|
||||
const soNormalizado = normalizarSO(item.sistema_operativo);
|
||||
soIndex = SISTEMAS_POR_TABLA[tabla].indexOf(soNormalizado);
|
||||
if (soIndex === -1) continue;
|
||||
}
|
||||
|
||||
const usoIndex = USO_INDEX[item.tipo_uso.toUpperCase()];
|
||||
if (usoIndex === undefined) continue;
|
||||
|
||||
const total = parseInt(item.total) || 0;
|
||||
nuevaTablas[tabla][soIndex][usoIndex] = total;
|
||||
|
||||
// 🔥 Corrección importante → SUMAR, no reemplazar
|
||||
nuevaTablas[tabla][soIndex][usoIndex] += total;
|
||||
}
|
||||
|
||||
setTablas(nuevaTablas);
|
||||
@@ -125,7 +167,7 @@ export default function Pregunta1() {
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{SISTEMAS_OPERATIVOS.map((so, soIndex) => {
|
||||
{SISTEMAS_POR_TABLA[tablaIndex].map((so, soIndex) => {
|
||||
const valores = datosSO[soIndex];
|
||||
const totalFila = valores.reduce((a, b) => a + b, 0);
|
||||
|
||||
@@ -183,11 +225,8 @@ export default function Pregunta1() {
|
||||
|
||||
<div className={style["contenedor-tablas"]}>
|
||||
{renderTabla(0)}
|
||||
{renderTabla(1)}
|
||||
</div>
|
||||
|
||||
<div className={style["contenedor-tablas"]}>
|
||||
{renderTabla(2)}
|
||||
{renderTabla(1)}
|
||||
{renderTabla(3)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import Cookies from "js-cookie";
|
||||
import axios from "axios";
|
||||
import "./pregunta9.css";
|
||||
import Pregunta10 from "./pregunta10";
|
||||
import ToggleButton from "../Toggle/ToggleButton";
|
||||
|
||||
import "./pregunta9.css";
|
||||
|
||||
type AntiguedadItem = {
|
||||
antiguedad: string | null;
|
||||
total: string;
|
||||
@@ -23,15 +24,15 @@ export default function Pregunta9() {
|
||||
const [datos, setDatos] = useState([
|
||||
{
|
||||
nombre: "Computadoras de Escritorio",
|
||||
valores: ["0.00", "0.00", "0.00", "0.00", "0.00"],
|
||||
valores: ["0.00", "0.00", "0.00", "0.00"],
|
||||
},
|
||||
{
|
||||
nombre: "Computadoras Portátiles",
|
||||
valores: ["0.00", "0.00", "0.00", "0.00", "0.00"],
|
||||
valores: ["0.00", "0.00", "0.00", "0.00"],
|
||||
},
|
||||
{
|
||||
nombre: "Alto Rendimiento",
|
||||
valores: ["0.00", "0.00", "0.00", "0.00", "0.00"],
|
||||
valores: ["0.00", "0.00", "0.00", "0.00"],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -44,7 +45,6 @@ export default function Pregunta9() {
|
||||
let entre4_6 = 0;
|
||||
|
||||
let mayores6 = 0;
|
||||
let notfound = 0;
|
||||
|
||||
for (const item of items) {
|
||||
const total = Number(item.total) || 0;
|
||||
@@ -64,15 +64,15 @@ export default function Pregunta9() {
|
||||
break;
|
||||
// Cualquier otro valor (aunque no debería haber) lo meteríamos en mayores6
|
||||
default:
|
||||
notfound += total;
|
||||
mayores6 += total;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const totalEquipo = menores2 + mayores6 + entre2_3 + entre4_6 + notfound;
|
||||
const totalEquipo = menores2 + mayores6 + entre2_3 + entre4_6 ;
|
||||
|
||||
if (totalEquipo === 0) {
|
||||
return ["0.00", "0.00", "0.00", "0.00", "0.00"];
|
||||
return ["0.00", "0.00", "0.00", "0.00"];
|
||||
}
|
||||
|
||||
const pct = (valor: number) => ((valor / totalEquipo) * 100).toFixed(2);
|
||||
@@ -82,7 +82,6 @@ export default function Pregunta9() {
|
||||
pct(entre2_3),
|
||||
pct(entre4_6),
|
||||
pct(mayores6),
|
||||
pct(notfound),
|
||||
];
|
||||
};
|
||||
|
||||
@@ -172,7 +171,6 @@ export default function Pregunta9() {
|
||||
<th className="rosa-fuerte">Entre 2 y 3 años</th>
|
||||
<th className="rosa-fuerte">Entre 4 y 5 años</th>
|
||||
<th className="rosa-fuerte">Mayor a 6 años</th>
|
||||
<th className="rosa-fuerte">No registrados</th>
|
||||
<th className="azul-marino">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -62,7 +62,7 @@ export default function Pregunta10() {
|
||||
return (
|
||||
<>
|
||||
<div className="pregunta-cuadro">
|
||||
Equipos de cómputo que tienen garantía de proveedoro.
|
||||
Equipos de cómputo que tienen garantía de proveedor.
|
||||
<ToggleButton
|
||||
onChange={(estado) => {
|
||||
cargarDatos(estado);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
.tabla-contenedor {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
overflow-x: auto;
|
||||
@@ -41,14 +41,15 @@
|
||||
|
||||
th,
|
||||
td {
|
||||
text-align: center;
|
||||
border: 1px solid #ddd;
|
||||
padding: 12px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
th {
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
td {
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
background: #f8fafc;
|
||||
font-size: 14px;
|
||||
transition: 0.2s ease;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.inputBox_P3:focus {
|
||||
|
||||
Reference in New Issue
Block a user