bug de no cargar visualización de archivos de referencia con filenames con caracteres no permitidos
This commit is contained in:
@@ -89,8 +89,8 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
|
|||||||
async function fetchDbFiles() {
|
async function fetchDbFiles() {
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("fine_tuning_referencias")
|
.from("documentos")
|
||||||
.select("fine_tuning_referencias_id, titulo_archivo, s3_file_path, fecha_subida, tags")
|
.select("documentos_id, titulo_archivo, s3_file_path, fecha_subida, tags")
|
||||||
.ilike("titulo_archivo", `%${debouncedSearchTerm}%`)
|
.ilike("titulo_archivo", `%${debouncedSearchTerm}%`)
|
||||||
.range((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage - 1);
|
.range((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage - 1);
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDbFiles((data || []).map((file: any) => ({
|
setDbFiles((data || []).map((file: any) => ({
|
||||||
id: file.fine_tuning_referencias_id,
|
id: file.documentos_id,
|
||||||
titulo: file.titulo_archivo,
|
titulo: file.titulo_archivo,
|
||||||
s3_file_path: file.s3_file_path,
|
s3_file_path: file.s3_file_path,
|
||||||
fecha_subida: file.fecha_subida,
|
fecha_subida: file.fecha_subida,
|
||||||
@@ -270,7 +270,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
|
|||||||
onDoubleClick={(e) => {
|
onDoubleClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setPreviewRow({
|
setPreviewRow({
|
||||||
fine_tuning_referencias_id: file.id,
|
documentos_id: file.id,
|
||||||
created_by: "unknown",
|
created_by: "unknown",
|
||||||
s3_file_path: file.s3_file_path,
|
s3_file_path: file.s3_file_path,
|
||||||
titulo_archivo: file.titulo,
|
titulo_archivo: file.titulo,
|
||||||
@@ -331,7 +331,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
|
|||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setPreviewRow({
|
setPreviewRow({
|
||||||
fine_tuning_referencias_id: file.id,
|
documentos_id: file.id,
|
||||||
created_by: "unknown",
|
created_by: "unknown",
|
||||||
s3_file_path: file.s3_file_path,
|
s3_file_path: file.s3_file_path,
|
||||||
titulo_archivo: file.titulo,
|
titulo_archivo: file.titulo,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const Route = createFileRoute("/_authenticated/archivos")({
|
|||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
loader: async () => {
|
loader: async () => {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("fine_tuning_referencias")
|
.from("documentos")
|
||||||
.select("*")
|
.select("*")
|
||||||
.order("fecha_subida", { ascending: false })
|
.order("fecha_subida", { ascending: false })
|
||||||
.limit(200)
|
.limit(200)
|
||||||
@@ -68,9 +68,9 @@ function RouteComponent() {
|
|||||||
async function remove(id: string) {
|
async function remove(id: string) {
|
||||||
if (!confirm("¿Eliminar archivo de referencia?")) return
|
if (!confirm("¿Eliminar archivo de referencia?")) return
|
||||||
const { error } = await supabase
|
const { error } = await supabase
|
||||||
.from("fine_tuning_referencias")
|
.from("documentos")
|
||||||
.delete()
|
.delete()
|
||||||
.eq("fine_tuning_referencias_id", id)
|
.eq("documentos_id", id)
|
||||||
if (error) return alert(error.message)
|
if (error) return alert(error.message)
|
||||||
router.invalidate()
|
router.invalidate()
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ function RouteComponent() {
|
|||||||
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||||
{filtered.map((r) => (
|
{filtered.map((r) => (
|
||||||
<article
|
<article
|
||||||
key={r.fine_tuning_referencias_id}
|
key={r.documentos_id}
|
||||||
className="rounded-2xl border bg-white/70 dark:bg-neutral-900/60 p-4 flex flex-col gap-3"
|
className="rounded-2xl border bg-white/70 dark:bg-neutral-900/60 p-4 flex flex-col gap-3"
|
||||||
>
|
>
|
||||||
<header className="min-w-0">
|
<header className="min-w-0">
|
||||||
@@ -166,7 +166,7 @@ function RouteComponent() {
|
|||||||
<Button variant="ghost" size="sm" onClick={() => setViewing(r)}>
|
<Button variant="ghost" size="sm" onClick={() => setViewing(r)}>
|
||||||
<Icons.Eye className="w-4 h-4 mr-1" /> Ver
|
<Icons.Eye className="w-4 h-4 mr-1" /> Ver
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="ghost" size="sm" onClick={() => remove(r.fine_tuning_referencias_id)}>
|
<Button variant="ghost" size="sm" onClick={() => remove(r.documentos_id)}>
|
||||||
<Icons.Trash2 className="w-4 h-4 mr-1" /> Eliminar
|
<Icons.Trash2 className="w-4 h-4 mr-1" /> Eliminar
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -237,21 +237,21 @@ function UploadDialog({
|
|||||||
try {
|
try {
|
||||||
const payload = await res.json()
|
const payload = await res.json()
|
||||||
createdId =
|
createdId =
|
||||||
payload?.fine_tuning_referencias_id ||
|
payload?.documentos_id ||
|
||||||
payload?.id ||
|
payload?.id ||
|
||||||
payload?.data?.fine_tuning_referencias_id ||
|
payload?.data?.documentos_id ||
|
||||||
null
|
null
|
||||||
} catch { /* noop */ }
|
} catch { /* noop */ }
|
||||||
|
|
||||||
if (createdId && (tags.trim() || fuente.trim() || typeof interno === "boolean")) {
|
if (createdId && (tags.trim() || fuente.trim() || typeof interno === "boolean")) {
|
||||||
await supabase
|
await supabase
|
||||||
.from("fine_tuning_referencias")
|
.from("documentos")
|
||||||
.update({
|
.update({
|
||||||
tags: tags.trim() ? tags.split(",").map((s) => s.trim()).filter(Boolean) : undefined,
|
tags: tags.trim() ? tags.split(",").map((s) => s.trim()).filter(Boolean) : undefined,
|
||||||
fuente_autoridad: fuente.trim() || undefined,
|
fuente_autoridad: fuente.trim() || undefined,
|
||||||
interno,
|
interno,
|
||||||
})
|
})
|
||||||
.eq("fine_tuning_referencias_id", createdId)
|
.eq("documentos_id", createdId)
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpenChange(false)
|
onOpenChange(false)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export type RefRow = {
|
export type RefRow = {
|
||||||
fine_tuning_referencias_id: string
|
documentos_id: string
|
||||||
titulo_archivo: string | null
|
titulo_archivo: string | null
|
||||||
descripcion: string | null
|
descripcion: string | null
|
||||||
s3_file_path: string | null // Added this property to match the API requirements.
|
s3_file_path: string | null // Added this property to match the API requirements.
|
||||||
|
|||||||
Reference in New Issue
Block a user