se hicieron cambios en como se muestra la información
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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",
|
||||
|
||||
+22
-11
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -11,7 +11,7 @@ export default function LandingBody() {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<motion.main
|
||||
className="overflow"
|
||||
className=""
|
||||
initial={{ y: 50, opacity: 0 }}
|
||||
animate={{ y: 0, opacity: 1 }}
|
||||
transition={{ delay: 1, duration: 1 }}
|
||||
|
||||
@@ -4,12 +4,15 @@ import React, { useState } from "react";
|
||||
import Input from "@/components/input";
|
||||
import Button from "@/components/button";
|
||||
|
||||
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
|
||||
|
||||
export default function Consulta() {
|
||||
const [tipo, setTipo] = useState("");
|
||||
const [value, setValue] = useState("");
|
||||
const [resultados, setResultados] = useState<any[]>([]);
|
||||
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() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{usuario && (
|
||||
|
||||
<h2 className="text-xl font-semibold mb-4 mt-5">Bienvenido <span className="text-blue-700">{usuario}</span>, estos son tus servicios activos</h2>
|
||||
|
||||
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<p style={{ color: "red", marginTop: "0.5rem", textAlign: "center" }}>
|
||||
{error}
|
||||
@@ -118,7 +130,7 @@ export default function Consulta() {
|
||||
style={{
|
||||
padding: "0.75rem",
|
||||
borderBottom: "1px solid #eee",
|
||||
textAlign: "left"
|
||||
textAlign: "left",
|
||||
}}
|
||||
>
|
||||
{String(val)}
|
||||
|
||||
@@ -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<File | null>(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}`,
|
||||
|
||||
@@ -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<FuenteCardProps> = ({
|
||||
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: {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user