2025-09-26 16:56:07 -06:00
|
|
|
import SearchUser from "@/app/Components/Global/SearchUser/searchUser";
|
|
|
|
|
import Information from "@/app/Components/Global/Information/information";
|
2025-10-08 12:01:52 -06:00
|
|
|
import ShowError from "@/app/Components/Global/ShowError";
|
|
|
|
|
import Table from "@/app/Components/Global/table";
|
2026-01-16 14:47:32 -06:00
|
|
|
import Inscripcion from "@/app/Components/Receipt/Inscripcion";
|
|
|
|
|
import { GetStudent } from "@/app/lib/getStudent";
|
2026-01-09 14:56:39 -06:00
|
|
|
import { envConfig } from "@/app/lib/config";
|
|
|
|
|
|
2026-01-22 10:11:08 -06:00
|
|
|
import Link from "next/link";
|
2026-02-18 19:14:37 -06:00
|
|
|
import "./inscripcion.css";
|
2026-01-13 18:51:56 -06:00
|
|
|
|
2026-01-09 14:56:39 -06:00
|
|
|
if (!envConfig.apiUrl) {
|
|
|
|
|
console.error("API URL is not defined in envConfig");
|
|
|
|
|
}
|
2025-09-22 05:27:32 -06:00
|
|
|
|
2025-12-04 18:49:30 -06:00
|
|
|
async function getInscripcion(idCuenta: number) {
|
|
|
|
|
try {
|
2026-01-22 10:11:08 -06:00
|
|
|
const res = await fetch(`${envConfig.apiUrl}/alumno-inscrito/${idCuenta}`, {
|
|
|
|
|
method: "GET",
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
cache: "no-store",
|
|
|
|
|
});
|
2025-12-04 18:49:30 -06:00
|
|
|
|
|
|
|
|
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ó"];
|
|
|
|
|
|
2025-09-22 13:27:42 -06:00
|
|
|
export default async function Page(props: {
|
2025-09-22 05:27:32 -06:00
|
|
|
searchParams?: Promise<{
|
2025-09-22 13:27:42 -06:00
|
|
|
numAcount: string;
|
|
|
|
|
}>;
|
2025-09-22 05:27:32 -06:00
|
|
|
}) {
|
2025-09-22 13:27:42 -06:00
|
|
|
const params = await props.searchParams;
|
|
|
|
|
const numAcount = params?.numAcount ? params.numAcount : null;
|
2025-09-19 17:20:05 -06:00
|
|
|
|
|
|
|
|
let student: any = null;
|
2025-12-04 18:49:30 -06:00
|
|
|
let inscripcion: any = null;
|
2025-10-01 15:29:23 -06:00
|
|
|
let errorMessage = "";
|
2025-12-04 18:49:30 -06:00
|
|
|
|
2025-09-22 12:15:32 -04:00
|
|
|
if (numAcount) {
|
2025-12-04 18:49:30 -06:00
|
|
|
const idCuenta = parseInt(numAcount);
|
2025-09-19 17:20:05 -06:00
|
|
|
|
2025-12-04 18:49:30 -06:00
|
|
|
const studentResult = await GetStudent(idCuenta);
|
|
|
|
|
if (studentResult.error) {
|
|
|
|
|
errorMessage = `${studentResult.error}`;
|
|
|
|
|
} else {
|
|
|
|
|
student = studentResult;
|
|
|
|
|
}
|
2025-12-04 19:56:47 -06:00
|
|
|
|
2026-01-16 14:47:32 -06:00
|
|
|
const inscResult = await getInscripcion(idCuenta);
|
2025-12-04 19:56:47 -06:00
|
|
|
if (!inscResult.error && Array.isArray(inscResult)) {
|
2025-12-04 18:49:30 -06:00
|
|
|
inscripcion = inscResult;
|
2025-09-19 17:20:05 -06:00
|
|
|
} else {
|
2025-12-04 19:56:47 -06:00
|
|
|
inscripcion = [];
|
2025-09-19 17:20:05 -06:00
|
|
|
}
|
|
|
|
|
}
|
2025-09-12 13:17:01 -04:00
|
|
|
|
2025-12-04 19:56:47 -06:00
|
|
|
const tableData = Array.isArray(inscripcion)
|
|
|
|
|
? inscripcion.map((ins) => ({
|
|
|
|
|
Inscrito: ins.plataforma?.nombre || "—",
|
|
|
|
|
Tiempo: ins.tiempo_disponible
|
2026-01-16 14:47:32 -06:00
|
|
|
? `${ins.tiempo_disponible} minutos`
|
2025-12-04 19:56:47 -06:00
|
|
|
: "—",
|
2026-01-21 17:10:17 -06:00
|
|
|
Confirmó: ins.platica.data?.[0] === 1 ? "sí" : "no",
|
2025-12-04 19:56:47 -06:00
|
|
|
}))
|
2025-12-04 18:49:30 -06:00
|
|
|
: [];
|
2025-10-08 12:01:52 -06:00
|
|
|
|
2026-01-22 10:26:15 -06:00
|
|
|
const plataformasInscritas = Array.isArray(inscripcion)
|
|
|
|
|
? inscripcion.map((ins) => ins.plataforma?.nombre)
|
|
|
|
|
: [];
|
|
|
|
|
|
2025-09-10 13:09:26 -06:00
|
|
|
return (
|
|
|
|
|
<section className="containerSection">
|
2025-10-01 15:29:23 -06:00
|
|
|
{errorMessage && <ShowError key={Date.now()} message={errorMessage} />}
|
2025-09-26 16:56:07 -06:00
|
|
|
|
2025-10-01 10:12:41 -06:00
|
|
|
<h2 className="title"> INSCRIPCIÓN </h2>
|
2025-09-02 19:50:17 -04:00
|
|
|
|
2025-10-08 12:01:52 -06:00
|
|
|
<div className="containeInformation">
|
|
|
|
|
<div className="firstPartInformation">
|
|
|
|
|
<SearchUser value={numAcount} />
|
|
|
|
|
|
|
|
|
|
{student && (
|
2025-10-29 14:28:50 -06:00
|
|
|
<>
|
|
|
|
|
<Information
|
|
|
|
|
NoCuenta={student.id_cuenta}
|
|
|
|
|
Nombre={student.nombre}
|
|
|
|
|
Carrera={student.carrera.carrera}
|
|
|
|
|
Credito={student.credito}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
2025-10-08 12:01:52 -06:00
|
|
|
)}
|
2025-10-14 17:18:18 -06:00
|
|
|
{!student && numAcount && (
|
2026-01-22 10:11:08 -06:00
|
|
|
<Link href={`/Alta?numAcount=${numAcount}`}>
|
|
|
|
|
<button
|
|
|
|
|
className="button buttonSearch"
|
|
|
|
|
style={{ marginTop: "1rem" }}
|
|
|
|
|
>
|
|
|
|
|
Alta Usuario
|
|
|
|
|
</button>
|
|
|
|
|
</Link>
|
2025-10-14 17:18:18 -06:00
|
|
|
)}
|
2025-10-08 12:01:52 -06:00
|
|
|
</div>
|
|
|
|
|
|
2025-10-29 14:28:50 -06:00
|
|
|
{student && (
|
|
|
|
|
<>
|
2025-12-04 18:49:30 -06:00
|
|
|
<Table headers={headers} data={tableData} />
|
2026-01-22 10:11:08 -06:00
|
|
|
<button className="button buttonSearch restarPass">
|
2025-10-29 14:28:50 -06:00
|
|
|
Restablecer contraseña
|
|
|
|
|
</button>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2025-10-08 12:01:52 -06:00
|
|
|
</div>
|
2025-09-03 21:03:22 -04:00
|
|
|
|
2025-09-29 15:37:56 -06:00
|
|
|
{student && (
|
2026-01-22 10:26:15 -06:00
|
|
|
<section className="inscripcion">
|
|
|
|
|
<Inscripcion
|
|
|
|
|
numAcount={student.id_cuenta}
|
|
|
|
|
plataformasInscritas={plataformasInscritas}
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
2025-09-19 17:20:05 -06:00
|
|
|
)}
|
2025-09-10 13:09:26 -06:00
|
|
|
</section>
|
|
|
|
|
);
|
2025-12-04 19:56:47 -06:00
|
|
|
}
|