From e12d0ad8b120505f0c9ae36175b1003dbe04f347 Mon Sep 17 00:00:00 2001 From: Guillermo Arrieta Medina Date: Fri, 3 Oct 2025 12:18:25 -0600 Subject: [PATCH] =?UTF-8?q?Parte=20de=20la=20actualizaci=C3=B3n=20de=20obt?= =?UTF-8?q?enci=C3=B3n=20de=20documentos=20a=20partir=20del=20documentos?= =?UTF-8?q?=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ahora se usa documentos_id para obtener los documentos de referencia de minio, por lo que se cambiaron los nombres de las variables utilizadas --- src/components/archivos/DetailDialog.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/archivos/DetailDialog.tsx b/src/components/archivos/DetailDialog.tsx index c0adbad..9081e46 100644 --- a/src/components/archivos/DetailDialog.tsx +++ b/src/components/archivos/DetailDialog.tsx @@ -7,7 +7,7 @@ import * as Icons from "lucide-react" import type { RefRow } from "@/types/RefRow" // POST -> recibe blob PDF y (opcional) Content-Disposition -async function fetchPdfBlob(url: string, body: { s3_file_path: string }) { +async function fetchPdfBlob(url: string, body: { documentos_id: string }) { const res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, @@ -35,6 +35,7 @@ export function DetailDialog({ onClose: () => void pdfUrl?: string }) { + console.log("DetailDialog render", { row }) const [viewerUrl, setViewerUrl] = useState(null) const [currentBlob, setCurrentBlob] = useState(null) const [filename, setFilename] = useState("archivo.pdf") @@ -48,13 +49,15 @@ export function DetailDialog({ const ctrl = new AbortController() async function load() { - if (!row?.s3_file_path) { + console.log(row) + if (!row?.documentos_id) { setViewerUrl(null) setCurrentBlob(null) + console.warn("No hay documentos_id en el row") return } try { - const { blob, disposition } = await fetchPdfBlob(`${import.meta.env.VITE_BACK_ORIGIN}/api/get/documento`, { s3_file_path: row.s3_file_path }) + const { blob, disposition } = await fetchPdfBlob(`${import.meta.env.VITE_BACK_ORIGIN}/api/get/documento`, { documentos_id: row.documentos_id }) if (ctrl.signal.aborted) return const name = row.titulo_archivo ? `${row.titulo_archivo}.pdf` : filenameFromDisposition(disposition) setFilename(name) @@ -94,8 +97,8 @@ export function DetailDialog({ } // Si no, vuelve a pedirlo (p. ej., si el user abre y descarga sin render previo) - if (!row?.s3_file_path) throw new Error("No hay contenido para descargar.") - const { blob, disposition } = await fetchPdfBlob(`${import.meta.env.VITE_BACK_ORIGIN}/api/get/documento`, { s3_file_path: row.s3_file_path }) + if (!row?.documentos_id) throw new Error("No hay contenido para descargar.") + const { blob, disposition } = await fetchPdfBlob(`${import.meta.env.VITE_BACK_ORIGIN}/api/get/documento`, { documentos_id: row.documentos_id }) const name = row.titulo_archivo ? `${row.titulo_archivo}.pdf` : filenameFromDisposition(disposition) const link = document.createElement("a") const href = URL.createObjectURL(blob)