From 8b803cbf814920320d972b0e95f8e0ddc4312450 Mon Sep 17 00:00:00 2001 From: IO <320154041@pcpuma.acatlan.unam.mx> Date: Thu, 19 Feb 2026 15:25:50 -0600 Subject: [PATCH] new conexion to api --- app/(private)/BitacoraSanciones/page.tsx | 4 +-- app/Components/Equipos/tableequipos.tsx | 2 +- app/globals.css | 3 +-- app/lib/getStudentWhitoutSancion.ts | 34 ++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 app/lib/getStudentWhitoutSancion.ts diff --git a/app/(private)/BitacoraSanciones/page.tsx b/app/(private)/BitacoraSanciones/page.tsx index 46e0ff6..47dc437 100644 --- a/app/(private)/BitacoraSanciones/page.tsx +++ b/app/(private)/BitacoraSanciones/page.tsx @@ -7,7 +7,7 @@ import SearchUserWithDate from "@/app/Components/Global/SearchUser/SearchUserWit import ShowError from "@/app/Components/Global/ShowError"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; import QuitarSancion from "@/app/Components/QuitarSancion/QuitarSancion"; -import { GetStudent } from "@/app/lib/getStudent"; +import { GetStudentWhitoutSancion } from "@/app/lib/getStudentWhitoutSancion"; export default async function Page(props: { searchParams?: Promise<{ @@ -26,7 +26,7 @@ export default async function Page(props: { let errorMessage = ""; if (numAcount) { - const result = await GetStudent(parseInt(numAcount)); + const result = await GetStudentWhitoutSancion(parseInt(numAcount)); if (result.error) { errorMessage = `${result.error}`; diff --git a/app/Components/Equipos/tableequipos.tsx b/app/Components/Equipos/tableequipos.tsx index 8ef300b..0eb39a6 100644 --- a/app/Components/Equipos/tableequipos.tsx +++ b/app/Components/Equipos/tableequipos.tsx @@ -23,7 +23,7 @@ export default function TableEquipos() { const toggleEquipo = async (id_equipo: number) => { try { - await fetch(`${envConfig.apiUrl}/mesa/${id_equipo}/activo`, { + await fetch(`${envConfig.apiUrl}/equipo/${id_equipo}/activo`, { method: "PATCH", }); diff --git a/app/globals.css b/app/globals.css index ee28c4e..1b80425 100644 --- a/app/globals.css +++ b/app/globals.css @@ -705,7 +705,7 @@ table td:last-child { @media(max-width:785px) { .toggleSection { - min-width: 250px; + min-width: 100%; } } @@ -719,7 +719,6 @@ table td:last-child { } .toggleButton { - min-height: 35px; padding: 0; } } \ No newline at end of file diff --git a/app/lib/getStudentWhitoutSancion.ts b/app/lib/getStudentWhitoutSancion.ts new file mode 100644 index 0000000..9f40719 --- /dev/null +++ b/app/lib/getStudentWhitoutSancion.ts @@ -0,0 +1,34 @@ +import axios from "axios"; +import { envConfig } from "./config"; +import { redirect } from "next/navigation"; +import { cookies } from "next/headers"; + +if (!envConfig.apiUrl) { + console.error("API URL is not defined in envConfig"); +} + +export async function GetStudentWhitoutSancion(numAcount: number) { + const cookieStore = cookies(); + const token = (await cookieStore).get("token")?.value; + + if (!token) redirect("/"); + try { + const response = await axios.get( + `${envConfig.apiUrl}/student/sancion/${numAcount}`, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ); + + return response.data; + } catch (error: any) { + const msg = + error.response?.data?.message || + error.message || + "Error desconocido al obtener estudiante"; + return { error: msg }; + } +} +//IO