fixed code

This commit is contained in:
2025-12-04 19:56:47 -06:00
parent 59274690b1
commit 106784c4dd
2 changed files with 31 additions and 23 deletions
+26 -22
View File
@@ -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 && (
<button className="button buttonSearch" style={{ marginTop: "1rem" }}>
<button
className="button buttonSearch"
style={{ marginTop: "1rem" }}
>
Registrar Estudiante
</button>
)}
@@ -133,4 +137,4 @@ export default async function Page(props: {
)}
</section>
);
}
}
+5 -1
View File
@@ -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"
},