change to pathname and params
This commit is contained in:
@@ -45,7 +45,7 @@ export default async function Page(props: {
|
||||
label: "Equipos",
|
||||
content: (
|
||||
<>
|
||||
<SearchUser urlBase="ActivosMantenimiento" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
<Equipos />
|
||||
</>
|
||||
),
|
||||
|
||||
@@ -49,7 +49,7 @@ export default async function Page(props: {
|
||||
|
||||
<h2 className="title"> AGREGAR TIEMPO </h2>
|
||||
|
||||
<SearchUser urlBase="AgregarTiempo" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
|
||||
{student ? (
|
||||
<>
|
||||
|
||||
@@ -2,11 +2,14 @@ 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";
|
||||
import { GetStudent } from "@/app/lib/getStudent";
|
||||
|
||||
import '@/app/globals.css'
|
||||
|
||||
export default async function Page(props: {
|
||||
searchParams?: Promise<{
|
||||
numAcount?: string;
|
||||
machine?:string;
|
||||
machine?: string;
|
||||
success?: string;
|
||||
error?: string;
|
||||
}>;
|
||||
@@ -17,6 +20,17 @@ export default async function Page(props: {
|
||||
const showSuccess = params?.success ? params.success : null;
|
||||
const showError = params?.error ? params.error : null;
|
||||
|
||||
let student: any = null;
|
||||
|
||||
if (numAcount) {
|
||||
const result = await GetStudent(parseInt(numAcount));
|
||||
|
||||
if (result.error) {
|
||||
} else {
|
||||
student = result;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="containerSection">
|
||||
{showError && (
|
||||
@@ -32,7 +46,7 @@ export default async function Page(props: {
|
||||
<ClearParams paramsToClear={["success"]} />
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
<h2 className="title"> ASIGNACION DE EQUIPOS </h2>
|
||||
|
||||
<Toggle
|
||||
@@ -43,9 +57,9 @@ export default async function Page(props: {
|
||||
label: "Asignar tiempo",
|
||||
content: (
|
||||
<>
|
||||
<SearchUser urlBase="AsignacionEquipo" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
|
||||
<form className="containerForm"></form>
|
||||
{student && <h1>No hay records disponibles</h1>}
|
||||
</>
|
||||
),
|
||||
},
|
||||
@@ -63,7 +77,7 @@ export default async function Page(props: {
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<SearchUser urlBase="AsignacionEquipo" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function Page() {
|
||||
label: "Asignar mesa",
|
||||
content: (
|
||||
<>
|
||||
<SearchUser urlBase="AsignacionMesas" value={"3"} />
|
||||
<SearchUser value={"3"} />
|
||||
|
||||
<form className="containerForm">
|
||||
<label className="label">Mesas disponibles</label>
|
||||
@@ -56,7 +56,7 @@ export default function Page() {
|
||||
<input type="checkbox" /> Cuenta
|
||||
</label>
|
||||
</div>
|
||||
<SearchUser urlBase="AsignacionMesas" value={"3"} />
|
||||
<SearchUser value={"3"} />
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -51,7 +51,7 @@ export default async function Page(props: {
|
||||
)}
|
||||
|
||||
<h2 className="title">IMPRESIONES Y PLOTEO</h2>
|
||||
<SearchUser urlBase="Impresiones" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
|
||||
{student && (
|
||||
<>
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 240px); /* ancho fijo por columna */
|
||||
gap: 6px 20px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@ import ClearParams from "@/app/Components/Global/ClearParams/ClearParams";
|
||||
|
||||
export default async function Page(props: {
|
||||
searchParams?: Promise<{
|
||||
machine: string;
|
||||
key?:string;
|
||||
machine?: string;
|
||||
success?: string;
|
||||
error?: string;
|
||||
}>;
|
||||
}) {
|
||||
const params = await props.searchParams;
|
||||
const key = params?.key && params.key;
|
||||
const machine = params?.machine ? params.machine : null;
|
||||
const showSuccess = params?.success ? params.success : null;
|
||||
const showError = params?.error ? params.error : null;
|
||||
@@ -37,15 +39,15 @@ export default async function Page(props: {
|
||||
<h2 className="title"> INFORMACION DE EQUIPOS </h2>
|
||||
|
||||
<Toggle
|
||||
defaultView="1"
|
||||
defaultView={key}
|
||||
options={[
|
||||
{
|
||||
key: "1",
|
||||
key: "Equipos",
|
||||
label: "Equipos",
|
||||
content: <Equipos />,
|
||||
},
|
||||
{
|
||||
key: "2",
|
||||
key: "Equipo",
|
||||
label: "Programa por equipo",
|
||||
content: (
|
||||
<ProgramSelector
|
||||
@@ -56,7 +58,7 @@ export default async function Page(props: {
|
||||
),
|
||||
},
|
||||
{
|
||||
key: "3",
|
||||
key: "Sala",
|
||||
label: "Programa por sala",
|
||||
content: (
|
||||
<ProgramSelector
|
||||
|
||||
@@ -49,7 +49,7 @@ export default async function Page(props: {
|
||||
|
||||
<h2 className="title"> INSCRIPCION </h2>
|
||||
|
||||
<SearchUser urlBase="Inscripcion" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
|
||||
{student && (
|
||||
<>
|
||||
|
||||
@@ -17,7 +17,7 @@ export default async function Page(props: {
|
||||
<>
|
||||
<h2 className="title"> Quitar Sanciones </h2>
|
||||
<div style={{ display: "flex", gap: "1rem", flexDirection: "column" }}>
|
||||
<SearchUser urlBase="QuitarSancion" value={numAcount} />
|
||||
<SearchUser value={numAcount} />
|
||||
<QuitarSancion />
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -22,9 +22,10 @@ function Mesas() {
|
||||
<option value="90">15</option>
|
||||
</select>
|
||||
|
||||
<div className="checkbox">
|
||||
<div className="checkbox-grid">
|
||||
<label>
|
||||
<input type="checkbox" />
|
||||
<label>Mantenimiento</label>
|
||||
Mantenimiento</label>
|
||||
</div>
|
||||
|
||||
<button className="button buttonSearch" type="submit">
|
||||
|
||||
@@ -12,7 +12,7 @@ export default async function Sanciones(props: { student?: Student }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchUser urlBase="BitacoraSanciones" value={idCuenta} />
|
||||
<SearchUser value={idCuenta} />
|
||||
{props.student && (
|
||||
<>
|
||||
<Information
|
||||
|
||||
@@ -8,6 +8,7 @@ interface ClearParamsProps {
|
||||
|
||||
export default function ClearParams({ paramsToClear }: ClearParamsProps) {
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
const url = new URL(window.location.href);
|
||||
let changed = false;
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface urlProp{
|
||||
urlBase:string
|
||||
value:string|null
|
||||
interface urlProp {
|
||||
value: string | null;
|
||||
}
|
||||
|
||||
function SearchUser(props:urlProp) {
|
||||
function SearchUser(props: urlProp) {
|
||||
const [numAcount, setnumAcount] = useState("");
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
useEffect(() => {
|
||||
if (props.value) {
|
||||
@@ -20,16 +21,17 @@ function SearchUser(props:urlProp) {
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
if (numAcount) {
|
||||
router.push(`/${props.urlBase}?numAcount=${numAcount}`);
|
||||
params.delete("error");
|
||||
params.set("numAcount", `${numAcount}`);
|
||||
router.push(`${pathname}?${params.toString()}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<form className="containerForm"
|
||||
onSubmit={handleSubmit}>
|
||||
<form className="containerForm" onSubmit={handleSubmit}>
|
||||
<label className="label">No.Cuenta</label>
|
||||
<div className="groupInput">
|
||||
<input
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, ReactNode } from "react";
|
||||
|
||||
@@ -18,6 +18,7 @@ interface ToggleProps {
|
||||
export default function Toggle({ options, defaultView }: ToggleProps) {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const pathname = usePathname();
|
||||
const [view, setView] = useState(defaultView || options[0].key);
|
||||
|
||||
const handleClick = (key: string) => {
|
||||
@@ -26,7 +27,7 @@ export default function Toggle({ options, defaultView }: ToggleProps) {
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.set("key", key);
|
||||
|
||||
router.replace(`${window.location.pathname}?${params.toString()}`);
|
||||
router.replace(`${pathname}?${params.toString()}`);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import AlertBox from "@/app/Components/Global/AlertBox/AlertBox";
|
||||
import ClearParams from "@/app/Components/Global/ClearParams/ClearParams";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
|
||||
export default function GlobalAlert() {
|
||||
const searchParams = useSearchParams();
|
||||
const [showSuccess, setShowSuccess] = useState<string | null>(null);
|
||||
const [showError, setShowError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const url = new URL(window.location.href);
|
||||
const success = url.searchParams.get("success");
|
||||
const error = url.searchParams.get("error");
|
||||
const success = searchParams.get("success");
|
||||
const error = searchParams.get("error");
|
||||
|
||||
if (success) setShowSuccess(success);
|
||||
if (error) setShowError(error);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import Cookies from "js-cookie";
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { PostImpressions } from "@/app/lib/postImpressions";
|
||||
|
||||
interface CostOption {
|
||||
@@ -19,6 +19,8 @@ function Impressions({ costs, numAcount }: ImpressionsProps) {
|
||||
const [cost, setCost] = useState("");
|
||||
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const handleLogout = () => {
|
||||
Cookies.remove("token");
|
||||
@@ -27,12 +29,11 @@ function Impressions({ costs, numAcount }: ImpressionsProps) {
|
||||
};
|
||||
|
||||
const handlePayment = async () => {
|
||||
const currentUrl = new URL(window.location.href);
|
||||
const params = new URLSearchParams();
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
|
||||
const setError = (msg: string) => {
|
||||
params.set("error", msg);
|
||||
router.push(`${currentUrl}&${params.toString()}`);
|
||||
router.push(`${pathname}&${params.toString()}`);
|
||||
};
|
||||
|
||||
if (!numAcount) {
|
||||
@@ -65,7 +66,7 @@ function Impressions({ costs, numAcount }: ImpressionsProps) {
|
||||
setCost("");
|
||||
params.delete("error");
|
||||
params.set("success", "Impresion cobrada correctamente");
|
||||
router.push(`${currentUrl}&${params.toString()}`);
|
||||
router.push(`${pathname}&${params.toString()}`);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { PostReceipt } from "@/app/lib/postReceipt";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
|
||||
import "./Receipt.css";
|
||||
|
||||
@@ -12,6 +12,8 @@ interface ReceiptsProps {
|
||||
|
||||
function Receipt({ numAcount }: ReceiptsProps) {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const [folio, setFolio] = useState("");
|
||||
const [amount, setAmount] = useState("");
|
||||
@@ -28,12 +30,11 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
//restrict this month//
|
||||
|
||||
const handleSaveReceipt = async () => {
|
||||
const currentUrl = new URL(window.location.href);
|
||||
const params = new URLSearchParams();
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
|
||||
const setError = (msg: string) => {
|
||||
params.set("error", msg);
|
||||
router.push(`${currentUrl}&${params.toString()}`);
|
||||
router.push(`${pathname}&${params.toString()}`);
|
||||
};
|
||||
|
||||
if (!numAcount) {
|
||||
@@ -66,7 +67,7 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
|
||||
params.delete("error");
|
||||
params.set("success", "Recibo guardado");
|
||||
router.push(`${currentUrl}&${params.toString()}`);
|
||||
router.push(`${pathname}&${params.toString()}`);
|
||||
} catch (err: any) {
|
||||
setError(String(err));
|
||||
}
|
||||
@@ -111,10 +112,9 @@ function Receipt({ numAcount }: ReceiptsProps) {
|
||||
if (value === "" || numericValue <= 1000) {
|
||||
setAmount(value);
|
||||
} else {
|
||||
const currentUrl = new URL(window.location.href);
|
||||
const params = new URLSearchParams();
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
params.set("error", "El monto no puede superar $1000.00");
|
||||
router.push(`${currentUrl}&${params.toString()}`);
|
||||
router.push(`${pathname}&${params.toString()}`);
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -185,6 +185,10 @@ select:focus {
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
input[type="checkbox"]{
|
||||
min-width: 3rem;
|
||||
}
|
||||
|
||||
label {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
@@ -437,6 +441,20 @@ table tr {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.checkbox-grid label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
.checkbox-grid input[type="checkbox"] {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
transform: scale(1); /* mantiene el tamaño */
|
||||
}
|
||||
|
||||
@media (max-width: 1330px) {
|
||||
.centerGrid {
|
||||
display: flex !important;
|
||||
|
||||
Reference in New Issue
Block a user