diff --git a/src/components/Equipo_Computo/Pregunta2.tsx b/src/components/Equipo_Computo/Pregunta2.tsx index 9256903..5aa3b5f 100644 --- a/src/components/Equipo_Computo/Pregunta2.tsx +++ b/src/components/Equipo_Computo/Pregunta2.tsx @@ -31,22 +31,17 @@ interface RawOsEntry { sistema_operativo: string; total: string; } -// Función profesional para transformar tu JSON a OsEntry[] -function transformPlatform(raw: RawOsEntry[]): OsEntry[] { - const rows: OsEntry[] = raw.map((item) => ({ - os: item.sistema_operativo, - count: Number(item.total), // Convierte string a número - })); - const order = { +function transformPlatform(raw: RawOsEntry[]): OsEntry[] { + const order: Record = { "Windows 11": 1, "Windows 10": 2, "Windows 7/8": 3, "Windows XP/Vista": 4, Linux: 5, - "Mac OS (13 - Ventura, 14 - Sonoma)": 6, - "MAC OS (SEQUOIA)": 7, + "MAC OS (SEQUOIA)": 6, + "Mac OS (13 - Ventura, 14 - Sonoma)": 7, "Mac OS X (Mojave, Catalina, 11 - Big Sur, 12 - Monterrey)": 8, "Mac OS X (Snow Leopard, Lion, Mountain Lion, Mavericks)": 9, "Mac OS X (Yosemite, El Capitan, Sierra, High Sierra)": 10, @@ -60,7 +55,24 @@ function transformPlatform(raw: RawOsEntry[]): OsEntry[] { "Windows Server 2016/2019": 15, "Windows Server 2008/2012": 16, "Windows Server 2000/2003": 17, - } as const; + }; + + function cleanName(rawName: string): string { + return rawName + .normalize("NFKD") + .replace(/\u00A0/g, " ") + .replace(/\s+/g, " ") + .trim(); + } + + // mapeamos y limpiamos antes del sort + const rows: OsEntry[] = raw.map((item) => { + const cleaned = cleanName(item.sistema_operativo); + return { + os: cleaned, + count: Number(item.total), + }; + }); rows.sort((a, b) => { const orderA = (order as Record)[a.os] ?? 999;