From 12b6b6a60987e739b8b52832a8665b1f46871991 Mon Sep 17 00:00:00 2001 From: IO420 Date: Mon, 29 Sep 2025 22:48:06 -0600 Subject: [PATCH] return params --- .../BitacoraSanciones/Sanciones.tsx | 2 +- .../BitacoraSanciones/TableSancion.tsx | 34 ++++++++++++++----- app/Components/Impressions/impressions.tsx | 11 +++--- app/Components/Receipt/Receipt.tsx | 16 ++++----- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/Components/BitacoraSanciones/Sanciones.tsx b/app/Components/BitacoraSanciones/Sanciones.tsx index 477885f..0e4824b 100644 --- a/app/Components/BitacoraSanciones/Sanciones.tsx +++ b/app/Components/BitacoraSanciones/Sanciones.tsx @@ -20,7 +20,7 @@ export default async function Sanciones(props: { student?: Student }) { Nombre={props.student.nombre} /> - + )} diff --git a/app/Components/BitacoraSanciones/TableSancion.tsx b/app/Components/BitacoraSanciones/TableSancion.tsx index 4c83424..98de26c 100644 --- a/app/Components/BitacoraSanciones/TableSancion.tsx +++ b/app/Components/BitacoraSanciones/TableSancion.tsx @@ -1,4 +1,8 @@ +"use client"; + +import { useEffect, useState } from "react"; import styles from "./Page.module.css"; +import axios from "axios"; interface alumno_sancion { id_alumno_sancion: number; @@ -20,9 +24,25 @@ interface sancion { } export default function TableSancion() { + const [sanciones, setSanciones] = useState(); + const [button, setButton] = useState(false); + useEffect(() => { + const getSanciones = async () => { + const response = await axios.get( + "" + ); + setSanciones(response); + }; + getSanciones(); + }, [button]); + + const handlebutton = () => { + setButton(!button); + }; return ( <> +

{sanciones}

@@ -34,24 +54,22 @@ export default function TableSancion() { - - - +
Podra utilizar el servicio hasta
- -
+ +

{button ?

desactivado

:

activado

}

); } diff --git a/app/Components/Impressions/impressions.tsx b/app/Components/Impressions/impressions.tsx index 0f1a2cf..018a35d 100644 --- a/app/Components/Impressions/impressions.tsx +++ b/app/Components/Impressions/impressions.tsx @@ -2,7 +2,7 @@ import Cookies from "js-cookie"; import { useState } from "react"; -import { usePathname, useRouter, useSearchParams } from "next/navigation"; +import { useRouter } from "next/navigation"; import { PostImpressions } from "@/app/lib/postImpressions"; interface CostOption { @@ -19,8 +19,6 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { const [cost, setCost] = useState(""); const router = useRouter(); - const pathname = usePathname(); - const searchParams = useSearchParams(); const handleLogout = () => { Cookies.remove("token"); @@ -29,11 +27,12 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { }; const handlePayment = async () => { - const params = new URLSearchParams(searchParams.toString()); + const currentUrl = new URL(window.location.href); + const params = new URLSearchParams(); const setError = (msg: string) => { params.set("error", msg); - router.push(`${pathname}&${params.toString()}`); + router.push(`${currentUrl}&${params.toString()}`); }; if (!numAcount) { @@ -66,7 +65,7 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { setCost(""); params.delete("error"); params.set("success", "Impresion cobrada correctamente"); - router.push(`${pathname}&${params.toString()}`); + router.push(`${currentUrl}&${params.toString()}`); }; return ( diff --git a/app/Components/Receipt/Receipt.tsx b/app/Components/Receipt/Receipt.tsx index 019ed29..60efc9d 100644 --- a/app/Components/Receipt/Receipt.tsx +++ b/app/Components/Receipt/Receipt.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { PostReceipt } from "@/app/lib/postReceipt"; -import { usePathname, useRouter, useSearchParams } from "next/navigation"; +import { useRouter } from "next/navigation"; import "./Receipt.css"; @@ -12,8 +12,6 @@ interface ReceiptsProps { function Receipt({ numAcount }: ReceiptsProps) { const router = useRouter(); - const pathname = usePathname(); - const searchParams = useSearchParams(); const [folio, setFolio] = useState(""); const [amount, setAmount] = useState(""); @@ -30,11 +28,12 @@ function Receipt({ numAcount }: ReceiptsProps) { //restrict this month// const handleSaveReceipt = async () => { - const params = new URLSearchParams(searchParams.toString()); + const currentUrl = new URL(window.location.href); + const params = new URLSearchParams(); const setError = (msg: string) => { params.set("error", msg); - router.push(`${pathname}&${params.toString()}`); + router.push(`${currentUrl}&${params.toString()}`); }; if (!numAcount) { @@ -67,7 +66,7 @@ function Receipt({ numAcount }: ReceiptsProps) { params.delete("error"); params.set("success", "Recibo guardado"); - router.push(`${pathname}&${params.toString()}`); + router.push(`${currentUrl}&${params.toString()}`); } catch (err: any) { setError(String(err)); } @@ -112,9 +111,10 @@ function Receipt({ numAcount }: ReceiptsProps) { if (value === "" || numericValue <= 1000) { setAmount(value); } else { - const params = new URLSearchParams(searchParams.toString()); + const currentUrl = new URL(window.location.href); + const params = new URLSearchParams(); params.set("error", "El monto no puede superar $1000.00"); - router.push(`${pathname}&${params.toString()}`); + router.push(`${currentUrl}&${params.toString()}`); } } }}