fixed name and headers
This commit is contained in:
@@ -25,10 +25,11 @@ export default function MachineTable() {
|
||||
const [selectedArea, setSelectedArea] = useState("Todo");
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const fetchMachines = async () => {
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const res = await axios.get(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/equipo/disable`,
|
||||
@@ -46,7 +47,8 @@ export default function MachineTable() {
|
||||
const fetchAreas = async () => {
|
||||
try {
|
||||
const res = await axios.get(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/area-ubicacion`
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/area-ubicacion`,
|
||||
{ headers },
|
||||
);
|
||||
|
||||
setAreas(res.data);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
interface SearchUserProps {
|
||||
value?: string | null;
|
||||
@@ -19,7 +20,9 @@ export default function SearchUserTable({ value }: SearchUserProps) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Si el prop cambia, actualizar el input
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
useEffect(() => {
|
||||
if (value) setNumAcount(value);
|
||||
}, [value]);
|
||||
@@ -37,8 +40,8 @@ export default function SearchUserTable({ value }: SearchUserProps) {
|
||||
setAlumno(null);
|
||||
|
||||
try {
|
||||
// Llamada a la API con Axios
|
||||
const { data } = await axios.get<Alumno>(`/api/alumnos/${numAcount}`);
|
||||
const { data } = await axios.get<Alumno>(`/api/alumnos/${numAcount}`, { headers },
|
||||
);
|
||||
setAlumno(data);
|
||||
} catch (err: any) {
|
||||
setAlumno(null);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import DownloadReporteXLSX from "../Dowload/Reporte";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
interface Recibo {
|
||||
id_recibo: number;
|
||||
@@ -38,9 +39,13 @@ export default function PorRecibos({ desde, hasta }: Props) {
|
||||
const fetchRecibos = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const res = await axios.post(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/recibo/rango`,
|
||||
{ desde, hasta }
|
||||
{ desde, hasta },
|
||||
{ headers },
|
||||
);
|
||||
|
||||
setRecibos(res.data);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
interface ServicioReporte {
|
||||
id_servicio: number;
|
||||
@@ -24,9 +25,13 @@ export default function PorServicio({ desde, hasta }: Props) {
|
||||
const fetchServicios = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const token = Cookies.get("token");
|
||||
const headers = { Authorization: `Bearer ${token}` };
|
||||
|
||||
const res = await axios.post(
|
||||
`${process.env.NEXT_PUBLIC_API_URL}/detalle-servicio/rango`,
|
||||
{ desde, hasta }
|
||||
{ desde, hasta },
|
||||
{ headers },
|
||||
);
|
||||
|
||||
setServicios(res.data);
|
||||
|
||||
Reference in New Issue
Block a user