added headers to all axios
This commit is contained in:
@@ -27,6 +27,9 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
||||
const [bitacora, setBitacora] = useState<[] | null>([]);
|
||||
const [error, setError] = useState<string>();
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const fetchByCuenta = async (idCuenta: number) => {
|
||||
const [result, resultMesa] = await Promise.all([
|
||||
getEquipoByCount(idCuenta),
|
||||
@@ -74,8 +77,6 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
||||
|
||||
const fetchEquipos = async () => {
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
setLoadingEquipos(true);
|
||||
|
||||
@@ -121,7 +122,8 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
||||
id_alumno_inscrito: inscripcion[0].id_alumno_inscrito,
|
||||
};
|
||||
|
||||
await axios.post(`${envConfig.apiUrl}/bitacora`, body);
|
||||
await axios.post(`${envConfig.apiUrl}/bitacora`, body, { headers }
|
||||
);
|
||||
|
||||
setBitacora([]);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
import "./inscripciones.css"
|
||||
|
||||
@@ -34,9 +35,13 @@ export default function Inscripciones() {
|
||||
const [selectedPeriodo, setSelectedPeriodo] = useState<number | null>(null);
|
||||
const [tablaData, setTablaData] = useState<TablaRow[]>([]);
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
const getPeriodo = async () => {
|
||||
const response = await axios.get(`${envConfig.apiUrl}/periodo`);
|
||||
const response = await axios.get(`${envConfig.apiUrl}/periodo`, { headers }
|
||||
);
|
||||
setPeriodo(response.data);
|
||||
};
|
||||
getPeriodo();
|
||||
@@ -48,7 +53,9 @@ export default function Inscripciones() {
|
||||
if (!selectedPeriodo) return;
|
||||
|
||||
const response = await axios.get(
|
||||
`${envConfig.apiUrl}/alumno-inscrito/inscritos/${selectedPeriodo}`
|
||||
`${envConfig.apiUrl}/alumno-inscrito/inscritos/${selectedPeriodo}`,
|
||||
{ headers }
|
||||
|
||||
);
|
||||
|
||||
const data: ApiResponse[] = response.data;
|
||||
|
||||
@@ -27,12 +27,12 @@ export default function MachineTable() {
|
||||
|
||||
const fetchMachines = async () => {
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const res = await axios.get(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/equipo/disable`,
|
||||
{ headers },
|
||||
{ headers },
|
||||
);
|
||||
|
||||
setMachines(res.data);
|
||||
@@ -68,8 +68,8 @@ export default function MachineTable() {
|
||||
selectedArea === "Todo"
|
||||
? machines
|
||||
: machines.filter(
|
||||
(machine) => machine.areaUbicacion.area === selectedArea,
|
||||
);
|
||||
(machine) => machine.areaUbicacion.area === selectedArea,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.tableContainer}>
|
||||
|
||||
@@ -23,7 +23,8 @@ export default function Page() {
|
||||
|
||||
const cargarProgramas = async () => {
|
||||
try {
|
||||
const response = await axios.get(`${envConfig.apiUrl}/programa/`);
|
||||
const response = await axios.get(`${envConfig.apiUrl}/programa/`, { headers }
|
||||
);
|
||||
setProgramas(response.data);
|
||||
} catch (error: any) {
|
||||
console.error("Error al cargar programas:", error);
|
||||
@@ -45,7 +46,8 @@ export default function Page() {
|
||||
try {
|
||||
await axios.post(`${envConfig.apiUrl}/programa`, {
|
||||
programa: nombrePrograma,
|
||||
});
|
||||
}, { headers }
|
||||
);
|
||||
|
||||
await cargarProgramas();
|
||||
|
||||
@@ -114,7 +116,6 @@ export default function Page() {
|
||||
await axios.delete(
|
||||
`${envConfig.apiUrl}/programa/${programaSeleccionado}`,
|
||||
{ headers },
|
||||
|
||||
);
|
||||
|
||||
await cargarProgramas();
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
"use client";
|
||||
import { useEffect, useState } from "react";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
|
||||
import axios from "axios";
|
||||
import Swal from "sweetalert2";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
import "@/app/globals.css";
|
||||
import axios from "axios";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import Swal from "sweetalert2";
|
||||
|
||||
export default function Areas() {
|
||||
const [areas, setAreas] = useState([]);
|
||||
@@ -14,9 +16,15 @@ export default function Areas() {
|
||||
"Mantenimiento",
|
||||
);
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get(`${envConfig.apiUrl}/area-ubicacion`)
|
||||
.get(`${envConfig.apiUrl}/area-ubicacion`,
|
||||
{ headers }
|
||||
)
|
||||
.then((data) => {
|
||||
setAreas(data.data);
|
||||
})
|
||||
@@ -54,7 +62,7 @@ export default function Areas() {
|
||||
{
|
||||
id_area_ubicacion: Number(selectedArea),
|
||||
activo: modo === "Activo",
|
||||
}
|
||||
}, { headers }
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export default function MesasDisponibles() {
|
||||
|
||||
const obtenerMesas = async () => {
|
||||
try {
|
||||
const response = await axios.get(`${envConfig.apiUrl}/mesa`);
|
||||
const response = await axios.get(`${envConfig.apiUrl}/mesa`,{ headers });
|
||||
setMesas(response.data);
|
||||
} catch (error) {
|
||||
console.error("Error al obtener mesas:", error);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
interface AlumnoBitacora {
|
||||
tiempo_entrada: string;
|
||||
@@ -20,6 +21,9 @@ interface BitacoraAlumnoProps {
|
||||
export default function BitacoraAlumno({ numAcount, date }: BitacoraAlumnoProps) {
|
||||
const [alumnos, setAlumnos] = useState<AlumnoBitacora[]>([]);
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
if (!numAcount) return;
|
||||
if (!date) return;
|
||||
@@ -27,7 +31,7 @@ export default function BitacoraAlumno({ numAcount, date }: BitacoraAlumnoProps)
|
||||
axios.post(`${envConfig.apiUrl}/bitacora/equipos-por-dia`, {
|
||||
numero_cuenta: numAcount,
|
||||
fecha: date,
|
||||
})
|
||||
}, { headers })
|
||||
.then(res => {
|
||||
setAlumnos(res.data);
|
||||
})
|
||||
|
||||
@@ -21,10 +21,10 @@ export default function BitacoraEquipo({ date }: { date: string | null }) {
|
||||
const [equipoSeleccionado, setEquipoSeleccionado] = useState<any>(null);
|
||||
const [equipos, setEquipos] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
setLoadingEquipos(true);
|
||||
const response = await axios.get(`${envConfig.apiUrl}/equipo`, { headers },
|
||||
@@ -43,7 +43,7 @@ export default function BitacoraEquipo({ date }: { date: string | null }) {
|
||||
axios.post(`${envConfig.apiUrl}/bitacora/equipos-por-equipo`, {
|
||||
id_equipo: equipoSeleccionado.id_equipo,
|
||||
fecha: date,
|
||||
})
|
||||
}, { headers })
|
||||
.then(res => {
|
||||
setEquipo(res.data);
|
||||
})
|
||||
|
||||
@@ -18,12 +18,15 @@ export default function BitacoraMesas() {
|
||||
const searchParams = useSearchParams();
|
||||
const date = searchParams.get("date");
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
if (!date) return;
|
||||
|
||||
axios.post(`${envConfig.apiUrl}/bitacora-mesa/mesas-por-dia`, {
|
||||
fecha: date,
|
||||
})
|
||||
}, { headers })
|
||||
.then(res => {
|
||||
setTables(res.data);
|
||||
})
|
||||
|
||||
@@ -45,6 +45,10 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) {
|
||||
const [error, setError] = useState()
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
|
||||
const fetchByCuenta = async (idCuenta: number) => {
|
||||
const result = await getEquipoByCount(idCuenta);
|
||||
|
||||
@@ -114,6 +118,7 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) {
|
||||
await axios.patch(
|
||||
`${envConfig.apiUrl}/bitacora/cancelar/${bitacora.id_bitacora}`,
|
||||
{ tiempo_asignado: minutos },
|
||||
{ headers }
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -41,13 +41,13 @@ export default function Equipos() {
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
|
||||
const [equipoRes, plataformaRes, areaRes] = await Promise.all([
|
||||
axios.get(`${envConfig.apiUrl}/equipo/${id}`, { headers },
|
||||
@@ -91,7 +91,9 @@ export default function Equipos() {
|
||||
id_plataforma: idPlataforma,
|
||||
id_area_ubicacion: idArea,
|
||||
ip: data.ip,
|
||||
});
|
||||
},
|
||||
{ headers }
|
||||
);
|
||||
|
||||
// Actualiza el estado local
|
||||
setData({
|
||||
@@ -123,8 +125,8 @@ export default function Equipos() {
|
||||
const handleNuevo = async () => {
|
||||
try {
|
||||
const [plataformaRes, areaRes] = await Promise.all([
|
||||
axios.get(`${envConfig.apiUrl}/alumno-inscrito/plataforma`),
|
||||
axios.get(`${envConfig.apiUrl}/area-ubicacion`),
|
||||
axios.get(`${envConfig.apiUrl}/alumno-inscrito/plataforma`, { headers }),
|
||||
axios.get(`${envConfig.apiUrl}/area-ubicacion`, { headers }),
|
||||
]);
|
||||
|
||||
setPlataforma(plataformaRes.data);
|
||||
@@ -163,7 +165,7 @@ export default function Equipos() {
|
||||
id_plataforma: idPlataforma,
|
||||
id_area_ubicacion: idArea,
|
||||
ip: "0.0.0.0",
|
||||
});
|
||||
}, { headers });
|
||||
|
||||
|
||||
Swal.fire({
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
import "../../(private)/AsignacionEquipo/asignacion.css";
|
||||
|
||||
@@ -39,14 +40,17 @@ const EnviarMensaje = ({ titulo }: EnviarMensajeProps) => {
|
||||
|
||||
const [customMsg, setCustomMsg] = useState("");
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
setLoadingMensajes(true);
|
||||
|
||||
const [equiposRes, mensajesRes] = await Promise.all([
|
||||
axios.get(`${envConfig.apiUrl}/equipo/busy`),
|
||||
axios.get(`${envConfig.apiUrl}/mensaje`)
|
||||
axios.get(`${envConfig.apiUrl}/equipo/busy`, { headers }),
|
||||
axios.get(`${envConfig.apiUrl}/mensaje`, { headers })
|
||||
]);
|
||||
|
||||
setEquipos(equiposRes.data);
|
||||
|
||||
@@ -20,10 +20,13 @@ const EnviarMensajeSala = ({ titulo }: EnviarMensajeSalaProps) => {
|
||||
const [mensaje, setMensaje] = useState("");
|
||||
const [customMsg, setCustomMsg] = useState("");
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSalas = async () => {
|
||||
try {
|
||||
const response = await axios.get(`${envConfig.apiUrl}/area-ubicacion`);
|
||||
const response = await axios.get(`${envConfig.apiUrl}/area-ubicacion`, { headers });
|
||||
setSalas(response.data);
|
||||
} catch (error) {
|
||||
console.error("Error cargando salas:", error);
|
||||
@@ -45,7 +48,7 @@ const EnviarMensajeSala = ({ titulo }: EnviarMensajeSalaProps) => {
|
||||
|
||||
return (
|
||||
<form className="containerForm" onSubmit={handleSubmit}>
|
||||
|
||||
|
||||
<label className="label">{titulo}</label>
|
||||
<div className="groupInput">
|
||||
<select
|
||||
@@ -62,7 +65,7 @@ const EnviarMensajeSala = ({ titulo }: EnviarMensajeSalaProps) => {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<label className="label">Seleccione el mensaje</label>
|
||||
<div className="groupInput">
|
||||
<select value={mensaje} onChange={(e) => setMensaje(e.target.value)}>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"use client";
|
||||
import axios from "axios";
|
||||
import { useEffect, useState } from "react";
|
||||
import { envConfig } from "../lib/config";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
if (!envConfig.apiUrl) {
|
||||
console.error("API URL is not defined in envConfig");
|
||||
@@ -15,9 +16,14 @@ export default function SelectAreas(props: proms) {
|
||||
const [areas, setAreas] = useState([]);
|
||||
const [selectedArea, setSelectedArea] = useState("");
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
axios
|
||||
.get(`${envConfig.apiUrl}/area-ubicacion`)
|
||||
.get(`${envConfig.apiUrl}/area-ubicacion`, { headers }
|
||||
)
|
||||
.then((data) => {
|
||||
setAreas(data.data);
|
||||
})
|
||||
|
||||
+11
-4
@@ -120,6 +120,7 @@ select {
|
||||
font-size: 1.4rem;
|
||||
color: black;
|
||||
height: 3.5rem;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
@@ -130,6 +131,12 @@ select:focus {
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
input:disabled,
|
||||
select:disabled {
|
||||
background-color: #cfcfcf;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
select:-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
@@ -252,7 +259,7 @@ button:disabled {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.total{
|
||||
.total {
|
||||
height: 35px;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
@@ -713,9 +720,9 @@ table td:last-child {
|
||||
padding: 0.7rem;
|
||||
}
|
||||
|
||||
.total{
|
||||
height: 30px;
|
||||
}
|
||||
.total {
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user