modified table and fixed chow numTable

This commit is contained in:
2026-03-04 15:00:47 -06:00
parent 7155f8c7b1
commit 4ff4349fa7
5 changed files with 97 additions and 12 deletions
+14 -5
View File
@@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
import { getTableByCount } from "../lib/getTableByCount";
import { envConfig } from "../lib/config";
import { getMesaByCount } from "../lib/getMesaByCount";
import { useRouter } from "next/navigation";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import SearchUser from "./Global/SearchUser/searchUser";
import Information from "./Global/Information/information";
@@ -15,7 +15,7 @@ import Cookies from "js-cookie";
interface props {
numAcount: string | null;
table: number | null;
table: string | null;
}
export default function CheckBoxMesa({ numAcount, table }: props) {
@@ -31,6 +31,8 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
const bitacora = modo === "Cuenta" ? bitacoraCuenta : bitacoraMesa;
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const fetchByCuenta = async (idCuenta: number) => {
const result = await getMesaByCount(idCuenta);
@@ -66,7 +68,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
useEffect(() => {
if (modo !== "Mesa" || !table) return;
const idEquipo = table;
const idEquipo = parseInt(table);
if (isNaN(idEquipo)) return;
fetchByMesa(idEquipo);
@@ -130,15 +132,22 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
icon: "success",
});
const params = new URLSearchParams(searchParams.toString());
if (modo === "Cuenta" && numAcount) {
fetchByCuenta(parseInt(numAcount));
params.delete("numAcount");
router.push(`${pathname}?${params.toString()}`);
}
if (modo === "Mesa" && table) {
fetchByMesa(table);
fetchByMesa(parseInt(table));
params.delete("table");
router.push(`${pathname}?${params.toString()}`);
}
router.refresh();
setBitacoraMesa(null);
setBitacoraCuenta(null);
} catch (error) {
@@ -204,7 +213,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
}
{modo === "Mesa" &&
<>
<SearchMesa />
<SearchMesa value={table ?? null}/>
<h2 style={{ marginTop: "10px" }}>{errorMesa}</h2>
{bitacoraMesa && tiempoRestante !== "agotado" && (
+15 -2
View File
@@ -1,15 +1,28 @@
"use client";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useState } from "react";
import { useEffect, useState } from "react";
interface urlProp {
value: string | null;
}
export default function SearchMesa() {
export default function SearchMesa(props: urlProp) {
const [inputValue, setInputValue] = useState("");
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
useEffect(() => {
if (props.value) {
setInputValue(props.value);
}
if(props.value===null){
setInputValue("")
}
}, [props.value]);
const buscar = (e: React.FormEvent) => {
e.preventDefault();
const params = new URLSearchParams(searchParams.toString());