get alumnno
This commit is contained in:
@@ -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 (
|
||||
<section className="containerSection">
|
||||
{errorMessage && <ShowError key={Date.now()} message={errorMessage} />}
|
||||
@@ -55,11 +98,7 @@ export default async function Page(props: {
|
||||
NoCuenta={student.id_cuenta}
|
||||
nombre={student.nombre}
|
||||
/>
|
||||
<Information
|
||||
inscrito={"WINDOWS"}
|
||||
tiempo={"9minutos"}
|
||||
confirmo={"si/no"}
|
||||
/>
|
||||
<Table headers={headers} data={tableData} />
|
||||
<div className="containerForm">
|
||||
<label style={{ marginTop: "1rem" }}>
|
||||
Seleccionar tiempo
|
||||
|
||||
@@ -23,15 +23,18 @@
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.containeInformation {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.restarPass{
|
||||
margin-top: 2rem;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.containeInformation {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
.restarPass{
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
import SearchUser from "@/app/Components/Global/SearchUser/searchUser";
|
||||
import Information from "@/app/Components/Global/Information/information";
|
||||
import Receipt from "@/app/Components/Receipt/Receipt";
|
||||
import Selection from "@/app/Components/Selection/Selection";
|
||||
import ShowError from "@/app/Components/Global/ShowError";
|
||||
import { GetStudent } from "@/app/lib/getStudent";
|
||||
import Table from "@/app/Components/Global/table";
|
||||
import Inscripcion from "@/app/Components/Receipt/Inscripcion";
|
||||
import { GetStudent } from "@/app/lib/getStudent";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
|
||||
import "./inscripcion.css";
|
||||
import Inscripcion from "@/app/Components/Receipt/Inscripcion";
|
||||
|
||||
if (!envConfig.apiUrl) {
|
||||
console.error("API URL is not defined in envConfig");
|
||||
@@ -60,8 +58,8 @@ export default async function Page(props: {
|
||||
} else {
|
||||
student = studentResult;
|
||||
}
|
||||
const inscResult = await getInscripcion(idCuenta);
|
||||
|
||||
const inscResult = await getInscripcion(idCuenta);
|
||||
if (!inscResult.error && Array.isArray(inscResult)) {
|
||||
inscripcion = inscResult;
|
||||
} else {
|
||||
@@ -73,7 +71,7 @@ export default async function Page(props: {
|
||||
? inscripcion.map((ins) => ({
|
||||
Inscrito: ins.plataforma?.nombre || "—",
|
||||
Tiempo: ins.tiempo_disponible
|
||||
? `${Math.floor(ins.tiempo_disponible / 60)} horas`
|
||||
? `${ins.tiempo_disponible} minutos`
|
||||
: "—",
|
||||
Confirmó: ins.platica.data === 1 ? "sí" : "no",
|
||||
}))
|
||||
@@ -113,8 +111,7 @@ export default async function Page(props: {
|
||||
<>
|
||||
<Table headers={headers} data={tableData} />
|
||||
<button
|
||||
className="button buttonSearch"
|
||||
style={{ marginTop: "2rem" }}
|
||||
className="button buttonSearch restarPass"
|
||||
>
|
||||
Restablecer contraseña
|
||||
</button>
|
||||
|
||||
+1
-2
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user