From de19f41436b3dc9fce0205bd013aef88074966b9 Mon Sep 17 00:00:00 2001 From: evenegas Date: Thu, 3 Jul 2025 11:16:43 -0600 Subject: [PATCH] =?UTF-8?q?se=20hicieron=20cambios=20en=20como=20se=20mues?= =?UTF-8?q?tra=20la=20informaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(auth)/page.tsx | 4 +++- src/app/alta/alta.tsx | 5 ++++- src/app/carga/page.tsx | 33 +++++++++++++++++++++----------- src/app/landing/globals.css | 17 +++++++++++++++- src/app/landing/landing_body.tsx | 2 +- src/app/visualizacion/page.tsx | 26 ++++++++++++++++++------- src/components/cargaArchivo.tsx | 4 +++- src/components/fuenteCard.tsx | 3 ++- src/containers/LoginPage.tsx | 5 ++++- 9 files changed, 74 insertions(+), 25 deletions(-) diff --git a/src/app/(auth)/page.tsx b/src/app/(auth)/page.tsx index 949eacc..72d54ee 100644 --- a/src/app/(auth)/page.tsx +++ b/src/app/(auth)/page.tsx @@ -7,6 +7,8 @@ import React, { useState } from "react"; import axios from "axios"; import { useRouter } from "next/navigation"; import { motion } from "framer-motion"; +const apiUrl = process.env.NEXT_PUBLIC_API_URL; + export default function Page() { const [email, setEmail] = useState(""); @@ -18,7 +20,7 @@ export default function Page() { const handleLogin = async () => { setLoading(true); try { - const response = await axios.post("http://https://venus.acatlan.unam.mx/servicios_pcpuma_test/login", { + const response = await axios.post(`${apiUrl}/login`, { email: email, password: password, }); diff --git a/src/app/alta/alta.tsx b/src/app/alta/alta.tsx index 3ac2172..504fad4 100644 --- a/src/app/alta/alta.tsx +++ b/src/app/alta/alta.tsx @@ -2,6 +2,9 @@ import React, { useState } from "react"; +const apiUrl = process.env.NEXT_PUBLIC_API_URL; + + const tiposUsuarioEstudiante = [ "Diplomado", "Extra Largo", "Servicio Social", "Idiomas R (UNAM)", "Idiomas Sabatino", "Reinscrito", "Posgrado", "Intercambio UNAM", @@ -88,7 +91,7 @@ const FormularioCargaIndividual = () => { } } - const response = await fetch("https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/carga", { + const response = await fetch(`${apiUrl}/excel/carga`, { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/app/carga/page.tsx b/src/app/carga/page.tsx index 51f0f16..a73a8a9 100644 --- a/src/app/carga/page.tsx +++ b/src/app/carga/page.tsx @@ -7,6 +7,9 @@ import Button from "@/components/button"; import { useAuthRedirect } from "@/hooks/auth"; import { getUserFromToken } from "@/components/Hook"; +const apiUrl = process.env.NEXT_PUBLIC_API_URL; + + interface Fuente { nombre: string; fecha: string; @@ -24,7 +27,7 @@ export default function Dashboard() { if (!token) return; const res = await fetch( - "https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/movimientos", + `${apiUrl}/excel/movimientos`, { headers: { Authorization: `Bearer ${token}`, @@ -63,15 +66,12 @@ export default function Dashboard() { setDescargando(true); try { - const response = await fetch( - "https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/download", - { - method: "GET", - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); + const response = await fetch(`${apiUrl}/excel/download`, { + method: "GET", + headers: { + Authorization: `Bearer ${token}`, + }, + }); if (!response.ok) { const errorBody = await response.json(); @@ -79,12 +79,23 @@ export default function Dashboard() { return; } + // Obtén el nombre del archivo desde el header + const disposition = response.headers.get("Content-Disposition"); + let filename = "usuarios.csv"; // Valor por defecto + console.log(disposition); + if (disposition && disposition.includes("filename=")) { + const match = disposition.match(/filename="?(.+?)"?$/); + if (match && match[1]) { + filename = match[1]; + } + } + const blob = await response.blob(); const url = window.URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; - a.download = "usuarios.csv"; + a.download = filename; document.body.appendChild(a); a.click(); a.remove(); diff --git a/src/app/landing/globals.css b/src/app/landing/globals.css index ff45995..bb2f239 100644 --- a/src/app/landing/globals.css +++ b/src/app/landing/globals.css @@ -14,6 +14,9 @@ body { text-align: center; } + + + /* Header */ header { display: flex; @@ -106,6 +109,18 @@ body>p:last-of-type { letter-spacing: 1px; } +.ocultar-scroll { + scrollbar-width: none; + /* Firefox */ + -ms-overflow-style: none; + /* IE 10+ */ +} + +.ocultar-scroll::-webkit-scrollbar { + display: none; + /* Chrome, Safari */ +} + .circle-background { margin-top: 0; padding-top: 0; @@ -123,7 +138,7 @@ body>p:last-of-type { justify-content: center; align-items: center; height: 100%; - overflow-y: auto; + overflow: hidden; } .circle { diff --git a/src/app/landing/landing_body.tsx b/src/app/landing/landing_body.tsx index 7bd61a1..37ce8ef 100644 --- a/src/app/landing/landing_body.tsx +++ b/src/app/landing/landing_body.tsx @@ -11,7 +11,7 @@ export default function LandingBody() { const router = useRouter(); return ( ([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); + const [usuario, setUsuario] = useState(""); const handleSubmit = async () => { if (!value) { @@ -20,21 +23,23 @@ export default function Consulta() { setLoading(true); setError(""); setResultados([]); + setUsuario(""); try { - const res = await fetch(`https://venus.acatlan.unam.mx/servicios_pcpuma_test/usuarios/${value}`); + const res = await fetch(`${apiUrl}/usuarios/${value}`); if (!res.ok) { const errData = await res.json(); - throw new Error(errData.message || "Error al consultar usuario"); + throw new Error("No se encontró usuario"); } const data = await res.json(); - setResultados(data); + setUsuario(data.usuario); + setResultados(data.resultado || []); } catch (err: any) { - const message = err.message || "Error desconocido"; + const message = "No se encontró usuario"; setError(message); - console.error("Error al obtener datos:", err); + console.error(message); } finally { setLoading(false); } @@ -65,7 +70,7 @@ export default function Consulta() { padding: "0.5rem 1rem", border: "none", borderRadius: "4px", - cursor: "pointer" + cursor: "pointer", }} > {loading ? "Buscando..." : "Buscar"} @@ -73,6 +78,13 @@ export default function Consulta() { + {usuario && ( + +

Bienvenido {usuario}, estos son tus servicios activos

+ + + )} + {error && (

{error} @@ -118,7 +130,7 @@ export default function Consulta() { style={{ padding: "0.75rem", borderBottom: "1px solid #eee", - textAlign: "left" + textAlign: "left", }} > {String(val)} diff --git a/src/components/cargaArchivo.tsx b/src/components/cargaArchivo.tsx index d960293..72ef0d7 100644 --- a/src/components/cargaArchivo.tsx +++ b/src/components/cargaArchivo.tsx @@ -1,6 +1,8 @@ "use client"; import React, { useState } from "react"; import Button from "./button"; +const apiUrl = process.env.NEXT_PUBLIC_API_URL; + const CargaArchivo: React.FC = () => { const [archivo, setArchivo] = useState(null); @@ -37,7 +39,7 @@ const CargaArchivo: React.FC = () => { setLoading(true); // ← empieza a subir try { - const res = await fetch("https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/load", { + const res = await fetch(`${apiUrl}/excel/load`, { method: "POST", headers: { Authorization: `Bearer ${token}`, diff --git a/src/components/fuenteCard.tsx b/src/components/fuenteCard.tsx index 955cbf9..6230519 100644 --- a/src/components/fuenteCard.tsx +++ b/src/components/fuenteCard.tsx @@ -1,6 +1,7 @@ "use client"; import React, { useState } from "react"; import Button from "./button"; +const apiUrl = process.env.NEXT_PUBLIC_API_URL; type FuenteCardProps = { nombre: string; @@ -29,7 +30,7 @@ const FuenteCard: React.FC = ({ try { setLoading(true); // ← activa estado de carga const res = await fetch( - `https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/activar-servicios/${id_mov}`, + `${apiUrl}/excel/activar-servicios/${id_mov}`, { method: "POST", headers: { diff --git a/src/containers/LoginPage.tsx b/src/containers/LoginPage.tsx index c8dba81..5d57254 100644 --- a/src/containers/LoginPage.tsx +++ b/src/containers/LoginPage.tsx @@ -8,6 +8,9 @@ import axios from "axios"; import { useRouter } from "next/navigation"; import { motion } from "framer-motion"; +const apiUrl = process.env.NEXT_PUBLIC_API_URL; + + export default function Page() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); @@ -18,7 +21,7 @@ export default function Page() { const handleLogin = async () => { setLoading(true); try { - const response = await axios.post("https://venus.acatlan.unam.mx/servicios_pcpuma_test/login", { + const response = await axios.post(`${apiUrl}/login`, { email: email, password: password, });