fixed code
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user