diff --git a/app/(private)/AsignacionEquipo/page.tsx b/app/(private)/AsignacionEquipo/page.tsx index a0a4659..17b4e86 100644 --- a/app/(private)/AsignacionEquipo/page.tsx +++ b/app/(private)/AsignacionEquipo/page.tsx @@ -7,6 +7,30 @@ import Information from "@/app/Components/Global/Information/information"; import ShowError from "@/app/Components/Global/ShowError"; import "@/app/globals.css"; +import Table from "@/app/Components/Global/table"; +import { envConfig } from "@/app/lib/config"; + +async function getInscripcion(idCuenta: number) { + try { + const res = await fetch(`${envConfig.apiUrl}/alumno-inscrito/${idCuenta}`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + cache: "no-store", + }); + + if (!res.ok) { + throw new Error(`Error ${res.status}: ${res.statusText}`); + } + + return await res.json(); + } catch (error: any) { + return { error: error.message || "No se pudo cargar la inscripción" }; + } +} + +const headers = ["Inscrito", "Tiempo", "Confirmó"]; export default async function Page(props: { searchParams?: Promise<{ @@ -21,18 +45,37 @@ export default async function Page(props: { const machine = params?.machine ? params.machine : null; let student: any = null; + let inscripcion: any = null; let errorMessage = ""; if (numAcount) { - const result = await GetStudent(parseInt(numAcount)); + const idCuenta = parseInt(numAcount); + const result = await GetStudent(idCuenta); if (result.error) { errorMessage = `${result.error}`; } else { student = result as Student; } + + const inscResult = await getInscripcion(idCuenta); + if (!inscResult.error && Array.isArray(inscResult)) { + inscripcion = inscResult; + } else { + inscripcion = []; + } } + const tableData = Array.isArray(inscripcion) + ? inscripcion.map((ins) => ({ + Inscrito: ins.plataforma?.nombre || "—", + Tiempo: ins.tiempo_disponible + ? `${ins.tiempo_disponible} minutos` + : "—", + Confirmó: ins.platica.data === 1 ? "sí" : "no", + })) + : []; + return (
{errorMessage && } @@ -55,11 +98,7 @@ export default async function Page(props: { NoCuenta={student.id_cuenta} nombre={student.nombre} /> - +
diff --git a/app/globals.css b/app/globals.css index 1626223..2f2018e 100644 --- a/app/globals.css +++ b/app/globals.css @@ -101,7 +101,6 @@ footer p { .containerForm { width: 100%; max-width: 450px; - gap:10px; } .img { @@ -283,7 +282,7 @@ a { .informationKey { font-weight: 600; text-transform: capitalize; - width: 100px; + min-width: 80px; } .informationValue {