fixed table and equipo

This commit is contained in:
2026-02-06 10:39:20 -06:00
parent f2caf2ad83
commit 5747394bb1
5 changed files with 47 additions and 24 deletions
+12 -2
View File
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import { envConfig } from "@/app/lib/config";
import toast from "react-hot-toast";
import { getEquipoByCount } from "../lib/getEquipoByCount";
import { getMesaByCount } from "../lib/getMesaByCount";
type Props = {
inscripcion: any[];
@@ -27,9 +28,18 @@ export default function AsignacionMesas({ idCuenta, inscripcion }: Props) {
setBitacora(result);
toast.error("Ya cuentas con un equipo asignado");
}
const resultMesa = await getMesaByCount(idCuenta);
if (resultMesa?.error) {
setBitacora(null)
} else {
setBitacora(result)
toast.error("Ya cuentas con una mesa asignada")
}
};
useEffect(() => {
useEffect(() => {
if (!idCuenta) return;
const Cuenta = idCuenta;
if (isNaN(Cuenta)) return;
@@ -163,7 +173,7 @@ export default function AsignacionMesas({ idCuenta, inscripcion }: Props) {
>
Asignar Mesa
</button>
</div>
</div>
);
+3 -19
View File
@@ -8,29 +8,13 @@ import { getTableByCount } from "../lib/getTableByCount";
import toast from "react-hot-toast";
import axios from "axios";
import { envConfig } from "../lib/config";
import { getMesaByCount } from "../lib/getMesaByCount";
interface props {
numAcount: string | null;
table: number | null;
}
async function getEquipoId(idEquipo: number) {
try {
const res = await axios.get(
`${envConfig.apiUrl}/bitacora-mesa/table/${idEquipo}`,
);
return res.data;
} catch (error: any) {
if (axios.isAxiosError(error)) {
return {
error: error.response?.data?.message || "Error al consultar equipo",
};
}
return { error: "Error desconocido" };
}
}
export default function CheckBoxMesa({ numAcount, table }: props) {
const [modo, setModo] = useState<"Mesa" | "Cuenta" | null>("Cuenta");
const [bitacora, setBitacora] = useState<any>(null);
@@ -38,7 +22,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
const [minutos, setMinutos] = useState<number>();
const fetchByCuenta = async (idCuenta: number) => {
const result = await getTableByCount(idCuenta);
const result = await getMesaByCount(idCuenta);
if (result?.error) {
toast.error(result.error);
@@ -49,7 +33,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
};
const fetchByEquipo = async (idEquipo: number) => {
const result = await getEquipoId(idEquipo);
const result = await getTableByCount(idEquipo);
if (result?.error) {
toast.error(result.error);