From 106784c4ddfc8c0b13f8bd27c47342cedcd5205b Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Thu, 4 Dec 2025 19:56:47 -0600 Subject: [PATCH] fixed code --- app/(private)/Inscripcion/page.tsx | 48 ++++++++++++++++-------------- package-lock.json | 6 +++- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/app/(private)/Inscripcion/page.tsx b/app/(private)/Inscripcion/page.tsx index 9bfeddd..d8e0acc 100644 --- a/app/(private)/Inscripcion/page.tsx +++ b/app/(private)/Inscripcion/page.tsx @@ -9,14 +9,16 @@ import Table from "@/app/Components/Global/table"; async function getInscripcion(idCuenta: number) { try { - const res = await fetch(`http://localhost:5000/alumno-inscrito/${idCuenta}`, { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - // Desactiva caché si los datos pueden cambiar frecuentemente - cache: "no-store", - }); + const res = await fetch( + `http://localhost:5000/alumno-inscrito/${idCuenta}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + cache: "no-store", + } + ); if (!res.ok) { throw new Error(`Error ${res.status}: ${res.statusText}`); @@ -52,23 +54,22 @@ export default async function Page(props: { student = studentResult; } const inscResult = await getInscripcion(idCuenta); - if (!inscResult.error) { + + if (!inscResult.error && Array.isArray(inscResult)) { inscripcion = inscResult; } else { - + inscripcion = []; } } - const tableData = inscripcion - ? [ - { - Inscrito: inscripcion.plataforma?.nombre || "—", - Tiempo: inscripcion.tiempo_disponible - ? `${Math.floor(inscripcion.tiempo_disponible / 60)} minutos` - : "—", - Confirmó: inscripcion.realizo_pago === 1 ? "sí" : "no", - }, - ] + const tableData = Array.isArray(inscripcion) + ? inscripcion.map((ins) => ({ + Inscrito: ins.plataforma?.nombre || "—", + Tiempo: ins.tiempo_disponible + ? `${Math.floor(ins.tiempo_disponible / 60)} horas` + : "—", + Confirmó: ins.platica.data === 1 ? "sí" : "no", + })) : []; return ( @@ -92,7 +93,10 @@ export default async function Page(props: { )} {!student && numAcount && ( - )} @@ -133,4 +137,4 @@ export default async function Page(props: { )} ); -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 6fbc9c2..7483040 100644 --- a/package-lock.json +++ b/package-lock.json @@ -619,6 +619,7 @@ "integrity": "sha512-EhBeSYX0Y6ye8pNebpKrwFJq7BoQ8J5SO6NlvNwwHjSj6adXJViPQrKlsyPw7hLBLvckEMO1yxeGdR82YBBlDg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "csstype": "^3.0.2" } @@ -759,7 +760,8 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/delayed-stream": { "version": "1.0.0", @@ -1142,6 +1144,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -1151,6 +1154,7 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", "license": "MIT", + "peer": true, "dependencies": { "scheduler": "^0.26.0" },