([]);
const [loading, setLoading] = useState(true);
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
useEffect(() => {
+
const fetchEquipos = async () => {
try {
- const response = await axios.get(`${envConfig.apiUrl}/equipo`);
+ const response = await axios.get(`${envConfig.apiUrl}/equipo`,
+ { headers },
+ );
setEquipos(response.data);
} catch (error: any) {
console.error("ERROR API:", error.response?.data || error.message);
@@ -28,7 +36,8 @@ export default function TableEquipos() {
const toggleEquipo = async (id_equipo: number) => {
try {
await axios.patch(
- `${envConfig.apiUrl}/equipo/${id_equipo}/activo`
+ `${envConfig.apiUrl}/equipo/${id_equipo}/activo`,
+ { headers },
);
setEquipos((prev) =>
@@ -84,7 +93,7 @@ export default function TableEquipos() {
|
{eq.plataforma?.nombre}
|
- {eq.areaUbicacion?.nombre || eq.id_area_ubicacion} |
+ {eq.areaUbicacion?.area || eq.id_area_ubicacion} |
);
}
+//IO
\ No newline at end of file
diff --git a/app/Components/InformacionEquipos/ProgramSelector.tsx b/app/Components/InformacionEquipos/ProgramSelector.tsx
index ae8fd0c..9582c5e 100644
--- a/app/Components/InformacionEquipos/ProgramSelector.tsx
+++ b/app/Components/InformacionEquipos/ProgramSelector.tsx
@@ -3,6 +3,7 @@ import { envConfig } from "@/app/lib/config";
import axios from "axios";
import { useEffect, useState } from "react";
import Swal from "sweetalert2";
+import Cookies from "js-cookie";
interface Programa {
id_programa: number;
@@ -19,11 +20,14 @@ export default function ProgramSelector({
const [programas, setProgramas] = useState([]);
const [checkboxes, setCheckboxes] = useState>({});
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
useEffect(() => {
const fetchData = async () => {
const [programasRes] = await Promise.all([
- axios.get(`${envConfig.apiUrl}/programa`),
- ]);
+ axios.get(`${envConfig.apiUrl}/programa`, { headers },
+ )]);
setProgramas(programasRes.data);
@@ -58,9 +62,10 @@ export default function ProgramSelector({
{
programas: programasSeleccionados,
},
+ { headers },
);
-
+
Swal.fire({
title: "Programas actualizados en la máquina!",
icon: "success",
@@ -70,12 +75,15 @@ export default function ProgramSelector({
}
if (id) {
- await axios.patch(`${envConfig.apiUrl}/programa-equipo/sala`, {
- sala: id,
- programas: programasSeleccionados,
- });
+ await axios.patch(`${envConfig.apiUrl}/programa-equipo/sala`,
+ {
+ sala: id,
+ programas: programasSeleccionados,
+ },
+ { headers },
+ );
+
-
Swal.fire({
title: "Programas actualizados en la sala",
icon: "success",
@@ -90,7 +98,7 @@ export default function ProgramSelector({
draggable: true
});
} catch (error) {
-
+
Swal.fire({
title: "Error al guardar cambios!",
@@ -116,12 +124,15 @@ export default function ProgramSelector({
if (ubicacion && ubicacion !== "0") {
res = await axios.get(
`${envConfig.apiUrl}/programa-equipo/${ubicacion}`,
+ { headers },
);
}
if (id) {
res = await axios.get(
`${envConfig.apiUrl}/area-ubicacion/programs/${id}`,
+ { headers },
+
);
}
@@ -131,14 +142,14 @@ export default function ProgramSelector({
} catch (error: any) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
-
+
Swal.fire({
title: "Sin programas asignados!",
icon: "error",
draggable: true
});
} else {
-
+
Swal.fire({
title: "Error al cargar programas!",
icon: "error",
@@ -147,7 +158,7 @@ export default function ProgramSelector({
}
} else {
-
+
Swal.fire({
title: "Error inesperado!",
icon: "error",
diff --git a/app/Components/InformacionEquipos/SelectorEquipo.tsx b/app/Components/InformacionEquipos/SelectorEquipo.tsx
index 0f0840a..9560903 100644
--- a/app/Components/InformacionEquipos/SelectorEquipo.tsx
+++ b/app/Components/InformacionEquipos/SelectorEquipo.tsx
@@ -1,8 +1,10 @@
"use client";
+
import { envConfig } from "@/app/lib/config";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import axios from "axios";
+import Cookies from "js-cookie";
import "../../(private)/AsignacionEquipo/asignacion.css";
@@ -33,10 +35,15 @@ export default function SelectorEquipo({ onSearch }: Props) {
const [loadingEquipos, setLoadingEquipos] = useState(false);
const [open, setOpen] = useState(false);
+
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
useEffect(() => {
const fetchData = async () => {
setLoadingEquipos(true);
- const response = await axios.get(`${envConfig.apiUrl}/equipo`);
+ const response = await axios.get(`${envConfig.apiUrl}/equipo`, { headers },
+ );
setEquipos(response.data);
setLoadingEquipos(false);
};
@@ -85,7 +92,7 @@ export default function SelectorEquipo({ onSearch }: Props) {
{open && (
-
+
{equipos.length === 0 && (
No hay equipos disponibles
diff --git a/app/Components/InformacionEquipos/SelectorSala.tsx b/app/Components/InformacionEquipos/SelectorSala.tsx
index 1c482f2..590d183 100644
--- a/app/Components/InformacionEquipos/SelectorSala.tsx
+++ b/app/Components/InformacionEquipos/SelectorSala.tsx
@@ -3,6 +3,7 @@ import { envConfig } from "@/app/lib/config";
import { useEffect, useState } from "react";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import axios from "axios";
+import Cookies from "js-cookie";
interface Area {
id_area_ubicacion: number;
@@ -45,8 +46,13 @@ export default function SelectorSala({ onSearch }: Props) {
};
useEffect(() => {
+
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
const fetchData = async () => {
- const response = await axios.get(`${envConfig.apiUrl}/area-ubicacion`);
+ const response = await axios.get(`${envConfig.apiUrl}/area-ubicacion`, { headers },
+ );
setSala(response.data);
};
diff --git a/app/Components/Receipt/Inscripcion.tsx b/app/Components/Receipt/Inscripcion.tsx
index 2e21227..da2be87 100644
--- a/app/Components/Receipt/Inscripcion.tsx
+++ b/app/Components/Receipt/Inscripcion.tsx
@@ -1,14 +1,14 @@
"use client";
import { useState } from "react";
-import { useRouter } from "next/navigation";
+import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { envConfig } from "@/app/lib/config";
import Selection from "../Selection/Selection";
import Cookies from "js-cookie";
import axios from "axios";
-
import Swal from "sweetalert2";
+
import "./Receipt.css";
interface ReceiptsProps {
@@ -32,6 +32,8 @@ export default function Inscripcion({
>(null);
const router = useRouter();
+ const pathname = usePathname();
+ const searchParams = useSearchParams();
const [folio, setFolio] = useState("");
const [amount, setAmount] = useState("");
@@ -128,7 +130,10 @@ export default function Inscripcion({
setAmount("");
setDate(todayISO);
- router.refresh();
+ const params = new URLSearchParams(searchParams.toString());
+ params.delete("numAcount");
+ router.push(`${pathname}?${params.toString()}`);
+
} catch (error: any) {
const msg =
error.response?.data?.message ||
diff --git a/app/Components/SearchMesa.tsx b/app/Components/SearchMesa.tsx
index bfb9df1..e711893 100644
--- a/app/Components/SearchMesa.tsx
+++ b/app/Components/SearchMesa.tsx
@@ -26,7 +26,7 @@ export default function SearchMesa() {
setInputValue(e.target.value)}
diff --git a/app/lib/getEquipoByCount.ts b/app/lib/getEquipoByCount.ts
index a041689..5d442c9 100644
--- a/app/lib/getEquipoByCount.ts
+++ b/app/lib/getEquipoByCount.ts
@@ -1,10 +1,15 @@
import axios from "axios";
import { envConfig } from "./config";
+import Cookies from "js-cookie";
export async function getEquipoByCount(idCuenta: number) {
try {
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
const res = await axios.get(
`${envConfig.apiUrl}/bitacora/cuenta/${idCuenta}`,
+ { headers },
);
return res.data;
} catch (error: any) {
diff --git a/app/lib/getMesaByCount.ts b/app/lib/getMesaByCount.ts
index a4785e5..1e12b72 100644
--- a/app/lib/getMesaByCount.ts
+++ b/app/lib/getMesaByCount.ts
@@ -1,10 +1,15 @@
import axios from "axios";
import { envConfig } from "./config";
+import Cookies from "js-cookie";
export async function getMesaByCount(idCuenta: number) {
try {
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
const res = await axios.get(
`${envConfig.apiUrl}/bitacora-mesa/cuenta/${idCuenta}`,
+ { headers },
);
return res.data;
} catch (error: any) {
diff --git a/app/lib/getTableByCount.ts b/app/lib/getTableByCount.ts
index cd185a9..ccc44dd 100644
--- a/app/lib/getTableByCount.ts
+++ b/app/lib/getTableByCount.ts
@@ -1,10 +1,15 @@
import axios from "axios";
import { envConfig } from "./config";
+import Cookies from "js-cookie";
export async function getTableByCount(idCuenta: number) {
try {
+ const token = Cookies.get("token");
+ const headers = { Authorization: `Bearer ${token}` };
+
const res = await axios.get(
`${envConfig.apiUrl}/bitacora-mesa/table/${idCuenta}`,
+ { headers },
);
return res.data;
} catch (error: any) {
|