diff --git a/app/(private)/BitacoraSanciones/page.tsx b/app/(private)/BitacoraSanciones/page.tsx index 5ebe1ff..dcbc1e1 100644 --- a/app/(private)/BitacoraSanciones/page.tsx +++ b/app/(private)/BitacoraSanciones/page.tsx @@ -3,6 +3,7 @@ import BitacoraEquipo from "@/app/Components/BitacoraSanciones/BitacoraEquipo"; import BitacoraMesas from "@/app/Components/BitacoraSanciones/BitacoraMesas"; import Sanciones from "@/app/Components/BitacoraSanciones/Sanciones"; import SearchUser from "@/app/Components/Global/SearchUser/searchUser"; +import SearchUserWithDate from "@/app/Components/Global/SearchUser/SearchUserWithDate"; import Toggle from "@/app/Components/Global/Toggle/Toggle"; import { GetStudent } from "@/app/lib/getStudent"; @@ -13,23 +14,22 @@ export default async function Page(props: { }>; }) { const params = await props.searchParams; - const key = params?.key && params.key ; + const key = params?.key && params.key; const numAcount = params?.numAcount ? params.numAcount : null; - let student: any = null; - - if (numAcount) { - const result = await GetStudent(parseInt(numAcount)); - - if (result.error) { - } else { - student = result; - } + let student: any = null; + + if (numAcount) { + const result = await GetStudent(parseInt(numAcount)); + + if (result.error) { + } else { + student = result; } + } return (
-

BITACORA Y SANCIONES

- + ), @@ -68,7 +68,7 @@ export default async function Page(props: { label: "Sanciones", content: ( <> - + ), }, diff --git a/app/(private)/Impresiones/page.tsx b/app/(private)/Impresiones/page.tsx index ca95c16..ec32bf1 100644 --- a/app/(private)/Impresiones/page.tsx +++ b/app/(private)/Impresiones/page.tsx @@ -1,3 +1,5 @@ +"use client"; + import SearchUser from "../../Components/Global/SearchUser/searchUser"; import Receipt from "../../Components/Receipt/Receipt"; import Toggle from "../../Components/Global/Toggle/Toggle"; @@ -8,6 +10,7 @@ import ShowError from "@/app/Components/Global/ShowError"; import { GetStudent } from "@/app/lib/getStudent"; import "@/app/globals.css"; +import toast from "react-hot-toast"; export default async function Page(props: { searchParams?: Promise<{ @@ -26,7 +29,7 @@ export default async function Page(props: { const result = await GetStudent(parseInt(numAcount)); if (result.error) { - errorMessage = `${result.error}`; + toast.error("This didn't work."); } else { student = result as Student; } @@ -34,7 +37,6 @@ export default async function Page(props: { return (
- {errorMessage && }

IMPRESIONES Y PLOTEO

diff --git a/app/Components/BitacoraSanciones/BitacoraAlumno.tsx b/app/Components/BitacoraSanciones/BitacoraAlumno.tsx index fc793b1..5f93426 100644 --- a/app/Components/BitacoraSanciones/BitacoraAlumno.tsx +++ b/app/Components/BitacoraSanciones/BitacoraAlumno.tsx @@ -3,6 +3,7 @@ import SearchDate from "../SearchDate/SearchDate"; import { useState } from "react"; import styles from "./Page.module.css"; +import SearchUserWithDate from "../Global/SearchUser/SearchUserWithDate"; interface alumnos { tiempo_entrada: string; @@ -14,8 +15,7 @@ function BitacoraAlumno() { const [alumnos, setAlumnos] = useState([]); return ( <> - -
+
diff --git a/app/Components/BitacoraSanciones/BitacoraEquipo.tsx b/app/Components/BitacoraSanciones/BitacoraEquipo.tsx index a335743..6ba88d8 100644 --- a/app/Components/BitacoraSanciones/BitacoraEquipo.tsx +++ b/app/Components/BitacoraSanciones/BitacoraEquipo.tsx @@ -16,7 +16,6 @@ function BitacoraEquipo() { const [ubicacion_equipo, setUbicacionEquipo] = useState(""); return ( <> -
@@ -28,12 +27,10 @@ function BitacoraEquipo() { - + -
+
diff --git a/app/Components/Global/SearchUser/SearchUserWithDate.tsx b/app/Components/Global/SearchUser/SearchUserWithDate.tsx new file mode 100644 index 0000000..e1470c4 --- /dev/null +++ b/app/Components/Global/SearchUser/SearchUserWithDate.tsx @@ -0,0 +1,58 @@ +"use client"; + +import { usePathname, useRouter, useSearchParams } from "next/navigation"; +import { useEffect, useState } from "react"; +import SearchDate from "../../SearchDate/SearchDate"; + +interface urlProp { + value: string | null; +} + +function SearchUserWithDate(props: urlProp) { + const [numAcount, setnumAcount] = useState(""); + const router = useRouter(); + const pathname = usePathname(); + const searchParams = useSearchParams(); + + useEffect(() => { + if (props.value) { + setnumAcount(props.value); + } + }, [props.value]); + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + const params = new URLSearchParams(searchParams.toString()); + if (numAcount) { + params.set("numAcount", `${numAcount}`); + router.push(`${pathname}?${params.toString()}`); + } + }; + + return ( + <> +
+ +
+ { + const value = e.target.value; + if (/^\d*$/.test(value) && value.length <= 9) { + setnumAcount(value); + } + }} + placeholder="Coloca un nĂºmero de cuenta..." + inputMode="numeric" + pattern="[0-9]*" + /> + +
+ + + ); +} + +export default SearchUserWithDate; +//IO