From 7f8b28753ef630e7105b6012fa5ef3bc5d413de9 Mon Sep 17 00:00:00 2001 From: tyrannusss Date: Tue, 7 Oct 2025 15:17:07 -0600 Subject: [PATCH 1/4] consultas a base de datos --- .../BitacoraSanciones/Sanciones.tsx | 3 +- .../BitacoraSanciones/TableSancion.tsx | 100 +++++++++++++++--- package-lock.json | 25 ++++- package.json | 3 +- 4 files changed, 113 insertions(+), 18 deletions(-) diff --git a/app/Components/BitacoraSanciones/Sanciones.tsx b/app/Components/BitacoraSanciones/Sanciones.tsx index b4442e9..109ccc2 100644 --- a/app/Components/BitacoraSanciones/Sanciones.tsx +++ b/app/Components/BitacoraSanciones/Sanciones.tsx @@ -19,8 +19,7 @@ export default async function Sanciones(props: { student?: Student }) { NoCuenta={props.student.id_cuenta} Nombre={props.student.nombre} /> - - + )} diff --git a/app/Components/BitacoraSanciones/TableSancion.tsx b/app/Components/BitacoraSanciones/TableSancion.tsx index e45662e..0585608 100644 --- a/app/Components/BitacoraSanciones/TableSancion.tsx +++ b/app/Components/BitacoraSanciones/TableSancion.tsx @@ -24,24 +24,64 @@ interface sancion { } export default function TableSancion() { - const [sanciones, setSanciones] = useState(); + const [sanciones, setSanciones] = useState([]); const [button, setButton] = useState(false); + const [selectedSancion, setSelectedSancion] = useState(""); + const [alumnoSanciones, setAlumnoSanciones] = useState([]); + /* + useEffect(() => { + const getSanciones = async () => { + const response = await axios.get(""); + setSanciones(response); + }; + getSanciones(); + }, [button]); - // useEffect(() => { - // const getSanciones = async () => { - // const response = await axios.get(""); - // setSanciones(response); - // }; - // getSanciones(); - // }, [button]); + + + {new Date(item.fecha_inicio).toLocaleDateString()} + + {calcularFechaFin(item.fecha_inicio, item.sancion?.duracion)} + + + https://venus.acatlan.unam.mx/asignacionTiempo_test/alumno-sancion/320154041 + .get("https://venus.acatlan.unam.mx/asignacionTiempo_test/sancion") +*/ + useEffect(() => { + axios + .get( + " https://venus.acatlan.unam.mx/asignacionTiempo_test/alumno-sancion/320154041" + ) + .then((response) => { + setAlumnoSanciones(response.data); + }) + .catch((error) => { + console.error("Error al obtener las sanciones:", error); + }); + + axios + .get("https://venus.acatlan.unam.mx/asignacionTiempo_test/sancion") + .then((response) => { + setSanciones(response.data); + }) + .catch((error) => { + console.error("Error al obtener las sanciones:", error); + }); + }, []); const handlebutton = () => { setButton(!button); }; - + + const calcularFechaFin = (fechaInicio: string, duracionSemanas: number) => { + const fecha = new Date(fechaInicio); + fecha.setDate(fecha.getDate() + duracionSemanas * 7); + return fecha.toLocaleDateString(); + }; + return ( <> -
+
@@ -52,19 +92,51 @@ export default function TableSancion() { - + + {sanciones.length > 0 ? ( + alumnoSanciones.map((item: any) => ( + + + + + + + + )) + ) : ( + + + + )} +
Podra utilizar el servicio hasta
{item.alumno?.id_cuenta}{item.sancion?.sancion}{item.sancion?.duracion}{new Date(item.fecha_inicio).toLocaleDateString()} + {calcularFechaFin( + item.fecha_inicio, + item.sancion?.duracion + )} +
No hay sanciones registradas
- setSelectedSancion(e.target.value)} + > - + {sanciones.map((sancion: any) => ( + + ))}
- diff --git a/package-lock.json b/package-lock.json index 9bc5488..6fbc9c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,8 @@ "react": "19.1.0", "react-dom": "19.1.0", "react-hot-toast": "^2.6.0", - "react-icons": "^5.5.0" + "react-icons": "^5.5.0", + "react-toastify": "^11.0.5" }, "devDependencies": { "@types/js-cookie": "^3.0.6", @@ -688,6 +689,15 @@ "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", "license": "MIT" }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/color": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", @@ -1174,6 +1184,19 @@ "react": "*" } }, + "node_modules/react-toastify": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-11.0.5.tgz", + "integrity": "sha512-EpqHBGvnSTtHYhCPLxML05NLY2ZX0JURbAdNYa6BUkk+amz4wbKBQvoKQAB0ardvSarUBuY4Q4s1sluAzZwkmA==", + "license": "MIT", + "dependencies": { + "clsx": "^2.1.1" + }, + "peerDependencies": { + "react": "^18 || ^19", + "react-dom": "^18 || ^19" + } + }, "node_modules/scheduler": { "version": "0.26.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.26.0.tgz", diff --git a/package.json b/package.json index c888ba7..c422cf7 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "react": "19.1.0", "react-dom": "19.1.0", "react-hot-toast": "^2.6.0", - "react-icons": "^5.5.0" + "react-icons": "^5.5.0", + "react-toastify": "^11.0.5" }, "devDependencies": { "@types/js-cookie": "^3.0.6", From 139c0b507217617230dde3ca0a86081c062fa435 Mon Sep 17 00:00:00 2001 From: tyrannusss Date: Thu, 9 Oct 2025 17:14:53 -0600 Subject: [PATCH 2/4] consulta en quitar sancion --- .../BitacoraSanciones/TableSancion.tsx | 2 +- .../QuitarSancion/QuitarSancion.tsx | 85 ++++++++++++++++--- 2 files changed, 72 insertions(+), 15 deletions(-) diff --git a/app/Components/BitacoraSanciones/TableSancion.tsx b/app/Components/BitacoraSanciones/TableSancion.tsx index 0585608..6ff31d2 100644 --- a/app/Components/BitacoraSanciones/TableSancion.tsx +++ b/app/Components/BitacoraSanciones/TableSancion.tsx @@ -50,7 +50,7 @@ export default function TableSancion() { useEffect(() => { axios .get( - " https://venus.acatlan.unam.mx/asignacionTiempo_test/alumno-sancion/320154041" + " https://venus.acatlan.unam.mx/asignacionTiempo_test/alumno-sancion/423019393" ) .then((response) => { setAlumnoSanciones(response.data); diff --git a/app/Components/QuitarSancion/QuitarSancion.tsx b/app/Components/QuitarSancion/QuitarSancion.tsx index 03516d2..622e7f5 100644 --- a/app/Components/QuitarSancion/QuitarSancion.tsx +++ b/app/Components/QuitarSancion/QuitarSancion.tsx @@ -1,9 +1,10 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import styles from "./Page.module.css"; +import axios from "axios"; -interface quitarSanciones { +interface alumno_sancion { id: number; nombre: string; motivo: string; @@ -12,11 +13,53 @@ interface quitarSanciones { utilizar_equipo: number; } +interface alumno { + id_cuenta: number; + nombre: string; + credito: number; +} + +interface sancion { + id_sancion: number; + sancion: string; + duracion: number; +} + function QuitarSancion() { - const [quitarSanciones, SetQuitarSanciones] = useState([]); + const [quitarSanciones, SetQuitarSanciones] = useState([]); + const [sanciones, setSanciones] = useState([]); + const [alumnoSanciones, setAlumnoSanciones] = useState([]); + useEffect(() => { + axios + .get( + " https://venus.acatlan.unam.mx/asignacionTiempo_test/alumno-sancion/423019393" + ) + .then((response) => { + SetQuitarSanciones(response.data); + }) + .catch((error) => { + console.error("Error al obtener las sanciones:", error); + }); + + axios + .get("https://venus.acatlan.unam.mx/asignacionTiempo_test/sancion") + .then((response) => { + setSanciones(response.data); + }) + .catch((error) => { + console.error("Error al obtener las sanciones:", error); + }); + }, []); + + const calcularFechaFin = (fechaInicio: string, duracionSemanas: number) => { + const fecha = new Date(fechaInicio); + fecha.setDate(fecha.getDate() + duracionSemanas * 7); + return fecha.toLocaleDateString(); + }; + return (
-
+
@@ -29,20 +72,34 @@ function QuitarSancion() { - {quitarSanciones.map((quitarSanciones, index) => ( - - - - - - - + {sanciones.length > 0 ? ( + quitarSanciones.map((item: any) => ( + + + + + + + + + + )) + ) : ( + + - ))} + )}
{quitarSanciones.id}{quitarSanciones.nombre}{quitarSanciones.motivo}{quitarSanciones.duracion}{quitarSanciones.fecha_sancion}{quitarSanciones.utilizar_equipo}
{item.id_alumno_sancion}{item.alumno?.nombre}{item.sancion?.sancion}{item.sancion?.duracion}{new Date(item.fecha_inicio).toLocaleDateString()} + {calcularFechaFin( + item.fecha_inicio, + item.sancion?.duracion + )} +
No hay sanciones registradas
- +
); } From d05bf5a3ea556f759cc1c34fbe0037430bf9cd55 Mon Sep 17 00:00:00 2001 From: tyrannusss Date: Mon, 13 Oct 2025 16:47:17 -0600 Subject: [PATCH 3/4] Creacion de nuevo componente y arreglos de botones --- app/(private)/BitacoraSanciones/page.tsx | 26 ++++----- app/(private)/Impresiones/page.tsx | 6 +- .../BitacoraSanciones/BitacoraAlumno.tsx | 4 +- .../BitacoraSanciones/BitacoraEquipo.tsx | 7 +-- .../Global/SearchUser/SearchUserWithDate.tsx | 58 +++++++++++++++++++ 5 files changed, 79 insertions(+), 22 deletions(-) create mode 100644 app/Components/Global/SearchUser/SearchUserWithDate.tsx 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 From 059136375e8eeed4a89ca4a3efc8f69b7979b423 Mon Sep 17 00:00:00 2001 From: tyrannusss Date: Mon, 13 Oct 2025 17:14:45 -0600 Subject: [PATCH 4/4] q --- app/(private)/QuitarSancion/page.tsx | 5 ++--- app/Components/QuitarSancion/QuitarSancion.tsx | 13 ++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/(private)/QuitarSancion/page.tsx b/app/(private)/QuitarSancion/page.tsx index 7e2a7ed..c945287 100644 --- a/app/(private)/QuitarSancion/page.tsx +++ b/app/(private)/QuitarSancion/page.tsx @@ -12,10 +12,9 @@ export default async function Page(props: { return ( <>

Quitar Sanciones

-
+
- +
); diff --git a/app/Components/QuitarSancion/QuitarSancion.tsx b/app/Components/QuitarSancion/QuitarSancion.tsx index 622e7f5..108aed2 100644 --- a/app/Components/QuitarSancion/QuitarSancion.tsx +++ b/app/Components/QuitarSancion/QuitarSancion.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from "react"; import styles from "./Page.module.css"; import axios from "axios"; +import { envConfig } from "@/app/lib/config"; interface alumno_sancion { id: number; @@ -25,15 +26,17 @@ interface sancion { duracion: number; } -function QuitarSancion() { +interface prop { + numAcount: string | null; +} + +function QuitarSancion(props: prop) { const [quitarSanciones, SetQuitarSanciones] = useState([]); const [sanciones, setSanciones] = useState([]); const [alumnoSanciones, setAlumnoSanciones] = useState([]); useEffect(() => { axios - .get( - " https://venus.acatlan.unam.mx/asignacionTiempo_test/alumno-sancion/423019393" - ) + .get(`${envConfig.apiUrl}/alumno-sancion/${props.numAcount}`) .then((response) => { SetQuitarSanciones(response.data); }) @@ -42,7 +45,7 @@ function QuitarSancion() { }); axios - .get("https://venus.acatlan.unam.mx/asignacionTiempo_test/sancion") + .get(`${envConfig.apiUrl}/asignacionTiempo_test/sancion`) .then((response) => { setSanciones(response.data); })