@@ -898,11 +1098,10 @@ export default function Reports() {
-
+
{/* Tour Overlay */}
-
);
diff --git a/src/pages/TableroAlmacenamiento.jsx b/src/pages/TableroAlmacenamiento.jsx
index 42ae999..83c2f8b 100644
--- a/src/pages/TableroAlmacenamiento.jsx
+++ b/src/pages/TableroAlmacenamiento.jsx
@@ -1,6 +1,5 @@
import React, { useEffect, useState } from 'react';
import fetchWithAuth from '../fetchWithAuth';
-
const initialFilters = {
pedimento_app: '',
aduana: '',
@@ -12,11 +11,48 @@ const initialFilters = {
fecha_pago_lte: '',
contribuyente__rfc: '',
};
-
export default function TableroAlmacenamiento() {
const [filters, setFilters] = useState(initialFilters);
const [summary, setSummary] = useState(null);
const [isLoading, setIsLoading] = useState(false);
+ const [reports, setReports] = useState([]);
+
+ const handleGenerateReport = async () => {
+ try {
+ const params = Object.entries(filters)
+ .filter(([_, v]) => v)
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
+ .join('&');
+ const url = `${import.meta.env.VITE_EFC_API_URL}/reports/table-summary/${params ? `?${params}` : ''}`;
+ const res = await fetchWithAuth(url, { method: 'POST' });
+ if (!res.ok) throw new Error('Error al generar el reporte');
+ alert('Reporte solicitado correctamente. Aparecerá en el historial cuando esté listo.');
+ } catch (err) {
+ alert('No se pudo generar el reporte.');
+ }
+ };
+
+ const handleDownloadReport = async (reportId) => {
+ try {
+ const url = `${import.meta.env.VITE_EFC_API_URL}/reports/report-document-download/${reportId}/`;
+ const res = await fetchWithAuth(url);
+ if (!res.ok) throw new Error('Error al descargar el reporte');
+ const blob = await res.blob();
+ let filename = `reporte_${reportId}.csv`;
+ const disposition = res.headers.get('Content-Disposition');
+ if (disposition && disposition.includes('filename=')) {
+ filename = disposition.split('filename=')[1].replace(/"/g, '').trim();
+ }
+ const link = document.createElement('a');
+ link.href = window.URL.createObjectURL(blob);
+ link.download = filename;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ } catch (err) {
+ alert('No se pudo descargar el reporte.');
+ }
+ };
// Fetch summary data
const fetchSummary = async () => {
@@ -36,27 +72,31 @@ export default function TableroAlmacenamiento() {
setIsLoading(false);
};
- // Fetch initial data
+ // Fetch report list from API
+ useEffect(() => {
+ const fetchReports = async () => {
+ try {
+ const url = `${import.meta.env.VITE_EFC_API_URL}/reports/report-document-list/`;
+ const res = await fetchWithAuth(url);
+ if (!res.ok) throw new Error('Error al obtener el historial de reportes');
+ const data = await res.json();
+ setReports(data);
+ } catch (err) {
+ setReports([]);
+ }
+ };
+ fetchReports();
+ }, []);
+
useEffect(() => {
fetchSummary();
}, []);
- // Handle filter changes
const handleFilterChange = (e) => {
setFilters({ ...filters, [e.target.name]: e.target.value });
};
- // Card components for different sizes
- const Card = ({ title, children, icon, small }) => (
-
-
- {icon && {icon}}
- {title}
-
-
{children}
-
- );
-
+
return (
{/* Header */}
@@ -97,12 +137,21 @@ export default function TableroAlmacenamiento() {
))}
-
- Aplicar Filtros
-
+
+
+ Aplicar Filtros
+
+ alert('Generar reporte (implementación pendiente)')}
+ >
+ Generar Reporte
+
+
@@ -115,203 +164,60 @@ export default function TableroAlmacenamiento() {