added more headers

This commit is contained in:
2026-02-27 19:52:23 -06:00
parent 805f4835a3
commit 46357ee7e0
7 changed files with 37 additions and 17 deletions
+1 -1
View File
@@ -2,10 +2,10 @@
import { useState } from "react"; import { useState } from "react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { envConfig } from "@/app/lib/config";
import SelectionCo from "@/app/Components/Selection/SelectionCo"; import SelectionCo from "@/app/Components/Selection/SelectionCo";
import axios from "axios"; import axios from "axios";
import { envConfig } from "@/app/lib/config";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import Swal from "sweetalert2"; import Swal from "sweetalert2";
@@ -7,6 +7,7 @@ import { GetSancionByStudent } from "@/app/lib/getSancionByStudent";
import TableSanction from "./TableSanction"; import TableSanction from "./TableSanction";
import axios from "axios"; import axios from "axios";
import Swal from "sweetalert2"; import Swal from "sweetalert2";
import Cookies from "js-cookie";
if (!envConfig.apiUrl) { if (!envConfig.apiUrl) {
console.error("API URL is not defined in envConfig"); console.error("API URL is not defined in envConfig");
@@ -20,6 +21,9 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [loadingTable, setLoadingTable] = useState(false); const [loadingTable, setLoadingTable] = useState(false);
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
const fetchAlumnoSanciones = async () => { const fetchAlumnoSanciones = async () => {
try { try {
@@ -39,7 +43,7 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
fetchAlumnoSanciones(); fetchAlumnoSanciones();
axios axios
.get(`${envConfig.apiUrl}/sancion`) .get(`${envConfig.apiUrl}/sancion`, { headers })
.then((res) => setSanciones(res.data)) .then((res) => setSanciones(res.data))
.catch(() => .catch(() =>
@@ -56,7 +60,7 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
e.preventDefault(); e.preventDefault();
if (!selectedSancion) { if (!selectedSancion) {
Swal.fire({ Swal.fire({
title: "Selecciona una sanción!", title: "Selecciona una sanción!",
icon: "error", icon: "error",
@@ -71,18 +75,18 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
await axios.post(`${envConfig.apiUrl}/alumno-sancion/`, { await axios.post(`${envConfig.apiUrl}/alumno-sancion/`, {
id_sancion: Number(selectedSancion), id_sancion: Number(selectedSancion),
id_cuenta: idCuenta, id_cuenta: idCuenta,
}); }, { headers });
await fetchAlumnoSanciones(); await fetchAlumnoSanciones();
setSelectedSancion(""); setSelectedSancion("");
Swal.fire({ Swal.fire({
title: "Sanción aplicada correctamente!", title: "Sanción aplicada correctamente!",
icon: "success", icon: "success",
draggable: true draggable: true
}); });
} catch { } catch {
Swal.fire({ Swal.fire({
title: "Error al aplicar la sanción!", title: "Error al aplicar la sanción!",
icon: "error", icon: "error",
+1 -2
View File
@@ -129,8 +129,7 @@ function Impressions({ costs, numAcount, id_servicio }: ImpressionsProps) {
</div> </div>
<div <div
className="groupInput" className="groupInput total"
style={{ height: "35px", flexWrap: "nowrap" }}
> >
<label className="label">Total:</label> <label className="label">Total:</label>
<label <label
+10 -4
View File
@@ -2,10 +2,11 @@
import { envConfig } from "@/app/lib/config"; import { envConfig } from "@/app/lib/config";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import TableSanction from "../BitacoraSanciones/TableSanction";
import { Alumno, AlumnoSancion } from "@/app/types/sanction";
import axios from "axios";
import { GetSancionByStudent } from "@/app/lib/getSancionByStudent"; import { GetSancionByStudent } from "@/app/lib/getSancionByStudent";
import { Alumno, AlumnoSancion } from "@/app/types/sanction";
import TableSanction from "../BitacoraSanciones/TableSanction";
import axios from "axios";
import Cookies from "js-cookie";
function QuitarSancion({ id_cuenta }: { id_cuenta: number }) { function QuitarSancion({ id_cuenta }: { id_cuenta: number }) {
const [alumno, setAlumno] = useState<Alumno>(); const [alumno, setAlumno] = useState<Alumno>();
@@ -32,8 +33,12 @@ function QuitarSancion({ id_cuenta }: { id_cuenta: number }) {
const handleButton = async (e: React.MouseEvent<HTMLButtonElement>) => { const handleButton = async (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault(); e.preventDefault();
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
setLoading(true) setLoading(true)
await axios.delete(`${envConfig.apiUrl}/alumno-sancion/${id_cuenta}`) await axios.delete(`${envConfig.apiUrl}/alumno-sancion/${id_cuenta}`, { headers })
setAlumnoSanciones([]) setAlumnoSanciones([])
setLoading(false) setLoading(false)
} }
@@ -56,3 +61,4 @@ function QuitarSancion({ id_cuenta }: { id_cuenta: number }) {
} }
export default QuitarSancion; export default QuitarSancion;
//IO
@@ -139,7 +139,6 @@ tbody {
@media(max-height:550px) { @media(max-height:550px) {
.barNavigation { .barNavigation {
height: 25px;
max-height: 35px; max-height: 35px;
} }
} }
+11 -3
View File
@@ -252,6 +252,11 @@ button:disabled {
width: 100%; width: 100%;
} }
.total{
height: 35px;
flex-wrap: nowrap;
}
.buttonSearch { .buttonSearch {
background-color: #2563eb; background-color: #2563eb;
} }
@@ -681,15 +686,14 @@ table td:last-child {
} }
.toggleGroup { .toggleGroup {
min-height: 35px; min-height: 30px;
} }
.toggleButton { .toggleButton {
font-weight: 400; font-weight: 400;
padding: 1rem 0.5rem; padding: 1rem 0.5rem;
min-width: 100px; min-width: 100px;
min-height: 35px; min-height: 30px;
} }
.gap { .gap {
@@ -709,6 +713,10 @@ table td:last-child {
padding: 0.7rem; padding: 0.7rem;
} }
.total{
height: 30px;
}
} }
@media (max-height: 960px) { @media (max-height: 960px) {
+5 -1
View File
@@ -1,10 +1,14 @@
import axios from "axios"; import axios from "axios";
import { envConfig } from "./config"; import { envConfig } from "./config";
import Cookies from "js-cookie";
export async function GetSancionByStudent(numAcount: number) { export async function GetSancionByStudent(numAcount: number) {
try { try {
const token = Cookies.get("token");
const headers = { Authorization: `Bearer ${token}` };
const response = await axios.get( const response = await axios.get(
`${envConfig.apiUrl}/alumno-sancion/${numAcount}` `${envConfig.apiUrl}/alumno-sancion/${numAcount}`, { headers }
); );
return response.data; return response.data;