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