From 6071f38af251a41058039293b33daf6824554d2d Mon Sep 17 00:00:00 2001 From: IO <320154041@pcpuma.acatlan.unam.mx> Date: Thu, 19 Feb 2026 10:48:45 -0600 Subject: [PATCH] added bitacora mesa --- .../BitacoraSanciones/BitacoraMesas.tsx | 51 +++++++++++++++---- app/Components/CheckBoxEquipo.tsx | 19 ++++--- app/Components/CheckBoxMesa.tsx | 7 ++- 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/app/Components/BitacoraSanciones/BitacoraMesas.tsx b/app/Components/BitacoraSanciones/BitacoraMesas.tsx index 14c2d6f..0ce03ff 100644 --- a/app/Components/BitacoraSanciones/BitacoraMesas.tsx +++ b/app/Components/BitacoraSanciones/BitacoraMesas.tsx @@ -1,8 +1,11 @@ "use client"; import SearchDate from "../SearchDate/SearchDate"; -import { useState } from "react"; +import { useEffect, useState } from "react"; +import { useSearchParams } from "next/navigation"; +import axios from "axios"; +import { envConfig } from "@/app/lib/config"; -interface tables { +interface Tables { no_mesa: number; no_cuenta: number; hora_entrada: string; @@ -11,11 +14,29 @@ interface tables { } function BitacoraMesas() { - const [tables, setTables] = useState([]); + const [tables, setTables] = useState([]); + const searchParams = useSearchParams(); + const date = searchParams.get("date"); + + useEffect(() => { + if (!date) return; + + axios.post(`${envConfig.apiUrl}/bitacora-mesa/mesas-por-dia`, { + fecha: date, + }) + .then(res => { + setTables(res.data); + }) + .catch(err => { + console.error(err); + }); + + }, [date]); return ( <> +
@@ -28,15 +49,23 @@ function BitacoraMesas() { - {tables.map((table, index) => ( - - - - - - + {tables.length === 0 ? ( + + - ))} + ) : ( + tables.map((table, index) => ( + + + + + + + + )) + )}
{table.no_mesa}{table.no_cuenta}{table.hora_entrada}{table.tiempo_asignado}{table.hora_salida}
+ No hubo mesas utilizadas en esta fecha +
{table.no_mesa}{table.no_cuenta}{new Date(table.hora_entrada).toLocaleString()}{table.tiempo_asignado}{new Date(table.hora_salida).toLocaleString()}
diff --git a/app/Components/CheckBoxEquipo.tsx b/app/Components/CheckBoxEquipo.tsx index c41699d..b432c5a 100644 --- a/app/Components/CheckBoxEquipo.tsx +++ b/app/Components/CheckBoxEquipo.tsx @@ -37,12 +37,13 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { const [bitacora, setBitacora] = useState(null); const [tiempoRestante, setTiempoRestante] = useState(""); const [minutos, setMinutos] = useState(); + const [error, setError] = useState() const fetchByCuenta = async (idCuenta: number) => { const result = await getEquipoByCount(idCuenta); if (result?.error) { - toast.error(result.error); + setError(result.error); setBitacora(null); } else { setBitacora(result); @@ -53,7 +54,7 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { const result = await getEquipoId(idEquipo); if (result?.error) { - toast.error(result.error); + setError(result.error); setBitacora(null); } else { setBitacora(result); @@ -107,13 +108,13 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { `${envConfig.apiUrl}/bitacora/cancelar/${bitacora.id_bitacora}`, { tiempo_asignado: minutos }, ); - + toast.success("Tiempo cancelado"); - Swal.fire({ - title: "Tiempo cancelado!", - icon: "success", - draggable: true, - }); + Swal.fire({ + title: "Tiempo cancelado!", + icon: "success", + draggable: true, + }); if (modo === "Cuenta" && numAcount) { fetchByCuenta(parseInt(numAcount)); @@ -153,6 +154,8 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { {modo === "Cuenta" && } {modo === "Equipo" && } +

{error}

+ {bitacora && ( <> (null); const [tiempoRestante, setTiempoRestante] = useState(""); const [minutos, setMinutos] = useState(); + const [error,setError]=useState() const fetchByCuenta = async (idCuenta: number) => { const result = await getMesaByCount(idCuenta); if (result?.error) { - toast.error(result.error); + setError(result.error); setBitacora(null); } else { setBitacora(result); @@ -37,7 +38,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) { const result = await getTableByCount(idEquipo); if (result?.error) { - toast.error(result.error); + setError(result.error); setBitacora(null); } else { setBitacora(result); @@ -137,6 +138,8 @@ export default function CheckBoxMesa({ numAcount, table }: props) { {modo === "Cuenta" && } {modo === "Mesa" && } +

{error}

+ {bitacora && ( <>