return params
This commit is contained in:
@@ -20,7 +20,7 @@ export default async function Sanciones(props: { student?: Student }) {
|
||||
Nombre={props.student.nombre}
|
||||
/>
|
||||
|
||||
<TableSancion />
|
||||
<TableSancion />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -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<any>();
|
||||
const [button, setButton] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
const getSanciones = async () => {
|
||||
const response = await axios.get(
|
||||
""
|
||||
);
|
||||
setSanciones(response);
|
||||
};
|
||||
getSanciones();
|
||||
}, [button]);
|
||||
|
||||
const handlebutton = () => {
|
||||
setButton(!button);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<h1>{sanciones}</h1>
|
||||
<div className={styles.tableContainer}>
|
||||
<table className={styles.machineTable}>
|
||||
<thead>
|
||||
@@ -34,24 +54,22 @@ export default function TableSancion() {
|
||||
<th>Podra utilizar el servicio hasta</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<form className="containerForm">
|
||||
<div className="groupInput">
|
||||
<select
|
||||
>
|
||||
<select>
|
||||
<option value="">-- Selecciona una sancion --</option>
|
||||
<option value="sancion 1">No cerrar sesion (Una semana)</option>
|
||||
</select>
|
||||
<button className="button buttonSearch" type="submit">
|
||||
Aplicar sancion
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<button className="button buttonSearch" onClick={handlebutton}>
|
||||
Aplicar sancion
|
||||
</button>
|
||||
<h1>{button ? <p>desactivado</p> : <p>activado</p>}</h1>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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()}`);
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user