diff --git a/app/(private)/ActivosMantenimiento/page.tsx b/app/(private)/ActivosMantenimiento/page.tsx index 87949da..9657fd0 100644 --- a/app/(private)/ActivosMantenimiento/page.tsx +++ b/app/(private)/ActivosMantenimiento/page.tsx @@ -2,6 +2,7 @@ import Areas from "@/app/Components/ActivosMantenimiento/Areas"; import Mesas from "@/app/Components/ActivosMantenimiento/Mesas"; import Equipos from "@/app/Components/Equipos/equipos"; import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; import SearchUser from "@/app/Components/Global/SearchUser/searchUser"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; @@ -21,11 +22,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

EQUIPOS ACTIVOS Y EN MANTENIMIENTO

diff --git a/app/(private)/AgregarTiempo/page.tsx b/app/(private)/AgregarTiempo/page.tsx index 466ad4e..bbf12da 100644 --- a/app/(private)/AgregarTiempo/page.tsx +++ b/app/(private)/AgregarTiempo/page.tsx @@ -6,6 +6,7 @@ import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; import { GetStudent } from "@/app/lib/getStudent"; import "./addTime.css"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -33,11 +34,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

AGREGAR TIEMPO

@@ -49,7 +56,7 @@ export default async function Page(props: {
- +
) : ( diff --git a/app/(private)/Alta/page.tsx b/app/(private)/Alta/page.tsx index 167f43c..2e51c0a 100644 --- a/app/(private)/Alta/page.tsx +++ b/app/(private)/Alta/page.tsx @@ -2,6 +2,7 @@ import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; import RegisterAlta from "@/app/Components/Alta/registerAlta"; import "./style.css"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -16,11 +17,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

ALTA

diff --git a/app/(private)/AsignacionEquipo/page.tsx b/app/(private)/AsignacionEquipo/page.tsx index 7c5cf3d..5c5437e 100644 --- a/app/(private)/AsignacionEquipo/page.tsx +++ b/app/(private)/AsignacionEquipo/page.tsx @@ -1,4 +1,5 @@ import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; import SearchUser from "@/app/Components/Global/SearchUser/searchUser"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; @@ -19,11 +20,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

ASIGNACION DE EQUIPOS

diff --git a/app/(private)/BitacoraSanciones/page.tsx b/app/(private)/BitacoraSanciones/page.tsx index f4bb4ed..cc6c2cd 100644 --- a/app/(private)/BitacoraSanciones/page.tsx +++ b/app/(private)/BitacoraSanciones/page.tsx @@ -5,6 +5,7 @@ import Sanciones from "@/app/Components/BitacoraSanciones/Sanciones"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; import { GetStudent } from "@/app/lib/getStudent"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -34,11 +35,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

BITACORA Y SANCIONES

diff --git a/app/(private)/CambiarPass/page.tsx b/app/(private)/CambiarPass/page.tsx index 2c88235..23da32e 100644 --- a/app/(private)/CambiarPass/page.tsx +++ b/app/(private)/CambiarPass/page.tsx @@ -1,5 +1,6 @@ import ChangePassword from "@/app/Components/auth/ChangePassword/changePassword"; import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -14,11 +15,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

Cambiar contraseña

diff --git a/app/(private)/Impresiones/page.tsx b/app/(private)/Impresiones/page.tsx index 106b06e..f02e6d2 100644 --- a/app/(private)/Impresiones/page.tsx +++ b/app/(private)/Impresiones/page.tsx @@ -7,6 +7,7 @@ import Impressions from "@/app/Components/Impressions/impressions"; import { GetStudent } from "@/app/lib/getStudent"; import "@/app/globals.css"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -36,11 +37,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

IMPRESIONES Y PLOTEO

@@ -61,12 +68,7 @@ export default async function Page(props: { { key: "Recibo", label: "Recibo", - content: ( - - ), + content: , }, { key: "B/N", diff --git a/app/(private)/InformacionEquipo/page.tsx b/app/(private)/InformacionEquipo/page.tsx index b61b282..f0d7e2b 100644 --- a/app/(private)/InformacionEquipo/page.tsx +++ b/app/(private)/InformacionEquipo/page.tsx @@ -4,6 +4,7 @@ import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; import ProgramSelector from "@/app/Components/InformacionEquipos/ProgramSelector"; import "./informacionequipo.css"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -20,11 +21,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

INFORMACION DE EQUIPOS

diff --git a/app/(private)/Inscripcion/inscripcion.css b/app/(private)/Inscripcion/inscripcion.css new file mode 100644 index 0000000..7b05ca4 --- /dev/null +++ b/app/(private)/Inscripcion/inscripcion.css @@ -0,0 +1,9 @@ +.inscripcion{ + background-color: #f9f9f9; + width: 100%; + max-width: 700px; + border-radius: 4px; + padding: 1rem; + margin-top: 1rem; + outline: 1px solid #cfcfcf; +} \ No newline at end of file diff --git a/app/(private)/Inscripcion/inscriptions.css b/app/(private)/Inscripcion/inscriptions.css deleted file mode 100644 index e69de29..0000000 diff --git a/app/(private)/Inscripcion/page.tsx b/app/(private)/Inscripcion/page.tsx index 72c7c8e..0529080 100644 --- a/app/(private)/Inscripcion/page.tsx +++ b/app/(private)/Inscripcion/page.tsx @@ -1,12 +1,12 @@ import SearchUser from "@/app/Components/Global/SearchUser/searchUser"; import Information from "@/app/Components/Global/Information/information"; -import StepNavigator from "@/app/Components/Global/StepNavigator/StepNavigator"; import Receipt from "@/app/Components/Receipt/Receipt"; import Selection from "@/app/Components/Selection/Selection"; import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; import { GetStudent } from "@/app/lib/getStudent"; -import "./inscriptions.css"; +import "./inscripcion.css"; export default async function Page(props: { searchParams?: Promise<{ @@ -34,18 +34,24 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

INSCRIPCION

- {student ? ( + {student && ( <> - - +
- - + +
- ) : ( - <> )}
); diff --git a/app/(private)/Inscritos/page.tsx b/app/(private)/Inscritos/page.tsx index 6f2bd45..be351f6 100644 --- a/app/(private)/Inscritos/page.tsx +++ b/app/(private)/Inscritos/page.tsx @@ -1,3 +1,5 @@ +import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; export default async function Page(props: { searchParams?: Promise<{ @@ -12,14 +14,26 @@ export default async function Page(props: { const showError = params?.error ? params.error : null; return ( -
-

INSCRITOS

+
+ {showError && ( + <> + + + + )} + + {showSuccess && ( + <> + + + + )} +

INSCRITOS

- @@ -28,17 +42,14 @@ export default async function Page(props: { -
-
- +
@@ -48,12 +59,10 @@ export default async function Page(props: { - - +
CarreraProfesores
- ); } -//IO \ No newline at end of file +//IO diff --git a/app/(private)/Mensajes/page.tsx b/app/(private)/Mensajes/page.tsx index ac09c40..eaeaf38 100644 --- a/app/(private)/Mensajes/page.tsx +++ b/app/(private)/Mensajes/page.tsx @@ -1,5 +1,6 @@ import EnviarMensaje from "@/app/Components/EviarMensaje/EnviarMensaje"; import AlertBox from "@/app/Components/Global/AlertBox/AlertBox"; +import ClearParams from "@/app/Components/Global/ClearParams/ClearParams"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; export default async function Page(props: { @@ -17,11 +18,17 @@ export default async function Page(props: { return (
{showError && ( - + <> + + + )} {showSuccess && ( - + <> + + + )}

Enviar mensaje

diff --git a/app/Components/BitacoraSanciones/Sanciones.tsx b/app/Components/BitacoraSanciones/Sanciones.tsx index c0199cf..ac97716 100644 --- a/app/Components/BitacoraSanciones/Sanciones.tsx +++ b/app/Components/BitacoraSanciones/Sanciones.tsx @@ -1,9 +1,10 @@ import Information from "../Global/Information/information"; import SearchUser from "../Global/SearchUser/searchUser"; +import TableSancion from "./TableSancion"; interface Student { - id_cuenta: string ; - nombre: string ; + id_cuenta: string; + nombre: string; } export default async function Sanciones(props: { student?: Student }) { @@ -13,7 +14,14 @@ export default async function Sanciones(props: { student?: Student }) { <> {props.student && ( - + <> + + + + )} ); diff --git a/app/Components/BitacoraSanciones/TableSancion.tsx b/app/Components/BitacoraSanciones/TableSancion.tsx new file mode 100644 index 0000000..4c83424 --- /dev/null +++ b/app/Components/BitacoraSanciones/TableSancion.tsx @@ -0,0 +1,58 @@ +import styles from "./Page.module.css"; + +interface alumno_sancion { + id_alumno_sancion: number; + fecha_inicio: string; + alumno: alumno; + sancion: sancion; +} + +interface alumno { + id_cuenta: number; + nombre: string; + credito: number; +} + +interface sancion { + id_sancion: number; + sancion: string; + duracion: number; +} + +export default function TableSancion() { + + return ( + <> +
+ + + + + + + + + + + + + +
CuentaMotivo de la sancionDuracion (Semanas) Fecha SancionPodra utilizar el servicio hasta
+
+ +
+
+ + +
+
+ + ); +} +//IO diff --git a/app/Components/BitacoraSanciones/UbicacionEquipo.tsx b/app/Components/BitacoraSanciones/UbicacionEquipo.tsx deleted file mode 100644 index 1482c17..0000000 --- a/app/Components/BitacoraSanciones/UbicacionEquipo.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { useState } from "react"; - -import styles from "./Page.module.css"; - -interface alumno_sancion { - id_alumno_sancion: number; - fecha_inicio: string; - alumno: alumno; - sancion: sancion; -} - -interface alumno { - id_cuenta: number; - nombre: string; - credito: number; -} - -interface sancion { - id_sancion: number; - sancion: string; - duracion: number; -} - -export default function UbicacionEquipo(sanciones:alumno_sancion[]) { - const [ubicacionEquipo, setUbicacionEquipo] = useState(""); - - return ( - <> -
- - -
- - -
-
- -
- - - - - - - - - - - - {sanciones && - sanciones.map((s, index) => ( - - - - - - - ))} - -
CuentaMotivo de la sancionDuracion (Semanas) Fecha SancionPodra utilizar el servicio hasta
{s.sancion.id_sancion}{s.sancion.sancion}{s.fecha_inicio}{s.sancion.duracion}
-
- -
-
- - -
-
- - ); -} -//IO diff --git a/app/Components/Global/AlertBox/AlertBox.tsx b/app/Components/Global/AlertBox/AlertBox.tsx index e8863ea..aa295e5 100644 --- a/app/Components/Global/AlertBox/AlertBox.tsx +++ b/app/Components/Global/AlertBox/AlertBox.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; import "./AlertBox.css"; +import ClearParams from "../ClearParams/ClearParams"; interface AlertBoxProps { message: string | null; diff --git a/app/Components/Global/FormHandle.tsx b/app/Components/Global/FormHandle.tsx new file mode 100644 index 0000000..6f3d3c9 --- /dev/null +++ b/app/Components/Global/FormHandle.tsx @@ -0,0 +1,40 @@ +"use client"; + +import { ReactNode, useCallback } from "react"; +import { useRouter, usePathname, useSearchParams } from "next/navigation"; + +interface FormHandlerProps { + children: ReactNode; + onSubmit: () => Promise; +} + +export default function FormHandler({ children, onSubmit }: FormHandlerProps) { + const router = useRouter(); + const searchParams = useSearchParams(); + const pathname = usePathname(); + + const updateParams = useCallback( + (updates: Record) => { + const params = new URLSearchParams(searchParams.toString()); + + Object.entries(updates).forEach(([key, value]) => { + if (value === null) params.delete(key); + else params.set(key, value); + }); + + router.push(`${pathname}?${params.toString()}`); + }, + [searchParams, router, pathname] + ); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + try { + await onSubmit(); + } catch (err: any) { + updateParams({ error: String(err) }); + } + }; + + return
{children}
; +} diff --git a/app/Components/Impressions/impressions.tsx b/app/Components/Impressions/impressions.tsx index 1197b47..018a35d 100644 --- a/app/Components/Impressions/impressions.tsx +++ b/app/Components/Impressions/impressions.tsx @@ -27,25 +27,24 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { }; const handlePayment = async () => { + const currentUrl = new URL(window.location.href); + const params = new URLSearchParams(); + + const setError = (msg: string) => { + params.set("error", msg); + router.push(`${currentUrl}&${params.toString()}`); + }; + if (!numAcount) { - router.push( - `/Impresiones?numAcount=${numAcount}&error=Error busca denuevo al estudiante` - ); - return; + return setError("busca de nuevo al estudiante"); } if (!pages) { - router.push( - `/Impresiones?numAcount=${numAcount}&error=Ingresa el numero de hojas a imprimir` - ); - return; + return setError("Ingresa el numero de hojas a imprimir"); } if (!cost) { - router.push( - `/Impresiones?numAcount=${numAcount}&error=Selecciona un costo` - ); - return; + return setError("Selecciona un costo"); } const result = await PostImpressions({ @@ -57,18 +56,16 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { if (result.error) { if (result.error === "Token inválido") handleLogout(); else { - router.push( - `/Impresiones?numAcount=${numAcount}&error=${result.error}` - ); + return setError(`Error: ${result.error}`); } return; } setPages(""); setCost(""); - router.push( - `/Impresiones?numAcount=${numAcount}&success=Impresion cobrada correctamente` - ); + params.delete("error"); + params.set("success", "Impresion cobrada correctamente"); + router.push(`${currentUrl}&${params.toString()}`); }; return ( @@ -109,10 +106,12 @@ function Impressions({ costs, numAcount }: ImpressionsProps) {
-
diff --git a/app/Components/Receipt/Receipt.tsx b/app/Components/Receipt/Receipt.tsx index 29f9af1..60efc9d 100644 --- a/app/Components/Receipt/Receipt.tsx +++ b/app/Components/Receipt/Receipt.tsx @@ -7,11 +7,10 @@ import { useRouter } from "next/navigation"; import "./Receipt.css"; interface ReceiptsProps { - urlBase: string; numAcount: number | null; } -function Receipt({ urlBase, numAcount }: ReceiptsProps) { +function Receipt({ numAcount }: ReceiptsProps) { const router = useRouter(); const [folio, setFolio] = useState(""); @@ -29,30 +28,28 @@ function Receipt({ urlBase, numAcount }: ReceiptsProps) { //restrict this month// const handleSaveReceipt = async () => { + const currentUrl = new URL(window.location.href); + const params = new URLSearchParams(); + + const setError = (msg: string) => { + params.set("error", msg); + router.push(`${currentUrl}&${params.toString()}`); + }; + if (!numAcount) { - router.push( - `${urlBase}?numAcount=${numAcount}&error=Error busca denuevo al estudiante` - ); - return; + return setError("busca de nuevo al estudiante"); } if (!folio) { - router.push( - `${urlBase}?numAcount=${numAcount}&error=Ingresa el folio del tiket` - ); - return; + return setError("Ingresa el folio del ticket"); } if (!amount) { - router.push( - `${urlBase}?numAcount=${numAcount}&error=coloca el monto a depositar` - ); - return; + return setError("Coloca el monto a depositar"); } if (!date) { - router.push(`${urlBase}?numAcount=${numAcount}&error=coloca la fecha`); - return; + return setError("Coloca la fecha"); } try { @@ -67,10 +64,11 @@ function Receipt({ urlBase, numAcount }: ReceiptsProps) { setAmount(""); setDate(""); - router.push(`${urlBase}?numAcount=${numAcount}&success=Recibo guardado`); + params.delete("error"); + params.set("success", "Recibo guardado"); + router.push(`${currentUrl}&${params.toString()}`); } catch (err: any) { - console.error(err); - router.push(`${urlBase}?numAcount=${numAcount}&error=${err}`); + setError(String(err)); } }; @@ -113,9 +111,10 @@ function Receipt({ urlBase, numAcount }: ReceiptsProps) { if (value === "" || numericValue <= 1000) { setAmount(value); } else { - router.push( - `${urlBase}?numAcount=${numAcount}&error=El monto no puede superar $1000.00` - ); + const currentUrl = new URL(window.location.href); + const params = new URLSearchParams(); + params.set("error", "El monto no puede superar $1000.00"); + router.push(`${currentUrl}&${params.toString()}`); } } }} diff --git a/app/globals.css b/app/globals.css index f00aa1b..2431623 100644 --- a/app/globals.css +++ b/app/globals.css @@ -14,6 +14,7 @@ html { box-sizing: border-box; font-size: 62.5%; overflow-y: auto; + scrollbar-width: none; } body {