fixed blink
This commit is contained in:
@@ -8,6 +8,7 @@ import { getEquipoByCount } from "@/app/lib/getEquipoByCount";
|
||||
|
||||
import "./asignacion.css";
|
||||
import { getMesaByCount } from "@/app/lib/getMesaByCount";
|
||||
import { error } from "console";
|
||||
|
||||
type Props = {
|
||||
inscripcion: any[];
|
||||
@@ -24,22 +25,17 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
||||
const [bitacora, setBitacora] = useState<[] | null>(null);
|
||||
|
||||
const fetchByCuenta = async (idCuenta: number) => {
|
||||
const result = await getEquipoByCount(idCuenta);
|
||||
const [result, resultMesa] = await Promise.all([
|
||||
getEquipoByCount(idCuenta),
|
||||
getMesaByCount(idCuenta),
|
||||
]);
|
||||
|
||||
if (result?.error) {
|
||||
if (result?.error | resultMesa?.error) {
|
||||
setBitacora(null);
|
||||
} else {
|
||||
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")
|
||||
setBitacora([]);
|
||||
if (result?.error) toast.error("Ya cuentas con un equipo asignado");
|
||||
if (resultMesa?.error) toast.error("Ya cuentas con una mesa asignada");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -20,22 +20,17 @@ export default function AsignacionMesas({ idCuenta, inscripcion }: Props) {
|
||||
const [bitacora, setBitacora] = useState<[] | null>(null);
|
||||
|
||||
const fetchByCuenta = async (idCuenta: number) => {
|
||||
const result = await getEquipoByCount(idCuenta);
|
||||
const [result, resultMesa] = await Promise.all([
|
||||
getEquipoByCount(idCuenta),
|
||||
getMesaByCount(idCuenta),
|
||||
]);
|
||||
|
||||
if (result?.error) {
|
||||
if (result?.error | resultMesa?.error) {
|
||||
setBitacora(null);
|
||||
} else {
|
||||
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")
|
||||
setBitacora([]);
|
||||
if (result?.error) toast.error("Ya cuentas con un equipo asignado");
|
||||
if (resultMesa?.error) toast.error("Ya cuentas con una mesa asignada");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user