diff --git a/app/(private)/AsignacionEquipo/PlaticaGate.tsx b/app/(private)/AsignacionEquipo/PlaticaGate.tsx index 78147d4..3ca9d7d 100644 --- a/app/(private)/AsignacionEquipo/PlaticaGate.tsx +++ b/app/(private)/AsignacionEquipo/PlaticaGate.tsx @@ -8,6 +8,7 @@ import { getMesaByCount } from "@/app/lib/getMesaByCount"; import "./asignacion.css"; import Swal from "sweetalert2"; +import axios from "axios"; type Props = { inscripcion: any[]; @@ -41,10 +42,9 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { useEffect(() => { if (!numAcount) return; - const idCuenta = numAcount; - if (isNaN(idCuenta)) return; + if (isNaN(numAcount)) return; - fetchByCuenta(idCuenta); + fetchByCuenta(numAcount); }, [numAcount]); useEffect(() => { @@ -55,11 +55,10 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { ); if (!todasAsistieron) { - Swal.fire({ title: "El alumno no asistió a todas las pláticas!", icon: "error", - draggable: true + draggable: true, }); setPuedeContinuar(false); return; @@ -75,26 +74,16 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { try { setLoadingEquipos(true); - const res = await fetch( - `${envConfig.apiUrl}/equipo/student/${numAcount}`, - { - cache: "no-store", - }, + const res = await axios.get( + `${envConfig.apiUrl}/equipo/student/${numAcount}` ); - if (!res.ok) { - throw new Error("No se pudieron cargar los equipos"); - - } - - const data = await res.json(); - setEquipos(data); - } catch (error) { - + setEquipos(res.data); + } catch (err) { Swal.fire({ title: "Error al cargar equipos disponibles!", icon: "error", - draggable: true + draggable: true, }); } finally { setLoadingEquipos(false); @@ -110,11 +99,10 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { e.preventDefault(); if (!equipoSeleccionado) { - Swal.fire({ title: "Selecciona un equipo!", icon: "error", - draggable: true + draggable: true, }); return; } @@ -127,31 +115,20 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { id_alumno_inscrito: inscripcion[0].id_alumno_inscrito, }; - const res = await fetch(`${envConfig.apiUrl}/bitacora`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(body), - }); + await axios.post(`${envConfig.apiUrl}/bitacora`, body); - if (!res.ok) { - throw new Error("Error al asignar equipo"); - } - - setBitacora([]) + setBitacora([]); Swal.fire({ title: "Equipo asignado correctamente!", icon: "success", draggable: true, }); - } catch (error) { - + } catch (err) { Swal.fire({ title: "No se pudo asignar el equipo!", icon: "error", - draggable: true + draggable: true, }); } }; @@ -190,8 +167,7 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { onClick={() => !loadingEquipos && setOpen(!open)} > {equipoSeleccionado ? ( - + {equipoSeleccionado.ubicacion}{" "} {equipoSeleccionado.nombre_equipo} @@ -240,4 +216,4 @@ export default function PlaticaGate({ inscripcion, numAcount }: Props) { ); -} +} \ No newline at end of file diff --git a/app/Components/CheckBoxEquipo.tsx b/app/Components/CheckBoxEquipo.tsx index 7c138ca..4212e64 100644 --- a/app/Components/CheckBoxEquipo.tsx +++ b/app/Components/CheckBoxEquipo.tsx @@ -108,7 +108,7 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { { tiempo_asignado: minutos }, ); - + Swal.fire({ title: "Tiempo cancelado Correctamente!", icon: "success", @@ -153,7 +153,7 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { {modo === "Cuenta" && } {modo === "Equipo" && } -

{error}

+

{error}

{bitacora && ( <> @@ -167,6 +167,7 @@ export default function CheckBoxEquipo({ numAcount, machine }: Props) { className="button buttonSearch" style={{ marginTop: "1rem" }} onClick={handleButton} + disabled={minutos ? false : true} > Cancelar tiempo diff --git a/app/Components/CheckBoxMesa.tsx b/app/Components/CheckBoxMesa.tsx index 74b722f..9c4a611 100644 --- a/app/Components/CheckBoxMesa.tsx +++ b/app/Components/CheckBoxMesa.tsx @@ -153,7 +153,7 @@ export default function CheckBoxMesa({ numAcount, table }: props) { className="button buttonSearch" style={{ marginTop: "1rem" }} onClick={handleButton} - disabled={loading} + disabled={loading || minutos ? false : true} > Cancelar tiempo