Cambio en diseños
This commit is contained in:
@@ -15,7 +15,7 @@ export default function Login() {
|
||||
|
||||
const handleLogin = async () => {
|
||||
try {
|
||||
const response = await axios.post('http://localhost:4000/login', {
|
||||
const response = await axios.post('https://venus.acatlan.unam.mx/servicios_pcpuma_test/login', {
|
||||
email: value,
|
||||
password: password,
|
||||
});
|
||||
|
||||
+13
-18
@@ -8,20 +8,17 @@ import axios from "axios";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { motion } from "framer-motion";
|
||||
|
||||
// Estilos CSS adicionales para el input group
|
||||
const inputGroupStyles = `
|
||||
|
||||
`;
|
||||
|
||||
export default function Page() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const router = useRouter();
|
||||
|
||||
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("http://https://venus.acatlan.unam.mx/servicios_pcpuma_test/login", {
|
||||
email: email,
|
||||
password: password,
|
||||
});
|
||||
@@ -37,19 +34,19 @@ export default function Page() {
|
||||
setPassword("");
|
||||
setError("");
|
||||
|
||||
// Opcional: mostrar mensaje de éxito
|
||||
alert("Login exitoso. Ahora puedes acceder a Carga y Visualización.");
|
||||
|
||||
|
||||
} catch (err: any) {
|
||||
const message =
|
||||
err.response?.data?.message || err.message || "Error al iniciar sesión";
|
||||
setError(message);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Inyectar estilos CSS */}
|
||||
|
||||
<motion.main
|
||||
className="auth-page flex-fill flex-grow-1 d-flex flex-column justify-content-center align-items-center"
|
||||
initial={{ y: 50, opacity: 0 }}
|
||||
@@ -57,7 +54,8 @@ export default function Page() {
|
||||
transition={{ delay: 0, duration: 0.5 }}
|
||||
>
|
||||
<h2 className="text-dorado">Bienvenido al sistema de</h2>
|
||||
<h1 className="text-azul">Servicios PC PUMA y CEDETEC</h1>
|
||||
<h1 className="text-dorado">Servicios PC PUMA y CEDETEC</h1>
|
||||
|
||||
<SimpleInput
|
||||
label="Usuario"
|
||||
className={{
|
||||
@@ -66,6 +64,7 @@ export default function Page() {
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
/>
|
||||
|
||||
<PasswordInput
|
||||
label="Contraseña"
|
||||
className={{
|
||||
@@ -80,13 +79,9 @@ export default function Page() {
|
||||
{error && <p className="text-danger text-center mb-3">{error}</p>}
|
||||
|
||||
<div className="d-flex gap-3">
|
||||
<Button onClick={handleLogin}>Iniciar Sesión</Button>
|
||||
{/* <Button
|
||||
onClick={() => router.replace("/visualizacion")}
|
||||
className="btn-success"
|
||||
>
|
||||
Iniciar Sin Contraseña
|
||||
</Button> */}
|
||||
<Button onClick={handleLogin} disabled={loading}>
|
||||
{loading ? "Iniciando sesión..." : "Iniciar Sesión"}
|
||||
</Button>
|
||||
</div>
|
||||
</motion.main>
|
||||
</>
|
||||
|
||||
+60
-34
@@ -5,6 +5,7 @@ import FuenteCard from "@/components/fuenteCard";
|
||||
import CargaArchivo from "@/components/cargaArchivo";
|
||||
import Button from "@/components/button";
|
||||
import { useAuthRedirect } from "@/hooks/auth";
|
||||
import { getUserFromToken } from "@/components/Hook";
|
||||
|
||||
interface Fuente {
|
||||
nombre: string;
|
||||
@@ -16,36 +17,39 @@ interface Fuente {
|
||||
export default function Dashboard() {
|
||||
const loading = useAuthRedirect();
|
||||
const [fuentes, setFuentes] = useState<Fuente[]>([]);
|
||||
const [descargando, setDescargando] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchMovimientos = async () => {
|
||||
const token = localStorage.getItem("token");
|
||||
if (!token) return;
|
||||
const fetchMovimientos = async () => {
|
||||
const token = localStorage.getItem("token");
|
||||
if (!token) return;
|
||||
|
||||
const res = await fetch("https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/movimientos", {
|
||||
const res = await fetch(
|
||||
"https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/movimientos",
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const data = await res.json();
|
||||
console.log("Respuesta del backend:", data);
|
||||
const data = await res.json();
|
||||
|
||||
const fuentesConvertidas: Fuente[] = data.move.map((mov: any) => ({
|
||||
nombre: `${mov.reporte}: ${mov.id_mov}`,
|
||||
id_mov: mov.id_mov,
|
||||
fecha: new Date(mov.fecha_mov).toLocaleString("es-MX", {
|
||||
weekday: "long",
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
}),
|
||||
activa: data.button,
|
||||
}));
|
||||
const fuentesConvertidas: Fuente[] = data.move.map((mov: any) => ({
|
||||
nombre: `${mov.reporte}: ${mov.id_mov}`,
|
||||
id_mov: mov.id_mov,
|
||||
fecha: new Date(mov.fecha_mov).toLocaleString("es-MX", {
|
||||
weekday: "long",
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
}),
|
||||
activa: data.button,
|
||||
}));
|
||||
|
||||
setFuentes(fuentesConvertidas);
|
||||
};
|
||||
setFuentes(fuentesConvertidas);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetchMovimientos();
|
||||
}, []);
|
||||
|
||||
@@ -56,13 +60,18 @@ export default function Dashboard() {
|
||||
return;
|
||||
}
|
||||
|
||||
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(
|
||||
"https://venus.acatlan.unam.mx/servicios_pcpuma_test/excel/download",
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.json();
|
||||
@@ -82,6 +91,8 @@ export default function Dashboard() {
|
||||
window.URL.revokeObjectURL(url);
|
||||
} catch (error: any) {
|
||||
alert(`Error al descargar: ${error.message}`);
|
||||
} finally {
|
||||
setDescargando(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -107,18 +118,33 @@ export default function Dashboard() {
|
||||
fecha={f.fecha}
|
||||
activa={f.activa}
|
||||
id_mov={f.id_mov}
|
||||
onValidated={fetchMovimientos} // ← actualiza fuentes al validar
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<h2 style={{ marginTop: "2rem" }} className="text-xl font-semibold mt-6 mb-4">Carga</h2>
|
||||
<div>
|
||||
<CargaArchivo />
|
||||
</div>
|
||||
{getUserFromToken()?.tipo === "LOAD" && (
|
||||
<>
|
||||
<h2
|
||||
style={{ marginTop: "2rem" }}
|
||||
className="text-xl font-semibold mt-4 mb-4"
|
||||
>
|
||||
Carga
|
||||
</h2>
|
||||
<div>
|
||||
<CargaArchivo />
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<h2 className="text-xl font-semibold mt-6 mb-4">Descarga de Datos</h2>
|
||||
<Button onClick={handleDownload} className="mb-3" variant="azul">
|
||||
Descarga Base de Datos
|
||||
<h2 className="text-xl font-semibold mt-5 mb-4">Descarga de Datos</h2>
|
||||
<Button
|
||||
onClick={handleDownload}
|
||||
disabled={descargando}
|
||||
className="mb-3"
|
||||
variant="azul"
|
||||
>
|
||||
{descargando ? "Descargando..." : "Descarga Base de Datos"}
|
||||
</Button>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -44,6 +44,7 @@ export default function Consulta() {
|
||||
<main>
|
||||
<div>
|
||||
<div>
|
||||
<strong className="text-dorado">Servicios PC PUMA y CEDETEC</strong>
|
||||
<h2 className="text-xl font-semibold mb-4">Servicios habilitados</h2>
|
||||
|
||||
<Input
|
||||
@@ -103,7 +104,7 @@ export default function Consulta() {
|
||||
borderBottom: "1px solid #ccc",
|
||||
}}
|
||||
>
|
||||
{key.toUpperCase()}
|
||||
{key.charAt(0).toUpperCase() + key.slice(1).toLowerCase()}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user