feat: implement DetailDialog component for PDF viewing and downloading; refactor API calls to use environment variables
This commit is contained in:
@@ -13,21 +13,9 @@ import {
|
||||
} from "@/components/ui/dialog"
|
||||
import { Textarea } from "@/components/ui/textarea"
|
||||
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from "@/components/ui/select"
|
||||
import { DetailDialog } from "@/components/archivos/DetailDialog"
|
||||
|
||||
type RefRow = {
|
||||
fine_tuning_referencias_id: string
|
||||
titulo_archivo: string | null
|
||||
descripcion: string | null
|
||||
contenido_archivo: any | null
|
||||
tipo_contenido: string | null
|
||||
fecha_subida: string | null
|
||||
procesado: boolean | null
|
||||
tags: string[] | null
|
||||
fuente_autoridad: string | null
|
||||
interno: boolean | null
|
||||
instrucciones: string
|
||||
created_by: string | null
|
||||
}
|
||||
import type { RefRow } from "@/types/RefRow"
|
||||
|
||||
export const Route = createFileRoute("/_authenticated/archivos")({
|
||||
component: RouteComponent,
|
||||
@@ -200,63 +188,6 @@ function RouteComponent() {
|
||||
)
|
||||
}
|
||||
|
||||
/* ========= Detalle ========= */
|
||||
function DetailDialog({ row, onClose }: { row: RefRow | null; onClose: () => void }) {
|
||||
return (
|
||||
<Dialog open={!!row} onOpenChange={(o) => !o && onClose()}>
|
||||
<DialogContent className="max-w-3xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="font-mono" >{row?.titulo_archivo ?? "(Sin título)"}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{row?.descripcion || "Sin descripción"}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
{row && (
|
||||
<div className="space-y-3">
|
||||
<div className="text-xs flex flex-wrap gap-2">
|
||||
<Badge variant="outline">{row.tipo_contenido ?? "—"}</Badge>
|
||||
<Badge variant="outline">{row.interno ? "Interno" : "Externo"}</Badge>
|
||||
<Badge variant="outline">{row.procesado ? "Procesado" : "Pendiente"}</Badge>
|
||||
{row.fuente_autoridad && <Badge variant="outline">{row.fuente_autoridad}</Badge>}
|
||||
{row.fecha_subida && (
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<Icons.CalendarClock className="w-3 h-3" />
|
||||
{new Date(row.fecha_subida).toLocaleString()}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{row.tags && row.tags.length > 0 && (
|
||||
<div className="text-xs text-neutral-600">
|
||||
<span className="font-medium">Tags: </span>{row.tags.join(", ")}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<Label className="text-xs text-neutral-600">Instrucciones</Label>
|
||||
<div className="mt-1 rounded-xl border bg-white/60 p-3 text-sm whitespace-pre-wrap">
|
||||
{row.instrucciones || "—"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label className="text-xs text-neutral-600">Contenido (JSON)</Label>
|
||||
<pre className="mt-1 rounded-xl border bg-neutral-950 text-neutral-100 p-3 max-h-[360px] overflow-auto text-xs">
|
||||
{JSON.stringify(row.contenido_archivo ?? {}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<DialogFooter>
|
||||
<Button onClick={onClose}>Cerrar</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
/* ========= Subida ========= */
|
||||
function UploadDialog({
|
||||
open, onOpenChange, onDone,
|
||||
@@ -284,7 +215,7 @@ function UploadDialog({
|
||||
try {
|
||||
const fileBase64 = await toBase64(file)
|
||||
// Enviamos al motor (inserta en la tabla si insert=true)
|
||||
const res = await fetch("https://genesis-engine.apps.lci.ulsa.mx/api/upload/documento", {
|
||||
const res = await fetch(`${import.meta.env.VITE_BACK_ORIGIN}/api/upload/documento`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user