diff --git a/app/(private)/Impresiones/page.tsx b/app/(private)/Impresiones/page.tsx index 715ce2b..3da83c2 100644 --- a/app/(private)/Impresiones/page.tsx +++ b/app/(private)/Impresiones/page.tsx @@ -3,26 +3,29 @@ import Receipt from "../../Components/Receipt/Receipt"; import Impressions from "../../Components/Impressions/impressions"; import Toggle from "../../Components/Toggle/Toggle"; import Information from "../../Components/Information/information"; - import AlertBox from "@/app/Components/AlertBox/AlertBox"; import { GetStudent } from "@/app/lib/getStudent"; + import "@/app/globals.css"; export default async function Page(props: { searchParams?: Promise<{ numAcount: string; + success?: string; + error?: string; }>; -}) { +}) { const params = await props.searchParams; - const numAcount = params?.numAcount ? parseInt(params.numAcount) : null; + const numAcount = params?.numAcount ? params.numAcount : null; + const showSuccess = params?.success ? parseInt(params.success) : null; + let showError = params?.error ? params.error : null; let student: any = null; - let error: string | null = null; if (numAcount) { - const result = await GetStudent(numAcount); + const result = await GetStudent(parseInt(numAcount)); if (result.error) { - error = result.error; + showError = "Alumno no encontrado" } else { student = result; } @@ -30,10 +33,16 @@ export default async function Page(props: { return (
- {error && } + {showError && ( + + )} + + {showSuccess && ( + + )}

IMPRESIONES Y PLOTEO

- + {student ? ( <> diff --git a/app/Components/AlertBox/AlertBox.tsx b/app/Components/AlertBox/AlertBox.tsx index 1711910..c9181a2 100644 --- a/app/Components/AlertBox/AlertBox.tsx +++ b/app/Components/AlertBox/AlertBox.tsx @@ -4,7 +4,7 @@ import { useEffect, useState } from "react"; import "./AlertBox.css"; interface AlertBoxProps { - message: string; + message: string | null; type: "error" | "success"; duration?: number; } diff --git a/app/Components/FallingSquares/FallingSquares.tsx b/app/Components/FallingSquares/FallingSquares.tsx new file mode 100644 index 0000000..5ea9bc0 --- /dev/null +++ b/app/Components/FallingSquares/FallingSquares.tsx @@ -0,0 +1,12 @@ +import "./style.css" +export default function FallingSquares() { + return ( +
+ {Array.from({ length: 10 }).map((_, i) => ( +
+ ))} +
+ ); +} +//Chat +//IO \ No newline at end of file diff --git a/app/Components/FallingSquares/style.css b/app/Components/FallingSquares/style.css new file mode 100644 index 0000000..8c462da --- /dev/null +++ b/app/Components/FallingSquares/style.css @@ -0,0 +1,117 @@ +.falling-container { + position: absolute; + width: 100%; + height: 100vh; + overflow: hidden; + z-index: -1; +} + +.square { + position: absolute; + top: -100px; + opacity: 0.9; + animation: fall linear infinite; + border-radius: 6px; +} + +@keyframes fall { + 0% { + transform: translateY(0) rotate(0deg); + } + 100% { + transform: translateY(110vh) rotate(1080deg); + } +} + +.square:nth-child(1) { + left: 10%; + width: 40px; + height: 40px; + background: linear-gradient(45deg, #ff7eb3, #ff758c); + animation-duration: 4s; + animation-delay: 0s; +} +.square:nth-child(2) { + left: 25%; + width: 60px; + height: 60px; + background: linear-gradient(45deg, #43cea2, #185a9d); + animation-duration: 6s; + animation-delay: 2s; +} +.square:nth-child(3) { + left: 40%; + width: 50px; + height: 50px; + background: linear-gradient(45deg, #f7971e, #ffd200); + animation-duration: 5s; + animation-delay: 1s; +} +.square:nth-child(4) { + left: 55%; + width: 70px; + height: 70px; + background: linear-gradient(45deg, #7f00ff, #e100ff); + animation-duration: 7s; + animation-delay: 3s; +} +.square:nth-child(5) { + left: 70%; + width: 45px; + height: 45px; + background: linear-gradient(45deg, #00c6ff, #0072ff); + animation-duration: 4.5s; + animation-delay: 1.5s; +} +.square:nth-child(6) { + left: 85%; + width: 55px; + height: 55px; + background: linear-gradient(45deg, #f953c6, #b91d73); + animation-duration: 6.5s; + animation-delay: 2.5s; +} +.square:nth-child(7) { + left: 15%; + width: 65px; + height: 65px; + background: linear-gradient(45deg, #11998e, #38ef7d); + animation-duration: 5.5s; + animation-delay: 1.2s; +} +.square:nth-child(8) { + left: 35%; + width: 40px; + height: 40px; + background: linear-gradient(45deg, #ff4e50, #f9d423); + animation-duration: 7.5s; + animation-delay: 0.5s; +} +.square:nth-child(9) { + left: 60%; + width: 75px; + height: 75px; + background: linear-gradient(45deg, #00b09b, #96c93d); + animation-duration: 4.2s; + animation-delay: 2.8s; +} +.square:nth-child(10) { + left: 80%; + width: 28px; + height: 28px; + background: linear-gradient(45deg, #ff9966, #ff5e62); + animation-duration: 6.8s; + animation-delay: 1.8s; +} + +@media (min-width: 768px) { + .square { + animation: fall linear infinite; + } +} + +@media (max-width: 767px) { + .square { + animation: none; + } +} diff --git a/app/Components/Impressions/impressions.tsx b/app/Components/Impressions/impressions.tsx index ed38e5b..4a1b5e4 100644 --- a/app/Components/Impressions/impressions.tsx +++ b/app/Components/Impressions/impressions.tsx @@ -1,9 +1,8 @@ "use client"; +import Cookies from "js-cookie"; import { useState } from "react"; import { useRouter } from "next/navigation"; -import Cookies from "js-cookie"; -import AlertBox from "../AlertBox/AlertBox"; import { PostImpressions } from "@/app/lib/postImpressions"; import "./Impressions.css"; @@ -21,7 +20,6 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { const [pages, setPages] = useState(""); const [cost, setCost] = useState(""); - const [error, setError] = useState(""); const router = useRouter(); const handleLogout = () => { @@ -31,37 +29,46 @@ function Impressions({ costs, numAcount }: ImpressionsProps) { }; const handlePayment = async () => { - setError(""); if (!numAcount) { - setError("Error busca denuevo al estudiante"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=Error busca denuevo al estudiante` + ); return; } if (!pages) { - setError("Ingresa el numero de hojas a imprimir"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=Ingresa el numero de hojas a imprimir` + ); return; } if (!cost) { - setError("Selecciona un costo"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=Selecciona un costo` + ); return; } const result = await PostImpressions({ - id_cuenta:numAcount, - numero_hojas : parseInt(pages), + id_cuenta: numAcount, + numero_hojas: parseInt(pages), monto: parseInt(cost) * parseInt(pages), }); if (result.error) { if (result.error === "Token inválido") handleLogout(); - else setError(result.error); + else { + router.push( + `/Impresiones?numAcount=${numAcount}&error=${result.error}` + ); + } return; } setPages(""); - setCost("") + setCost(""); }; return ( @@ -102,15 +109,15 @@ function Impressions({ costs, numAcount }: ImpressionsProps) {
- +
- - {error && }
diff --git a/app/Components/Receipt/Receipt.tsx b/app/Components/Receipt/Receipt.tsx index 0d19218..d5eb571 100644 --- a/app/Components/Receipt/Receipt.tsx +++ b/app/Components/Receipt/Receipt.tsx @@ -1,8 +1,8 @@ "use client"; -import AlertBox from "../AlertBox/AlertBox"; + import { useState } from "react"; import { PostReceipt } from "@/app/lib/postReceipt"; -import Cookies from "js-cookie"; +import { useRouter } from "next/navigation"; import "./Receipt.css"; @@ -11,13 +11,12 @@ interface ReceiptsProps { } function Receipt({ numAcount }: ReceiptsProps) { + const router = useRouter(); + const [folio, setFolio] = useState(""); const [amount, setAmount] = useState(""); const [date, setDate] = useState(""); - const [error, setError] = useState(""); - const [alert, setAlert] = useState(""); - //restrict this month// const day = new Date(); const year = day.getFullYear(); @@ -28,33 +27,50 @@ function Receipt({ numAcount }: ReceiptsProps) { const maxFecha = new Date(year, month, today).toISOString().split("T")[0]; //restrict this month// - const handleSaveReceipt = () => { + const handleSaveReceipt = async () => { if (!numAcount) { - setError("Error busca denuevo al estudiante"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=Error busca denuevo al estudiante` + ); return; } if (!folio) { - setError("Ingresa el folio del tiket"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=Ingresa el folio del tiket` + ); return; } if (!amount) { - setError("coloca el monto a depositar"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=coloca el monto a depositar` + ); return; } if (!date) { - setError("coloca la fecha"); + router.push(`/Impresiones?numAcount=${numAcount}&error=coloca la fecha`); return; } - PostReceipt({ - id_cuenta: numAcount, - folio_recibo: folio, - monto: Number(amount), - fecha_recibo: date, - }); + try { + await PostReceipt({ + id_cuenta: numAcount, + folio_recibo: folio, + monto: Number(amount), + fecha_recibo: date, + }); + + setFolio(""); + setAmount(""); + setDate(""); + + router.push(`/Impresiones?numAcount=${numAcount}&success=1`); + } catch (err: any) { + console.error(err); + router.push(`/Impresiones?numAcount=${numAcount}&error=${err}`); + } }; return ( @@ -96,8 +112,9 @@ function Receipt({ numAcount }: ReceiptsProps) { if (value === "" || numericValue <= 1000) { setAmount(value); } else { - setAlert(""); - setError("El monto no puede superar $1000.00"); + router.push( + `/Impresiones?numAcount=${numAcount}&error=El monto no puede superar $1000.00` + ); } } }} @@ -120,9 +137,6 @@ function Receipt({ numAcount }: ReceiptsProps) {
- - {error && } - {alert && }
diff --git a/app/Components/SearchUser/searchUser.tsx b/app/Components/SearchUser/searchUser.tsx index 6af7039..a04d080 100644 --- a/app/Components/SearchUser/searchUser.tsx +++ b/app/Components/SearchUser/searchUser.tsx @@ -1,21 +1,28 @@ 'use client' import { useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect, useState } from "react"; interface urlProp{ urlBase:string + value:string|null } -function SearchUser(url:urlProp) { +function SearchUser(props:urlProp) { const [numAcount, setnumAcount] = useState(""); const router = useRouter(); + useEffect(() => { + if (props.value) { + setnumAcount(props.value); + } + }, [props.value]); + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (numAcount) { - router.push(`/${url.urlBase}?numAcount=${numAcount}`); + router.push(`/${props.urlBase}?numAcount=${numAcount}`); } }; diff --git a/app/Components/Wave/wave.module.css b/app/Components/Wave/wave.module.css index 70cc41f..3da39d6 100644 --- a/app/Components/Wave/wave.module.css +++ b/app/Components/Wave/wave.module.css @@ -51,5 +51,6 @@ } .wave { display: none; + animation: none; } } diff --git a/app/Components/Wave/wavesBack.tsx b/app/Components/Wave/wavesBack.tsx index c2e0d99..20ded08 100644 --- a/app/Components/Wave/wavesBack.tsx +++ b/app/Components/Wave/wavesBack.tsx @@ -10,3 +10,5 @@ export default function WavesBackground() { ); } +//Chat +//IO \ No newline at end of file diff --git a/app/globals.css b/app/globals.css index b4aec32..e6b8b5a 100644 --- a/app/globals.css +++ b/app/globals.css @@ -289,7 +289,7 @@ form { .toggleGroup { display: flex; - gap: 10px; + gap: 5px; background-color: #f3f4f6; border-radius: 6px; flex-wrap: wrap; @@ -304,7 +304,7 @@ form { border-radius: 4px; transition: background-color 0.3s, color 0.3s; font-weight: 500; - overflow-y: hidden; + overflow: hidden; max-height: 60px; } diff --git a/app/layout.tsx b/app/layout.tsx index 0981bf2..15d5c4d 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -4,6 +4,7 @@ import Header from "./Components/Header/Header"; import Footer from "./Components/Footer/Footer"; import WavesBackground from "./Components/Wave/wavesBack"; import "./globals.css"; +import FallingSquares from "./Components/FallingSquares/FallingSquares"; const poppins = Poppins({ variable: "--font-poppins", @@ -25,9 +26,10 @@ export default function RootLayout({ }>) { return ( - +
+ {children}
diff --git a/app/not-found.tsx b/app/not-found.tsx index b517f8d..03e157a 100644 --- a/app/not-found.tsx +++ b/app/not-found.tsx @@ -12,7 +12,7 @@ export default function NotFound() { return (
Página no encontrada diff --git a/middleware.ts b/middleware.ts index 3789498..0f47ec8 100644 --- a/middleware.ts +++ b/middleware.ts @@ -13,6 +13,23 @@ export function middleware(request: NextRequest) { } export const config = { - matcher: [] + matcher: [ + "/Reportes", + "/Monitor", + "/QuitarSancion", + "/Programas", + "/Mensajes", + "/Inscritos", + "/Inscripciones", + "/InformacionEquipo", + "/Impresiones", + "/CambiarPass", + "/BitacoraSanciones", + "/AsignacionMesas", + "/AsignacionEquipo", + "/Alta", + "/AgregarTiempo", + "/ActivosMantenimiento", + ], }; //IO