fixed table againd
This commit is contained in:
@@ -37,7 +37,15 @@ export default function TableMesas() {
|
||||
}, []);
|
||||
|
||||
if (loading) {
|
||||
return <p>Cargando mesas...</p>;
|
||||
return <div className={styles.tableContainer}>
|
||||
<table className={styles.machineTable}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Cargando mesas...</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -100,7 +100,7 @@ export default async function Page(props: {
|
||||
]}
|
||||
/>
|
||||
<div className="tableTable">
|
||||
<TableMesas />
|
||||
<TableMesas key={Date.now()}/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -4,10 +4,11 @@ import { useEffect, useState } from "react";
|
||||
import { envConfig } from "@/app/lib/config";
|
||||
import { getEquipoByCount } from "../lib/getEquipoByCount";
|
||||
import { getMesaByCount } from "../lib/getMesaByCount";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import Swal from "sweetalert2";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
type Props = {
|
||||
inscripcion: any[];
|
||||
@@ -130,6 +131,7 @@ export default function AsignacionMesas({ idCuenta, inscripcion }: Props) {
|
||||
|
||||
setBitacora([]);
|
||||
router.refresh();
|
||||
setError("Mesa")
|
||||
Swal.fire({
|
||||
title: "Mesa asignada correctamente!",
|
||||
icon: "success",
|
||||
|
||||
@@ -37,7 +37,7 @@ interface Props {
|
||||
}
|
||||
|
||||
export default function CheckBoxEquipo({ numAcount, machine }: Props) {
|
||||
const [modo, setModo] = useState<"Equipo" | "Cuenta">("Cuenta");
|
||||
const [modo, setModo] = useState<"Equipo" | "Cuenta">("Equipo");
|
||||
|
||||
const [bitacoraCuenta, setBitacoraCuenta] = useState<any>(null);
|
||||
const [bitacoraEquipo, setBitacoraEquipo] = useState<any>(null);
|
||||
|
||||
@@ -12,6 +12,7 @@ import SearchMesa from "./SearchMesa";
|
||||
import axios from "axios";
|
||||
import Swal from "sweetalert2";
|
||||
import Cookies from "js-cookie";
|
||||
import { error } from "console";
|
||||
|
||||
interface props {
|
||||
numAcount: string | null;
|
||||
@@ -19,7 +20,7 @@ interface props {
|
||||
}
|
||||
|
||||
export default function CheckBoxMesa({ numAcount, table }: props) {
|
||||
const [modo, setModo] = useState<"Mesa" | "Cuenta" | null>("Cuenta");
|
||||
const [modo, setModo] = useState<"Mesa" | "Cuenta" | null>("Mesa");
|
||||
const [bitacoraMesa, setBitacoraMesa] = useState<any>(null);
|
||||
const [bitacoraCuenta, setBitacoraCuenta] = useState<any>(null);
|
||||
const [tiempoRestante, setTiempoRestante] = useState<string>("");
|
||||
@@ -33,6 +34,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
|
||||
const fetchByCuenta = async (idCuenta: number) => {
|
||||
const result = await getMesaByCount(idCuenta);
|
||||
@@ -64,9 +66,11 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
|
||||
if (isNaN(idCuenta)) return;
|
||||
|
||||
fetchByCuenta(idCuenta);
|
||||
}, [numAcount]);
|
||||
}, [numAcount, modo]);
|
||||
|
||||
useEffect(() => {
|
||||
params.delete("numAcount");
|
||||
router.push(`${pathname}?${params.toString()}`);
|
||||
if (modo !== "Mesa" || !table) return;
|
||||
const idEquipo = parseInt(table);
|
||||
if (isNaN(idEquipo)) return;
|
||||
@@ -132,8 +136,6 @@ 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");
|
||||
@@ -150,6 +152,8 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
|
||||
|
||||
setBitacoraMesa(null);
|
||||
setBitacoraCuenta(null);
|
||||
setErrorMesa('Alumno sin mesa');
|
||||
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
title: "Error al cancelar tiempo",
|
||||
@@ -211,9 +215,10 @@ export default function CheckBoxMesa({ numAcount, table }: props) {
|
||||
)}
|
||||
</>
|
||||
}
|
||||
|
||||
{modo === "Mesa" &&
|
||||
<>
|
||||
<SearchMesa value={table ?? null}/>
|
||||
<SearchMesa value={table ?? null} />
|
||||
<h2 style={{ marginTop: "10px" }}>{errorMesa}</h2>
|
||||
|
||||
{bitacoraMesa && tiempoRestante !== "agotado" && (
|
||||
|
||||
Reference in New Issue
Block a user