added more headers
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
|
||||
import SelectionCo from "@/app/Components/Selection/SelectionCo";
|
||||
import axios from "axios";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import Cookies from "js-cookie";
|
||||
import Swal from "sweetalert2";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { GetSancionByStudent } from "@/app/lib/getSancionByStudent";
|
||||
import TableSanction from "./TableSanction";
|
||||
import axios from "axios";
|
||||
import Swal from "sweetalert2";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
if (!envConfig.apiUrl) {
|
||||
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 [loadingTable, setLoadingTable] = useState(false);
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const fetchAlumnoSanciones = async () => {
|
||||
try {
|
||||
|
||||
@@ -39,7 +43,7 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
|
||||
fetchAlumnoSanciones();
|
||||
|
||||
axios
|
||||
.get(`${envConfig.apiUrl}/sancion`)
|
||||
.get(`${envConfig.apiUrl}/sancion`, { headers })
|
||||
.then((res) => setSanciones(res.data))
|
||||
.catch(() =>
|
||||
|
||||
@@ -56,7 +60,7 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!selectedSancion) {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Selecciona una sanción!",
|
||||
icon: "error",
|
||||
@@ -71,18 +75,18 @@ export default function ApplySanction({ idCuenta }: { idCuenta: number }) {
|
||||
await axios.post(`${envConfig.apiUrl}/alumno-sancion/`, {
|
||||
id_sancion: Number(selectedSancion),
|
||||
id_cuenta: idCuenta,
|
||||
});
|
||||
}, { headers });
|
||||
|
||||
await fetchAlumnoSanciones();
|
||||
setSelectedSancion("");
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Sanción aplicada correctamente!",
|
||||
icon: "success",
|
||||
draggable: true
|
||||
});
|
||||
} catch {
|
||||
|
||||
|
||||
Swal.fire({
|
||||
title: "Error al aplicar la sanción!",
|
||||
icon: "error",
|
||||
|
||||
@@ -129,8 +129,7 @@ function Impressions({ costs, numAcount, id_servicio }: ImpressionsProps) {
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="groupInput"
|
||||
style={{ height: "35px", flexWrap: "nowrap" }}
|
||||
className="groupInput total"
|
||||
>
|
||||
<label className="label">Total:</label>
|
||||
<label
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
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 { 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 }) {
|
||||
const [alumno, setAlumno] = useState<Alumno>();
|
||||
@@ -32,8 +33,12 @@ function QuitarSancion({ id_cuenta }: { id_cuenta: number }) {
|
||||
|
||||
const handleButton = async (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
setLoading(true)
|
||||
await axios.delete(`${envConfig.apiUrl}/alumno-sancion/${id_cuenta}`)
|
||||
await axios.delete(`${envConfig.apiUrl}/alumno-sancion/${id_cuenta}`, { headers })
|
||||
setAlumnoSanciones([])
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -56,3 +61,4 @@ function QuitarSancion({ id_cuenta }: { id_cuenta: number }) {
|
||||
}
|
||||
|
||||
export default QuitarSancion;
|
||||
//IO
|
||||
@@ -139,7 +139,6 @@ tbody {
|
||||
|
||||
@media(max-height:550px) {
|
||||
.barNavigation {
|
||||
height: 25px;
|
||||
max-height: 35px;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -252,6 +252,11 @@ button:disabled {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total{
|
||||
height: 35px;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.buttonSearch {
|
||||
background-color: #2563eb;
|
||||
}
|
||||
@@ -681,15 +686,14 @@ table td:last-child {
|
||||
}
|
||||
|
||||
.toggleGroup {
|
||||
min-height: 35px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
|
||||
.toggleButton {
|
||||
font-weight: 400;
|
||||
padding: 1rem 0.5rem;
|
||||
min-width: 100px;
|
||||
min-height: 35px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.gap {
|
||||
@@ -709,6 +713,10 @@ table td:last-child {
|
||||
padding: 0.7rem;
|
||||
}
|
||||
|
||||
.total{
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-height: 960px) {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import axios from "axios";
|
||||
import { envConfig } from "./config";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
export async function GetSancionByStudent(numAcount: number) {
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const response = await axios.get(
|
||||
`${envConfig.apiUrl}/alumno-sancion/${numAcount}`
|
||||
`${envConfig.apiUrl}/alumno-sancion/${numAcount}`, { headers }
|
||||
);
|
||||
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user