new conexion to api

This commit is contained in:
2026-02-19 15:25:50 -06:00
parent 6071f38af2
commit 8b803cbf81
4 changed files with 38 additions and 5 deletions
+2 -2
View File
@@ -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}`;
+1 -1
View File
@@ -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",
});
+1 -2
View File
@@ -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;
}
}
+34
View File
@@ -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