diff --git a/src/components/reporteGraficas/Graficas/Antiguedad.tsx b/src/components/reporteGraficas/Graficas/Antiguedad.tsx index 4e6ba26..4658e83 100644 --- a/src/components/reporteGraficas/Graficas/Antiguedad.tsx +++ b/src/components/reporteGraficas/Graficas/Antiguedad.tsx @@ -12,6 +12,7 @@ import { XAxis, YAxis } from "recharts"; +import Cookies from "js-cookie"; type AdscripcionOption = { id_adscripcion: string @@ -27,18 +28,22 @@ interface AntiguedadData { antiguedad: string total: number } +const api_url = process.env.NEXT_PUBLIC_API_URL; export default function Antiguedad({ filtros }: Props) { const [data, setData] = useState([]) useEffect(() => { + const token = Cookies.get("token"); + const headers = { Authorization: `Bearer ${token}` }; const getAntiguedad = async () => { const response = await axios.post( - "http://localhost:3001/equipos/grafica/antiguedad", - filtros + `${api_url}/equipos/grafica/antiguedad`, + filtros, + { headers } ) setData(response.data) diff --git a/src/components/reporteGraficas/reporte.tsx b/src/components/reporteGraficas/reporte.tsx index 83971ba..7cf6eb2 100644 --- a/src/components/reporteGraficas/reporte.tsx +++ b/src/components/reporteGraficas/reporte.tsx @@ -10,6 +10,9 @@ import Procesador from "./Graficas/Procesador" import SistemaOperativo from "./Graficas/SistemaOperativo" import Uso from "./Graficas/Uso" +import Cookies from "js-cookie"; +const api_url = process.env.NEXT_PUBLIC_API_URL; + type AdscripcionOption = { id_adscripcion: string adscripcion: string @@ -51,23 +54,22 @@ export default function Reporte() { const [antiguedad, setAntiguedad] = useState([{ antiguedad: "Menor a 2 años" }, { antiguedad: "Entre 2 y 3 años" }, { antiguedad: "Entre 4 y 5 años" }, { antiguedad: "Mayor a 6 años" }]) const [antiguedadSeleccionada, setAntiguedadSeleccionada] = useState([]) - const [antiguedadActiva, setAntiguedadActiva] = useState(false) - const [filtros, setFiltros] = useState(null) useEffect(() => { const cargarDatos = async () => { - + const token = Cookies.get("token"); + const headers = { Authorization: `Bearer ${token}` }; const [ adscripcionRes, procesadorRes, usoRes, soRes, ] = await Promise.all([ - axios.get("http://localhost:3001/equipos/adscripciones"), - axios.get("http://localhost:3001/equipos/procesador-tipo-equipos"), - axios.get("http://localhost:3001/equipos/usos"), - axios.get("http://localhost:3001/equipos/sistemas-operativos"), + axios.get(`${api_url}/equipos/adscripciones`,{ headers }), + axios.get(`${api_url}/equipos/procesador-tipo-equipos`,{ headers }), + axios.get(`${api_url}/equipos/usos`,{ headers }), + axios.get(`${api_url}/equipos/sistemas-operativos`,{ headers }), ]) setAdscripciones(adscripcionRes.data) diff --git a/src/proxy.ts b/src/proxy.ts index a8229d5..c022580 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -35,6 +35,15 @@ export function proxy(request: NextRequest) { export const config = { matcher: [ + "/escaner", + "/agregarEquipo", + "/editar", + "/crearCuenta", + "/equipoComputo", + "/perifericos", + "/ranking", + "/historial", + "/cambiarPass" ], }; //IO