From df3b189276cda440beb507216663036c59598206 Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Thu, 22 Jan 2026 10:11:08 -0600 Subject: [PATCH] fixing some tings barnavigation, asignacion mesa and alta --- app/(private)/AsignacionEquipo/page.tsx | 22 +-- app/(private)/AsignacionMesas/page.tsx | 98 +++++++----- app/(private)/Inscripcion/page.tsx | 37 +++-- app/Components/Alta/registerAlta.css | 32 ++++ app/Components/Alta/registerAlta.tsx | 141 +++++++++++++----- app/Components/AsignacionMesas.tsx | 96 ++++++++---- .../BitacoraSanciones/TableSancion.tsx | 22 +-- app/Components/CheckBoxMesa.tsx | 44 ++++++ .../InformacionEquipos/ProgramSelector.tsx | 8 - .../auth/ChangePassword/changePassword.tsx | 3 + app/Components/auth/Login/Login.tsx | 1 + app/Components/auth/Logout/Logout.tsx | 2 + .../layout/BarNavigation/BarNavigation.tsx | 26 ++-- app/Components/layout/Header/Header.tsx | 26 +--- 14 files changed, 378 insertions(+), 180 deletions(-) create mode 100644 app/Components/Alta/registerAlta.css create mode 100644 app/Components/CheckBoxMesa.tsx diff --git a/app/(private)/AsignacionEquipo/page.tsx b/app/(private)/AsignacionEquipo/page.tsx index 7d8d869..cc1fe9f 100644 --- a/app/(private)/AsignacionEquipo/page.tsx +++ b/app/(private)/AsignacionEquipo/page.tsx @@ -88,7 +88,7 @@ export default async function Page(props: {
{errorMessage && } -

ASIGNACION DE EQUIPOS

+

ASIGNACIÓN DE EQUIPOS

-
- - + - - +
+ - + )} @@ -122,7 +124,7 @@ export default async function Page(props: { label: "Cancelar tiempo", content: ( <> - + ), }, diff --git a/app/(private)/AsignacionMesas/page.tsx b/app/(private)/AsignacionMesas/page.tsx index 984dc47..e624d29 100644 --- a/app/(private)/AsignacionMesas/page.tsx +++ b/app/(private)/AsignacionMesas/page.tsx @@ -1,38 +1,76 @@ import AsignacionMesas from "@/app/Components/AsignacionMesas"; -import CheckBox from "@/app/Components/CheckBox"; +import CheckBoxMesa from "@/app/Components/CheckBoxMesa"; import Information from "@/app/Components/Global/Information/information"; import SearchUser from "@/app/Components/Global/SearchUser/searchUser"; import ShowError from "@/app/Components/Global/ShowError"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; -import { GetStudent } from "@/app/lib/getStudent"; +import Table from "@/app/Components/Global/table"; + +import { envConfig } from "@/app/lib/config"; +import { GetRegisterStudent } from "@/app/lib/getRegisterStudent"; + +async function getInscripcion(idCuenta: number) { + try { + const res = await fetch( + `${envConfig.apiUrl}/alumno-inscrito/${idCuenta}`, + { cache: "no-store" } + ); + + if (!res.ok) throw new Error("Error al cargar inscripción"); + return await res.json(); + } catch (error: any) { + return { error: error.message }; + } +} + +const headers = ["Inscrito", "Tiempo", "Confirmó"]; export default async function Page(props: { searchParams?: Promise<{ - key: string; - numAcount: string; + key?: string; + numAcount?: string; }>; }) { const params = await props.searchParams; - const key = params?.key && params.key; - const numAcount = params?.numAcount ? params.numAcount : null; + const key = params?.key; + const numAcount = params?.numAcount ?? null; let student: any = null; + let inscripcion: any[] = []; let errorMessage = ""; if (numAcount) { - const result = await GetStudent(parseInt(numAcount)); + const idCuenta = parseInt(numAcount); + + const result = await GetRegisterStudent(idCuenta); if (result.error) { - errorMessage = `${result.error}`; + errorMessage = result.error; } else { - student = result as Student; + student = result[0]?.alumno; + } + + const inscResult = await getInscripcion(idCuenta); + if (!inscResult.error && Array.isArray(inscResult)) { + inscripcion = inscResult; } } + const tableData = Array.isArray(inscripcion) + ? inscripcion.map((ins) => ({ + Inscrito: ins.plataforma?.nombre || "—", + Tiempo: ins.tiempo_disponible + ? `${ins.tiempo_disponible} minutos` + : "—", + Confirmó: ins.platica?.data?.[0] === 1 ? "sí" : "no", + })) + : []; + return (
- {errorMessage && } -

ASIGNACION DE MESAS

+ {errorMessage && } + +

ASIGNACIÓN DE MESAS

+ {student && ( <> - - {/*
- -
- - +
+ +
- */} - + + )} ), }, { - key: "Tiempo", - label: "Cancelar Tiempo", - content: ( - <> - - - ), + key: "Liberar", + label: "Cancelar mesa", + content: , }, ]} /> diff --git a/app/(private)/Inscripcion/page.tsx b/app/(private)/Inscripcion/page.tsx index da76be5..0e2c3b9 100644 --- a/app/(private)/Inscripcion/page.tsx +++ b/app/(private)/Inscripcion/page.tsx @@ -7,6 +7,7 @@ import { GetStudent } from "@/app/lib/getStudent"; import { envConfig } from "@/app/lib/config"; import "./inscripcion.css"; +import Link from "next/link"; if (!envConfig.apiUrl) { console.error("API URL is not defined in envConfig"); @@ -14,16 +15,13 @@ if (!envConfig.apiUrl) { async function getInscripcion(idCuenta: number) { try { - const res = await fetch( - `${envConfig.apiUrl}/alumno-inscrito/${idCuenta}`, - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - cache: "no-store", - } - ); + const res = await fetch(`${envConfig.apiUrl}/alumno-inscrito/${idCuenta}`, { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + cache: "no-store", + }); if (!res.ok) { throw new Error(`Error ${res.status}: ${res.statusText}`); @@ -98,21 +96,21 @@ export default async function Page(props: { )} {!student && numAcount && ( - + + + )} {student && ( <>
- @@ -122,7 +120,6 @@ export default async function Page(props: { {student && ( <>
-
diff --git a/app/Components/Alta/registerAlta.css b/app/Components/Alta/registerAlta.css new file mode 100644 index 0000000..20e1fdd --- /dev/null +++ b/app/Components/Alta/registerAlta.css @@ -0,0 +1,32 @@ +.containerForm { + display: flex; + flex-direction: column; +} + +.buttonSave { + background-color: #002b7a; + color: #ffffff; +} + +.buttonSave:not(:disabled):hover { + background-color: #001f5c; +} + +button:disabled { + background-color: #bfc6d1; + cursor: not-allowed; + opacity: 0.7; +} + +.altaContainerButton{ + display: flex; + width: 100%; + justify-content: space-evenly; +} + +/* ===== RESPONSIVE ===== */ +@media (max-width: 768px) { + .gridAlta { + grid-template-columns: 1fr; + } +} diff --git a/app/Components/Alta/registerAlta.tsx b/app/Components/Alta/registerAlta.tsx index 6e43cbf..b1796ca 100644 --- a/app/Components/Alta/registerAlta.tsx +++ b/app/Components/Alta/registerAlta.tsx @@ -1,37 +1,85 @@ "use client"; +import { useEffect, useState } from "react"; import apiClient from "@/app/lib/apiClient"; -import { useEffect, useState } from "react"; +import "./registerAlta.css"; +import toast from "react-hot-toast"; + +type Carrera = { + id_carrera: number; + carrera: string; +}; export default function RegisterAlta() { - const [listMajor, setListMajor] = useState([]); - const [major, setMajor] = useState(""); + const [listMajor, setListMajor] = useState([]); + const [saved, setSaved] = useState(false); + + const [form, setForm] = useState({ + cuenta: "", + nombre: "", + apellidoP: "", + apellidoM: "", + fecha: "", + email: "", + genero: "", + carrera: "", + }); useEffect(() => { const fetchCarreras = async () => { try { const response = await apiClient.get("/carrera"); - - const sortedCarreras = response.data.sort((a: any, b: any) => - a.carrera.localeCompare(b.carrera) + const sorted = response.data.sort((a: Carrera, b: Carrera) => + a.carrera.localeCompare(b.carrera), ); - - setListMajor(sortedCarreras); + setListMajor(sorted); } catch (error) { console.error("Error al obtener carreras:", error); } }; + fetchCarreras(); }, []); + const handleChange = ( + e: React.ChangeEvent, + ) => { + const { name, value } = e.target; + setForm((prev) => ({ ...prev, [name]: value })); + }; + + const isFormComplete = Object.values(form).every( + (value) => value.trim() !== "", + ); + + + const handleSave = async (e: React.MouseEvent) => { + e.preventDefault(); + + try { + await apiClient.post("/alumno", form); + setSaved(true); + toast.error("Alumno registrado correctamente"); + } catch (error) { + console.error("Error al guardar alumno:", error); + toast.error("Error al guardar alumno"); + } + }; + + const handleInscripcion = (e: React.MouseEvent) => { + e.preventDefault(); + toast.success("Continuar con inscripción"); + }; + return (
- + setUser(e.target.value)} + name="cuenta" + value={form.cuenta} + onChange={handleChange} placeholder="Coloca un número de cuenta..." />
@@ -40,8 +88,9 @@ export default function RegisterAlta() { setUser(e.target.value)} + name="nombre" + value={form.nombre} + onChange={handleChange} placeholder="Coloca el nombre" /> @@ -50,8 +99,9 @@ export default function RegisterAlta() { setUser(e.target.value)} + name="apellidoP" + value={form.apellidoP} + onChange={handleChange} placeholder="Coloca el apellido paterno" /> @@ -60,8 +110,9 @@ export default function RegisterAlta() { setUser(e.target.value)} + name="apellidoM" + value={form.apellidoM} + onChange={handleChange} placeholder="Coloca el apellido materno" /> @@ -69,49 +120,63 @@ export default function RegisterAlta() {
setUser(e.target.value)} - placeholder="Coloca fecha empezando por año" + type="date" + name="fecha" + value={form.fecha} + onChange={handleChange} />
setUser(e.target.value)} + type="email" + name="email" + value={form.email} + onChange={handleChange} placeholder="Coloca el email" />
- - + + + +
- - {listMajor.map((carrera: any, index) => ( - ))}
- - +
+ + + +
); } diff --git a/app/Components/AsignacionMesas.tsx b/app/Components/AsignacionMesas.tsx index c45239b..4c74760 100644 --- a/app/Components/AsignacionMesas.tsx +++ b/app/Components/AsignacionMesas.tsx @@ -1,39 +1,83 @@ "use client"; -import axios from "axios"; -import { useEffect, useState } from "react"; -import { envConfig } from "../lib/config"; -interface mesas { - idMesa: number; - active: number; -} -export default function AsignacionMesas() { - const [tiempo, setTiempo] = useState(""); - const [mesa, setMesa] = useState([]); +import { useEffect, useState } from "react"; +import { envConfig } from "@/app/lib/config"; +import toast from "react-hot-toast"; + +type Props = { + idCuenta: number; + inscripcion: any[]; +}; + +export default function AsignacionMesas({ idCuenta }: Props) { + const [mesas, setMesas] = useState([]); + const [loadingMesas, setLoadingMesas] = useState(false); useEffect(() => { - const getMesa = async() => { - const response = await axios.get(`${envConfig.apiUrl}/mesa/activo`); - setMesa(response.data); + if (!idCuenta) return; + + const fetchMesas = async () => { + try { + setLoadingMesas(true); + + const res = await fetch( + `${envConfig.apiUrl}/mesa/activo`, + { cache: "no-store" } + ); + + if (!res.ok) { + throw new Error("No se pudieron cargar las mesas"); + } + + const data = await res.json(); + setMesas(data); + } catch (error) { + toast.error("Error al cargar mesas disponibles"); + } finally { + setLoadingMesas(false); + } }; - getMesa() - }, []); + + fetchMesas(); + }, [idCuenta]); return ( -
- -
- + + + + + + + + + +
+ -
- +
); } diff --git a/app/Components/BitacoraSanciones/TableSancion.tsx b/app/Components/BitacoraSanciones/TableSancion.tsx index 4e065d4..219fb74 100644 --- a/app/Components/BitacoraSanciones/TableSancion.tsx +++ b/app/Components/BitacoraSanciones/TableSancion.tsx @@ -36,27 +36,28 @@ export default function TableSancion({ idCuenta }: { idCuenta: number }) { useEffect(() => { if (!idCuenta) return; - // Obtener sanciones del alumno axios - .get( - `${envConfig.apiUrl}/asignacionTiempo_test/alumno-sancion/${idCuenta}` - ) + .get(`${envConfig.apiUrl}/alumno-sancion/${idCuenta}`) .then((res) => { setAlumno(res.data.student); setAlumnoSanciones( - res.data.alusancion?.length ? res.data.alusancion : [] + res.data.alusancion?.length ? res.data.alusancion : [], ); }) - .catch((err) => - toast.error("Error al obtener las sanciones del alumno:", err) - ); + .catch((err) => { + const mensaje = + err.response?.data?.message || + "Error al obtener las sanciones del alumno"; + + toast.error(mensaje); + }); // Obtener catálogo de sanciones axios - .get(`${envConfig.apiUrl}/asignacionTiempo_test/sancion`) + .get(`${envConfig.apiUrl}/sancion`) .then((res) => setSanciones(res.data)) .catch((err) => - toast.error("Error al obtener el catálogo de sanciones:", err) + toast.error("Error al obtener el catálogo de sanciones:", err), ); }, [idCuenta]); @@ -120,7 +121,6 @@ export default function TableSancion({ idCuenta }: { idCuenta: number }) { diff --git a/app/Components/CheckBoxMesa.tsx b/app/Components/CheckBoxMesa.tsx new file mode 100644 index 0000000..b32cea7 --- /dev/null +++ b/app/Components/CheckBoxMesa.tsx @@ -0,0 +1,44 @@ +"use client"; + +import { useState } from "react"; +import SearchUser from "./Global/SearchUser/searchUser"; +import SearchBoxEquipo from "./SearchEquipo"; + +export default function CheckBoxMesa({ + numAcount, +}: { + numAcount?: string | null; +}) { + const [modo, setModo] = useState<"Equipo" | "Cuenta" | null>(null); + + return ( + <> +
+ + + +
+ + {modo === "Cuenta" && } + {modo === "Equipo" && } + + ); +} diff --git a/app/Components/InformacionEquipos/ProgramSelector.tsx b/app/Components/InformacionEquipos/ProgramSelector.tsx index 4ebffa3..76ff9e4 100644 --- a/app/Components/InformacionEquipos/ProgramSelector.tsx +++ b/app/Components/InformacionEquipos/ProgramSelector.tsx @@ -68,14 +68,6 @@ export default function ProgramSelector() { return (
-
{programas.map((prog) => ( diff --git a/app/Components/auth/ChangePassword/changePassword.tsx b/app/Components/auth/ChangePassword/changePassword.tsx index 48b7b0b..0445706 100644 --- a/app/Components/auth/ChangePassword/changePassword.tsx +++ b/app/Components/auth/ChangePassword/changePassword.tsx @@ -15,6 +15,9 @@ export default function ChangePassword() { try{ const response = await apiClient.post("/user/changePassword", data); toast.success( `${response.data.message}`) + setPass(''); + setNewPass(''); + setconfirmNewPass(''); }catch{ toast.error( `No es la contraseña actual`) } diff --git a/app/Components/auth/Login/Login.tsx b/app/Components/auth/Login/Login.tsx index 25dc5cb..f98542a 100644 --- a/app/Components/auth/Login/Login.tsx +++ b/app/Components/auth/Login/Login.tsx @@ -41,6 +41,7 @@ function Login() { toast.success("Inicio de sesión exitoso"); router.push("/Impresiones"); + router.refresh(); } }; diff --git a/app/Components/auth/Logout/Logout.tsx b/app/Components/auth/Logout/Logout.tsx index 580eb85..04c49da 100644 --- a/app/Components/auth/Logout/Logout.tsx +++ b/app/Components/auth/Logout/Logout.tsx @@ -14,6 +14,8 @@ export default function Logout() { Cookies.remove("user", { path: "/" }); router.push("/"); + router.refresh(); + }; return ( diff --git a/app/Components/layout/BarNavigation/BarNavigation.tsx b/app/Components/layout/BarNavigation/BarNavigation.tsx index 7d1bc70..c6d9276 100644 --- a/app/Components/layout/BarNavigation/BarNavigation.tsx +++ b/app/Components/layout/BarNavigation/BarNavigation.tsx @@ -31,16 +31,6 @@ function BarNavigation() {
  • toggleSubMenu(0)}>Inscripciónes
      - { - e.stopPropagation(); - closeAllMenus(); - }} - > -
    • Agregar Tiempo
    • -
    • Inscripción Usuario
    • + { + e.stopPropagation(); + closeAllMenus(); + }} + > +
    • Agregar Tiempo
    • +
  • @@ -75,7 +75,7 @@ function BarNavigation() { closeAllMenus(); }} > -
  • Asignacion de Mesas
  • +
  • Asignación de Mesas
  • -
  • Asignacion de Equipos
  • +
  • Asignación de Equipos
  • { - const cookies = Object.fromEntries( - document.cookie.split("; ").map((c) => c.split("=")) - ); - setRole(cookies.role || ""); - }, []); +export default async function Header() { + const cookieStore = await cookies(); + const role = cookieStore.get("role")?.value || ""; return (
    @@ -21,11 +14,7 @@ function Header() { href="https://www.unam.mx/" target="_blank" className={header.center} - style={{ - display: "flex", - alignItems: "center", - margin: "10px 5px", - }} + style={{ display: "flex", alignItems: "center", margin: "10px 5px" }} >
    ); } - -export default Header; -//IO