diff --git a/app/(private)/ActivosMantenimiento/page.tsx b/app/(private)/ActivosMantenimiento/page.tsx index 8517154..cd39ba2 100644 --- a/app/(private)/ActivosMantenimiento/page.tsx +++ b/app/(private)/ActivosMantenimiento/page.tsx @@ -19,7 +19,7 @@ export default function Page() { label: "Equipos", content: ( <> - +
diff --git a/app/(private)/AgregarTiempo/page.tsx b/app/(private)/AgregarTiempo/page.tsx index b59a799..c7a081d 100644 --- a/app/(private)/AgregarTiempo/page.tsx +++ b/app/(private)/AgregarTiempo/page.tsx @@ -1,26 +1,39 @@ +import SearchUser from "@/app/Components/SearchUser/searchUser"; +import Information from "@/app/Components/Information/information"; +import Receipt from "@/app/Components/Receipt/Receipt"; +import { GetStudent } from "@/app/lib/getStudent"; -import SearchUser from '@/app/Components/SearchUser/searchUser'; -import './addTime.css' -import Information from '@/app/Components/Information/information'; -import Receipt from '@/app/Components/Receipt/Receipt'; +import "./addTime.css"; + +export default async function Page({ searchParams }: any) { + + const numAccount = searchParams?.numAccount + ? Number(searchParams.numAccount) + : null; + + let student: any = null; + if (numAccount) { + student = await GetStudent(numAccount); + } -export default function Page() { return ( -
-

AGREGAR TIEMPO

+
+

AGREGAR TIEMPO

- + - + {student ? ( + <> + -
- -
+
+ +
+ + ) : ( + <> + )}
- ); } -//IO \ No newline at end of file +//IO diff --git a/app/(private)/AsignacionEquipo/page.tsx b/app/(private)/AsignacionEquipo/page.tsx index e0280d3..8fa7b35 100644 --- a/app/(private)/AsignacionEquipo/page.tsx +++ b/app/(private)/AsignacionEquipo/page.tsx @@ -20,7 +20,7 @@ export default function Page() { label: "Asignar tiempo", content: ( <> - + @@ -39,7 +39,7 @@ export default function Page() { Cuenta - + ), }, diff --git a/app/(private)/AsignacionMesas/page.tsx b/app/(private)/AsignacionMesas/page.tsx index e6120f3..9ce759f 100644 --- a/app/(private)/AsignacionMesas/page.tsx +++ b/app/(private)/AsignacionMesas/page.tsx @@ -20,7 +20,7 @@ export default function Page() { label: "Asignar mesa", content: ( <> - +
@@ -58,7 +58,7 @@ export default function Page() { Cuenta - + ), }, diff --git a/app/(private)/BitacoraSanciones/page.tsx b/app/(private)/BitacoraSanciones/page.tsx index 9738f06..d82577f 100644 --- a/app/(private)/BitacoraSanciones/page.tsx +++ b/app/(private)/BitacoraSanciones/page.tsx @@ -166,7 +166,7 @@ export default function Page() { label: "Sanciones", content: ( <> - +
diff --git a/app/(private)/Impresiones/page.tsx b/app/(private)/Impresiones/page.tsx index 1159862..ba1edda 100644 --- a/app/(private)/Impresiones/page.tsx +++ b/app/(private)/Impresiones/page.tsx @@ -6,24 +6,30 @@ import Information from "../../Components/Information/information"; import "@/app/globals.css"; import { GetStudent } from "@/app/lib/getStudent"; +import AlertBox from "@/app/Components/AlertBox/AlertBox"; -export default async function Page({ - searchParams, -}: { - searchParams: { numAccount?: number }; -}) { +export default async function Page({ searchParams }: any) { const params = await searchParams; const numAccount = params.numAccount ? Number(params.numAccount) : null; let student: any = null; + let error: string | null = null; if (numAccount) { - student = await GetStudent(numAccount); + const result = await GetStudent(numAccount); + + if (result.error) { + error = result.error; + } else { + student = result; + } } return (
+ {error && } +

IMPRESIONES Y PLOTEO

- + {student ? ( <> diff --git a/app/(private)/Inscripciones/page.tsx b/app/(private)/Inscripciones/page.tsx index 4a1d2de..657ce35 100644 --- a/app/(private)/Inscripciones/page.tsx +++ b/app/(private)/Inscripciones/page.tsx @@ -12,7 +12,7 @@ export default function Page() {

INSCRIPCION

- +

Quitar Sanciones

- +
diff --git a/app/Components/AlertBox/AlertBox.css b/app/Components/AlertBox/AlertBox.css new file mode 100644 index 0000000..84d2886 --- /dev/null +++ b/app/Components/AlertBox/AlertBox.css @@ -0,0 +1,32 @@ +.messageBox { + position: absolute; + padding: 0.5rem 1.25rem; + border-radius: 4px; + font-weight: bold; + font-size: 1.5rem; + text-align: center; + opacity: 1; + z-index: 100; + top: 0; + left: 0; + width: 100%; + max-width: 200px; +} + +.messageBox.hidden { + opacity: 0; + pointer-events: none; + transition: opacity 1s ease-out; +} + +.success { + background-color: #d1f7c4; + color: #000000; + border: 1px solid #a5d6a7; +} + +.error { + background-color: #ffcdd2; + color: #000000; + border: 1px solid #ef9a9a; +} \ No newline at end of file diff --git a/app/Components/AlertBox/AlertBox.tsx b/app/Components/AlertBox/AlertBox.tsx new file mode 100644 index 0000000..1711910 --- /dev/null +++ b/app/Components/AlertBox/AlertBox.tsx @@ -0,0 +1,37 @@ +'use client' + +import { useEffect, useState } from "react"; +import "./AlertBox.css"; + +interface AlertBoxProps { + message: string; + type: "error" | "success"; + duration?: number; +} + +export default function AlertBox({ message, type, duration = 6000 }: AlertBoxProps) { + const [visible, setVisible] = useState(false); + const [text, setText] = useState(""); + + useEffect(() => { + if (message) { + setText(message); + setVisible(true); + + const timeout = setTimeout(() => { + setVisible(false); + setTimeout(() => setText(""), 500); + }, duration); + + return () => clearTimeout(timeout); + } + }, [message, duration]); + + if (!text) return null; + + return ( +
+ {text} +
+ ); +} diff --git a/app/Components/Impressions/impressions.tsx b/app/Components/Impressions/impressions.tsx index f0906f6..f680eaa 100644 --- a/app/Components/Impressions/impressions.tsx +++ b/app/Components/Impressions/impressions.tsx @@ -6,6 +6,7 @@ import { useRouter } from "next/navigation"; import Cookies from "js-cookie"; import { envConfig } from "@/app/lib/config"; import "./Impressions.css"; +import AlertBox from "../AlertBox/AlertBox"; interface CostOption { value: number; @@ -20,10 +21,6 @@ function Impressions({ costs, numAccount }: ImpressionsProps) { const [cost, setCost] = useState(""); const [error, setError] = useState(""); - const [alert, setAlert] = useState(""); - const [showError, setShowError] = useState(false); - const [showAlert, setShowAlert] = useState(false); - const router = useRouter(); const handleLogout = () => { @@ -33,7 +30,6 @@ function Impressions({ costs, numAccount }: ImpressionsProps) { }; const handlePayment = async () => { - setAlert(""); setError(""); if (!numAccount) { @@ -46,9 +42,9 @@ function Impressions({ costs, numAccount }: ImpressionsProps) { return; } - if(!cost){ - setError("Selecciona un costo") - return; + if (!cost) { + setError("Selecciona un costo"); + return; } const token = Cookies.get("token"); @@ -72,7 +68,6 @@ function Impressions({ costs, numAccount }: ImpressionsProps) { } ); - setAlert("Cobro realizado correctamente"); setPages(""); } catch (error: any) { const errorMessage = @@ -132,16 +127,7 @@ function Impressions({ costs, numAccount }: ImpressionsProps) { Cobrar - {error && ( -
- {error} -
- )} - {alert && ( -
- {alert} -
- )} + {error && } diff --git a/app/Components/SearchUser/searchUser.tsx b/app/Components/SearchUser/searchUser.tsx index 05da3d5..74f01d4 100644 --- a/app/Components/SearchUser/searchUser.tsx +++ b/app/Components/SearchUser/searchUser.tsx @@ -2,14 +2,20 @@ import { useRouter } from "next/navigation"; import { useState } from "react"; -function SearchUser() { + +interface urlProp{ + urlBase:string +} + +function SearchUser(url:urlProp) { const [numAccount, setNumAccount] = useState(""); const router = useRouter(); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); + if (numAccount) { - router.push(`/Impresiones?numAccount=${numAccount}`); + router.push(`/${url.urlBase}?numAccount=${numAccount}`); } }; diff --git a/app/globals.css b/app/globals.css index dd7dbb8..dd2bcad 100644 --- a/app/globals.css +++ b/app/globals.css @@ -363,38 +363,6 @@ table tr { align-items: center; } -.messageBox { - position: absolute; - padding: 0.5rem 1.25rem; - border-radius: 4px; - font-weight: bold; - font-size: 1.5rem; - text-align: center; - opacity: 1; - z-index: 100; - top: 0; - left: 0; - width: 100%; -} - -.messageBox.hidden { - opacity: 0; - pointer-events: none; - transition: opacity 1s ease-out; -} - -.success { - background-color: #d1f7c4; - color: #000000; - border: 1px solid #a5d6a7; -} - -.error { - background-color: #ffcdd2; - color: #000000; - border: 1px solid #ef9a9a; -} - @media (max-width: 1300px) { .container { width: 100%; diff --git a/app/lib/getStudent.ts b/app/lib/getStudent.ts index 172bcff..756ea2c 100644 --- a/app/lib/getStudent.ts +++ b/app/lib/getStudent.ts @@ -4,6 +4,7 @@ import { envConfig } from "./config"; export async function GetStudent(numAccount: number) { try { const response = await axios.get(`${envConfig.apiUrl}/student/${numAccount}`); + console.log(response.data) return response.data; } catch (error: any) { const msg =