| Podra utilizar el servicio hasta | - - - +
|---|
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()}`); } } }}