added sanction
This commit is contained in:
@@ -9,6 +9,7 @@ import Table from "@/app/Components/Global/table";
|
||||
import { GetRegisterStudent } from "@/app/lib/getRegisterStudent";
|
||||
import PlaticaGate from "./PlaticaGate";
|
||||
import "@/app/globals.css";
|
||||
import { GetRegisterStudentSancion } from "@/app/lib/GetRegisterStudentSancion";
|
||||
|
||||
const headers = ["Inscrito", "Tiempo", "Confirmó"];
|
||||
|
||||
@@ -32,7 +33,7 @@ export default async function Page(props: {
|
||||
if (numAcount) {
|
||||
const idCuenta = parseInt(numAcount);
|
||||
|
||||
const result = await GetRegisterStudent(idCuenta);
|
||||
const result = await GetRegisterStudentSancion(idCuenta);
|
||||
if (result.error) {
|
||||
errorMessage = `${result.error}`;
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@ import ShowError from "@/app/Components/Global/ShowError";
|
||||
import Toggle from "@/app/Components/Global/Toggle/Toggle";
|
||||
|
||||
import { GetRegisterStudent } from "@/app/lib/getRegisterStudent";
|
||||
import { GetRegisterStudentSancion } from "@/app/lib/GetRegisterStudentSancion";
|
||||
|
||||
export default async function Page(props: {
|
||||
searchParams?: Promise<{
|
||||
@@ -28,7 +29,7 @@ export default async function Page(props: {
|
||||
if (numAcount) {
|
||||
const idCuenta = parseInt(numAcount);
|
||||
|
||||
const result = await GetRegisterStudent(idCuenta);
|
||||
const result = await GetRegisterStudentSancion(idCuenta);
|
||||
if (result.error) {
|
||||
errorMessage = `${result.error}`;
|
||||
} else {
|
||||
|
||||
@@ -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 GetRegisterStudentSancion(numAcount: number) {
|
||||
const cookieStore = cookies();
|
||||
const token = (await cookieStore).get("token")?.value;
|
||||
|
||||
if (!token) redirect("/");
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${envConfig.apiUrl}/alumno-inscrito/${numAcount}/sancion`,
|
||||
{
|
||||
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
|
||||
Reference in New Issue
Block a user