fixed table and equipo
This commit is contained in:
@@ -7,6 +7,7 @@ import toast from "react-hot-toast";
|
||||
import { getEquipoByCount } from "@/app/lib/getEquipoByCount";
|
||||
|
||||
import "./asignacion.css";
|
||||
import { getMesaByCount } from "@/app/lib/getMesaByCount";
|
||||
|
||||
type Props = {
|
||||
inscripcion: any[];
|
||||
@@ -20,7 +21,7 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
||||
const [equipoSeleccionado, setEquipoSeleccionado] = useState<any>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [tiempo, setTiempo] = useState<number>(15);
|
||||
const [bitacora, setBitacora] = useState<[]|null>(null);
|
||||
const [bitacora, setBitacora] = useState<[] | null>(null);
|
||||
|
||||
const fetchByCuenta = async (idCuenta: number) => {
|
||||
const result = await getEquipoByCount(idCuenta);
|
||||
@@ -31,6 +32,15 @@ export default function PlaticaGate({ inscripcion, numAcount }: 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(() => {
|
||||
@@ -143,7 +153,7 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) {
|
||||
<option value={90}>90 minutos</option>
|
||||
</select>
|
||||
|
||||
<label style={{ marginTop: "1rem" }}>Seleccione un equipo</label>
|
||||
<label>Seleccione un equipo</label>
|
||||
|
||||
<div className="groupInput">
|
||||
<div
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import axios from "axios";
|
||||
import { envConfig } from "./config";
|
||||
|
||||
export async function getMesaByCount(idCuenta: number) {
|
||||
try {
|
||||
const res = await axios.get(
|
||||
`${envConfig.apiUrl}/bitacora-mesa/cuenta/${idCuenta}`,
|
||||
);
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
return {
|
||||
error: error.response?.data?.message || "Error al consultar equipo",
|
||||
};
|
||||
}
|
||||
|
||||
return { error: "Error desconocido" };
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { envConfig } from "./config";
|
||||
export async function getTableByCount(idCuenta: number) {
|
||||
try {
|
||||
const res = await axios.get(
|
||||
`${envConfig.apiUrl}/bitacora-mesa/cuenta/${idCuenta}`,
|
||||
`${envConfig.apiUrl}/bitacora-mesa/table/${idCuenta}`,
|
||||
);
|
||||
return res.data;
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user