diff --git a/src/components/Equipo_Computo/Pregunta7.tsx b/src/components/Equipo_Computo/Pregunta7.tsx index cab7d85..4d57ef0 100644 --- a/src/components/Equipo_Computo/Pregunta7.tsx +++ b/src/components/Equipo_Computo/Pregunta7.tsx @@ -29,47 +29,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 +83,7 @@ export default function Pregunta7() { body, { headers: { Authorization: `Bearer ${token}` }, - } + }, ) .then((res) => { const { impresion, digitalizacion } = res.data;