localize UI to english

This commit is contained in:
Anibal Angulo
2025-11-09 11:14:42 -06:00
parent 1ce4162e4a
commit 19c4841afc
9 changed files with 249 additions and 221 deletions

View File

@@ -16,7 +16,7 @@ import {
PromptInputTools,
} from "@/components/ai-elements/prompt-input";
import { Action, Actions } from "@/components/ai-elements/actions";
import { Fragment, useState, useEffect } from "react";
import { Fragment, useState, useEffect, useMemo } from "react";
import { useChat } from "@ai-sdk/react";
import { Response } from "@/components/ai-elements/response";
import {
@@ -56,7 +56,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
},
}),
onError: (error) => {
setError(`Error en el chat: ${error.message}`);
setError(`Chat error: ${error.message}`);
},
});
@@ -84,20 +84,32 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
{
body: {
dataroom: selectedTema,
context: `Usuario está consultando sobre el dataroom: ${selectedTema}`,
context: `User is asking about the dataroom: ${selectedTema}`,
},
},
);
setInput("");
};
const hasActiveToolRequest = useMemo(() => {
return messages.some((message) =>
message.parts.some(
(part: any) =>
typeof part?.type === "string" &&
part.type.startsWith("tool-") &&
part.state === "input-available",
),
);
}, [messages]);
const shouldShowGlobalLoader =
(status === "streaming" || status === "loading") && !hasActiveToolRequest;
if (!selectedTema) {
return (
<div className="flex flex-col items-center justify-center h-64">
<MessageCircle className="w-12 h-12 text-gray-400 mb-4" />
<p className="text-gray-500">
Selecciona un dataroom para iniciar el chat
</p>
<p className="text-gray-500">Select a dataroom to start chatting</p>
</div>
);
}
@@ -115,9 +127,9 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
</div>
<div className="flex-1 bg-gray-50 rounded-lg p-4">
<p className="text-sm text-gray-800">
¡Hola! Soy tu asistente de IA para el dataroom{" "}
<strong>{selectedTema}</strong>. Puedes hacerme preguntas
sobre los documentos almacenados aquí.
Hi! Im your AI assistant for dataroom{" "}
<strong>{selectedTema}</strong>. Ask me anything about the
stored documents.
</p>
</div>
</div>
@@ -206,11 +218,11 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="flex items-center gap-2 p-4 bg-blue-50 rounded-lg border border-blue-200"
className="mb-4 flex items-center gap-2 p-4 bg-blue-50 rounded-lg border border-blue-200"
>
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
<span className="text-sm text-blue-700">
Generando reporte de auditoría...
Generating audit report
</span>
</div>
);
@@ -218,7 +230,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="mt-4 w-full"
className="mt-4 mb-4 w-full"
>
<div className="max-w-full overflow-hidden">
<AuditReport data={part.output} />
@@ -229,12 +241,12 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="p-4 bg-red-50 border border-red-200 rounded-lg"
className="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"
>
<div className="flex items-center gap-2">
<AlertCircle className="w-4 h-4 text-red-600" />
<span className="text-sm font-medium text-red-800">
Error generando reporte de auditoría
Failed to generate audit report
</span>
</div>
<p className="text-sm text-red-600 mt-1">
@@ -251,11 +263,11 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="flex items-center gap-2 p-4 bg-purple-50 rounded-lg border border-purple-200"
className="mb-4 flex items-center gap-2 p-4 bg-purple-50 rounded-lg border border-purple-200"
>
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-purple-600"></div>
<span className="text-sm text-purple-700">
Generando análisis histórico...
Generating performance analysis
</span>
</div>
);
@@ -263,7 +275,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="mt-4 w-full"
className="mt-4 mb-4 w-full"
>
<div className="max-w-full overflow-hidden">
<AnalystReport data={part.output} />
@@ -274,12 +286,12 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="p-4 bg-red-50 border border-red-200 rounded-lg"
className="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"
>
<div className="flex items-center gap-2">
<AlertCircle className="w-4 h-4 text-red-600" />
<span className="text-sm font-medium text-red-800">
Error generando análisis histórico
Failed to generate performance analysis
</span>
</div>
<p className="text-sm text-red-600 mt-1">
@@ -296,11 +308,11 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="flex items-center gap-2 p-4 bg-green-50 rounded-lg border border-green-200"
className="mb-4 flex items-center gap-2 p-4 bg-green-50 rounded-lg border border-green-200"
>
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-green-600"></div>
<span className="text-sm text-green-700">
Searching the web...
Searching the web
</span>
</div>
);
@@ -308,7 +320,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="mt-4 w-full"
className="mt-4 mb-4 w-full"
>
<div className="max-w-full overflow-hidden">
<WebSearchResults data={part.output} />
@@ -319,12 +331,12 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
return (
<div
key={`${message.id}-${i}`}
className="p-4 bg-red-50 border border-red-200 rounded-lg"
className="mb-4 p-4 bg-red-50 border border-red-200 rounded-lg"
>
<div className="flex items-center gap-2">
<AlertCircle className="w-4 h-4 text-red-600" />
<span className="text-sm font-medium text-red-800">
Error searching the web
Failed to search the web
</span>
</div>
<p className="text-sm text-red-600 mt-1">
@@ -341,8 +353,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
})}
</div>
))}
{status === "streaming" && <Loader />}
{status === "loading" && <Loader />}
{shouldShowGlobalLoader && <Loader />}
</div>
</div>
@@ -363,7 +374,7 @@ export function ChatTab({ selectedTema }: ChatTabProps) {
<PromptInputTextarea
onChange={(e) => setInput(e.target.value)}
value={input}
placeholder={`Pregunta algo sobre ${selectedTema}...`}
placeholder={`Ask something about ${selectedTema}...`}
disabled={status === "streaming" || status === "loading"}
className="min-h-[60px] resize-none border-0 focus:ring-0 transition-all duration-200 text-base px-4 py-3 bg-white rounded-xl"
/>

View File

@@ -59,9 +59,8 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
const info = await api.getDataroomInfo(selectedTema);
setDataroomInfo(info);
} catch (err) {
const errorMessage =
err instanceof Error ? err.message : "Error desconocido";
setError(`Error cargando información: ${errorMessage}`);
const errorMessage = err instanceof Error ? err.message : "Unknown error";
setError(`Unable to load dataroom info: ${errorMessage}`);
console.error("Error fetching dataroom info:", err);
} finally {
setLoading(false);
@@ -70,7 +69,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
const formatFileTypes = (fileTypes: Record<string, number>) => {
const entries = Object.entries(fileTypes);
if (entries.length === 0) return "Sin archivos";
if (entries.length === 0) return "No files";
return entries
.sort(([, a], [, b]) => b - a) // Sort by count descending
@@ -90,9 +89,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
return (
<div className="flex flex-col items-center justify-center h-64">
<Activity className="w-12 h-12 text-gray-400 mb-4" />
<p className="text-gray-500">
Selecciona un dataroom para ver las métricas
</p>
<p className="text-gray-500">Select a dataroom to view its metrics</p>
</div>
);
}
@@ -101,7 +98,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
return (
<div className="flex flex-col items-center justify-center h-64">
<Loader2 className="w-8 h-8 text-blue-600 animate-spin mb-4" />
<p className="text-gray-600">Cargando métricas...</p>
<p className="text-gray-600">Loading metrics</p>
</div>
);
}
@@ -124,24 +121,14 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
return (
<div className="flex flex-col items-center justify-center h-64">
<AlertCircle className="w-12 h-12 text-gray-400 mb-4" />
<p className="text-gray-500">
No se pudo cargar la información del dataroom
</p>
<p className="text-gray-500">Unable to load dataroom information</p>
</div>
);
}
return (
<div className="p-6">
<div className="mb-6">
<h3 className="text-lg font-semibold text-gray-900 mb-2">
Métricas del Dataroom: {selectedTema}
</h3>
<p className="text-sm text-gray-600">
Vista general del estado y actividad del dataroom
</p>
</div>
<h4 className="text-md font-semibold text-gray-900 mb-4">Metrics</h4>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
{/* Files Count Card */}
<div className="bg-white border border-gray-200 rounded-lg p-4">
@@ -150,7 +137,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
<FileText className="w-5 h-5 text-blue-600" />
</div>
<div>
<p className="text-sm font-medium text-gray-600">Archivos</p>
<p className="text-sm font-medium text-gray-600">Files</p>
<p className="text-2xl font-bold text-gray-900">
{dataroomInfo.file_count}
</p>
@@ -168,9 +155,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
<Database className="w-5 h-5 text-green-600" />
</div>
<div>
<p className="text-sm font-medium text-gray-600">
Almacenamiento
</p>
<p className="text-sm font-medium text-gray-600">Storage</p>
<p className="text-2xl font-bold text-gray-900">
{dataroomInfo.total_size_mb.toFixed(1)} MB
</p>
@@ -188,14 +173,14 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
<Activity className="w-5 h-5 text-purple-600" />
</div>
<div>
<p className="text-sm font-medium text-gray-600">Vectores</p>
<p className="text-sm font-medium text-gray-600">Vectors</p>
<p className="text-2xl font-bold text-gray-900">
{dataroomInfo.vector_count ?? 0}
</p>
<p className="text-xs text-gray-500 mt-1">
{dataroomInfo.collection_exists
? "Vectores indexados"
: "Sin vectores"}
? "Indexed vectors"
: "No vectors"}
</p>
</div>
</div>
@@ -208,10 +193,10 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
<TrendingUp className="w-5 h-5 text-orange-600" />
</div>
<div>
<p className="text-sm font-medium text-gray-600">Estado</p>
<p className="text-sm font-medium text-gray-600">Status</p>
<div className="flex items-center gap-2">
<p className="text-2xl font-bold text-gray-900">
{dataroomInfo.collection_exists ? "Activo" : "Inactivo"}
{dataroomInfo.collection_exists ? "Active" : "Inactive"}
</p>
{dataroomInfo.collection_exists ? (
<CheckCircle className="w-6 h-6 text-green-600" />
@@ -222,14 +207,13 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
{dataroomInfo.collection_info ? (
<p className="text-xs text-gray-500 mt-1">
{dataroomInfo.collection_info.indexed_vectors_count}/
{dataroomInfo.collection_info.vectors_count} vectores
indexados
{dataroomInfo.collection_info.vectors_count} indexed vectors
</p>
) : (
<p className="text-xs text-gray-500 mt-1">
{dataroomInfo.collection_exists
? "Colección sin datos"
: "Sin colección"}
? "Collection has no data"
: "No collection"}
</p>
)}
</div>
@@ -241,7 +225,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
{dataroomInfo.recent_files.length > 0 && (
<div className="mt-8">
<h4 className="text-md font-semibold text-gray-900 mb-4">
Archivos Recientes
Recent Files
</h4>
<div className="bg-white border border-gray-200 rounded-lg overflow-hidden">
<div className="divide-y divide-gray-200">
@@ -258,7 +242,7 @@ export function DashboardTab({ selectedTema }: DashboardTabProps) {
</p>
<p className="text-xs text-gray-500">
{new Date(file.last_modified).toLocaleDateString(
"es-ES",
"en-US",
{
year: "numeric",
month: "short",

View File

@@ -87,14 +87,12 @@ export function DataroomView({ onProcessingChange }: DataroomViewProps = {}) {
<div className="flex flex-wrap items-center justify-between gap-4">
<div>
<h2 className="text-2xl font-semibold text-gray-900 mb-2">
{selectedTema
? `Dataroom: ${selectedTema}`
: "Selecciona un dataroom"}
{selectedTema ? `Dataroom: ${selectedTema}` : "Select a dataroom"}
</h2>
<p className="text-sm text-gray-600">
{selectedTema
? "Gestiona archivos, consulta métricas y chatea con IA sobre el contenido"
: "Selecciona un dataroom de la barra lateral para comenzar"}
? "Manage files, review metrics, and chat with AI about the content."
: "Pick a dataroom from the sidebar to get started."}
</p>
</div>
</div>

View File

@@ -1,4 +1,4 @@
import { Button } from '@/components/ui/button'
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
@@ -6,17 +6,17 @@ import {
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
import { Trash2, AlertTriangle } from 'lucide-react'
} from "@/components/ui/dialog";
import { Trash2, AlertTriangle } from "lucide-react";
interface DeleteConfirmDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
onConfirm: () => void
title: string
description: string
fileList?: string[]
loading?: boolean
open: boolean;
onOpenChange: (open: boolean) => void;
onConfirm: () => void;
title: string;
description: string;
fileList?: string[];
loading?: boolean;
}
export function DeleteConfirmDialog({
@@ -26,7 +26,7 @@ export function DeleteConfirmDialog({
title,
description,
fileList,
loading = false
loading = false,
}: DeleteConfirmDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
@@ -41,7 +41,7 @@ export function DeleteConfirmDialog({
{fileList && fileList.length > 0 && (
<div className="max-h-40 overflow-y-auto bg-gray-50 rounded p-3">
<p className="text-sm font-medium mb-2">Archivos a eliminar:</p>
<p className="text-sm font-medium mb-2">Files to delete:</p>
<ul className="text-sm space-y-1">
{fileList.map((filename, index) => (
<li key={index} className="flex items-center gap-2">
@@ -59,17 +59,13 @@ export function DeleteConfirmDialog({
onClick={() => onOpenChange(false)}
disabled={loading}
>
Cancelar
Cancel
</Button>
<Button
variant="destructive"
onClick={onConfirm}
disabled={loading}
>
{loading ? 'Eliminando...' : 'Eliminar'}
<Button variant="destructive" onClick={onConfirm} disabled={loading}>
{loading ? "Deleting…" : "Delete"}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
)
);
}

View File

@@ -60,7 +60,7 @@ export function FilesTab({
const [deleting, setDeleting] = useState(false);
const [downloading, setDownloading] = useState(false);
// Estados para el modal de preview de PDF
// PDF preview modal state
const [previewModalOpen, setPreviewModalOpen] = useState(false);
const [previewFileUrl, setPreviewFileUrl] = useState<string | null>(null);
const [previewFileName, setPreviewFileName] = useState("");
@@ -69,12 +69,12 @@ export function FilesTab({
);
const [loadingPreview, setLoadingPreview] = useState(false);
// Estados para el modal de chunks
// Chunk viewer modal state
const [chunkViewerOpen, setChunkViewerOpen] = useState(false);
const [chunkFileName, setChunkFileName] = useState("");
const [chunkFileTema, setChunkFileTema] = useState("");
// Estados para chunking
// LandingAI chunking state
const [chunkingConfigOpen, setChunkingConfigOpen] = useState(false);
const [chunkingFileName, setChunkingFileName] = useState("");
const [chunkingFileTema, setChunkingFileTema] = useState("");
@@ -123,10 +123,10 @@ export function FilesTab({
setDeleting(true);
if (fileToDelete) {
// Eliminar archivo individual
// Delete single file
await api.deleteFile(fileToDelete, selectedTema || undefined);
} else {
// Eliminar archivos seleccionados
// Delete selected files
const filesToDelete = Array.from(selectedFiles);
await api.deleteFiles(filesToDelete, selectedTema || undefined);
clearSelection();
@@ -159,9 +159,7 @@ export function FilesTab({
try {
setDownloading(true);
const filesToDownload = Array.from(selectedFiles);
const zipName = selectedTema
? `${selectedTema}_archivos`
: "archivos_seleccionados";
const zipName = selectedTema ? `${selectedTema}_files` : "selected_files";
await api.downloadMultipleFiles(
filesToDownload,
selectedTema || undefined,
@@ -234,7 +232,7 @@ export function FilesTab({
}
};
// Filtrar archivos por término de búsqueda
// Filter files by search term
const filteredFiles = files.filter((file) =>
file.name.toLowerCase().includes(searchTerm.toLowerCase()),
);
@@ -250,7 +248,7 @@ export function FilesTab({
};
const formatDate = (dateString: string): string => {
return new Date(dateString).toLocaleDateString("es-ES", {
return new Date(dateString).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
@@ -262,15 +260,15 @@ export function FilesTab({
const getDeleteDialogProps = () => {
if (fileToDelete) {
return {
title: "Eliminar archivo",
message: `¿Estás seguro de que deseas eliminar el archivo "${fileToDelete}"?`,
title: "Delete file",
message: `Are you sure you want to delete "${fileToDelete}"?`,
fileList: [fileToDelete],
};
} else {
const filesToDelete = Array.from(selectedFiles);
return {
title: "Eliminar archivos seleccionados",
message: `¿Estás seguro de que deseas eliminar ${filesToDelete.length} archivo${filesToDelete.length > 1 ? "s" : ""}?`,
title: "Delete selected files",
message: `Are you sure you want to delete ${filesToDelete.length} file${filesToDelete.length > 1 ? "s" : ""}?`,
fileList: filesToDelete,
};
}
@@ -280,9 +278,7 @@ export function FilesTab({
return (
<div className="flex flex-col items-center justify-center h-64">
<FileText className="w-12 h-12 text-gray-400 mb-4" />
<p className="text-gray-500">
Selecciona un dataroom para ver sus archivos
</p>
<p className="text-gray-500">Select a dataroom to view its files</p>
</div>
);
}
@@ -294,7 +290,7 @@ export function FilesTab({
<div className="flex items-center gap-3">
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div>
<span className="text-sm text-blue-800">
Procesando archivos con LandingAI...
Processing files with LandingAI
</span>
</div>
</div>
@@ -305,7 +301,7 @@ export function FilesTab({
<div className="relative flex-1 max-w-md">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
<Input
placeholder="Buscar archivos..."
placeholder="Search files..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="pl-10"
@@ -324,7 +320,7 @@ export function FilesTab({
className="gap-2"
>
<Download className="w-4 h-4" />
Descargar ({selectedFiles.size})
Download ({selectedFiles.size})
</Button>
<Button
variant="outline"
@@ -334,7 +330,7 @@ export function FilesTab({
className="gap-2 text-red-600 hover:text-red-700"
>
<Trash2 className="w-4 h-4" />
Eliminar ({selectedFiles.size})
Delete ({selectedFiles.size})
</Button>
</>
)}
@@ -345,7 +341,7 @@ export function FilesTab({
className="gap-2"
>
<Upload className="w-4 h-4" />
Subir archivo
Upload files
</Button>
</div>
</div>
@@ -355,17 +351,17 @@ export function FilesTab({
<div className="p-6">
{loading ? (
<div className="flex items-center justify-center h-64">
<p className="text-gray-500">Cargando archivos...</p>
<p className="text-gray-500">Loading files</p>
</div>
) : filteredFiles.length === 0 ? (
<div className="flex flex-col items-center justify-center h-64">
<FileText className="w-12 h-12 text-gray-400 mb-4" />
<p className="text-gray-500">
{!selectedTema
? "Selecciona un dataroom para ver sus archivos"
? "Select a dataroom to view its files"
: searchTerm
? "No se encontraron archivos"
: "No hay archivos en este dataroom"}
? "No files match your search"
: "This dataroom has no files yet"}
</p>
</div>
) : (
@@ -387,10 +383,10 @@ export function FilesTab({
}}
/>
</TableHead>
<TableHead>Archivo</TableHead>
<TableHead>Tamaño</TableHead>
<TableHead>Modificado</TableHead>
<TableHead className="text-right">Acciones</TableHead>
<TableHead>File</TableHead>
<TableHead>Size</TableHead>
<TableHead>Modified</TableHead>
<TableHead className="text-right">Actions</TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -418,7 +414,7 @@ export function FilesTab({
onClick={() => handlePreviewFile(file.name)}
disabled={loadingPreview}
className="h-8 w-8 p-0"
title="Vista previa"
title="Preview"
>
<Eye className="w-4 h-4" />
</Button>
@@ -427,7 +423,7 @@ export function FilesTab({
size="sm"
onClick={() => handleViewChunks(file.name)}
className="h-8 w-8 p-0"
title="Ver chunks"
title="View chunks"
>
<MessageSquare className="w-4 h-4" />
</Button>
@@ -436,7 +432,7 @@ export function FilesTab({
size="sm"
onClick={() => handleStartChunking(file.name)}
className="h-8 w-8 p-0"
title="Procesar con LandingAI"
title="Process with LandingAI"
>
<Scissors className="w-4 h-4" />
</Button>
@@ -446,7 +442,7 @@ export function FilesTab({
onClick={() => handleDownloadFile(file.name)}
disabled={downloading}
className="h-8 w-8 p-0"
title="Descargar"
title="Download"
>
<Download className="w-4 h-4" />
</Button>
@@ -456,7 +452,7 @@ export function FilesTab({
onClick={() => handleDeleteFile(file.name)}
disabled={deleting}
className="h-8 w-8 p-0 text-red-600 hover:text-red-700 hover:bg-red-50"
title="Eliminar"
title="Delete"
>
<Trash2 className="w-4 h-4" />
</Button>
@@ -503,7 +499,7 @@ export function FilesTab({
tema={chunkFileTema}
/>
{/* Modal de configuración de chunking con LandingAI */}
{/* LandingAI chunking config modal */}
<ChunkingConfigModalLandingAI
isOpen={chunkingConfigOpen}
onClose={() => setChunkingConfigOpen(false)}

View File

@@ -1,25 +1,20 @@
import { useState, useEffect } from 'react'
import { useState, useEffect } from "react";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription
} from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import {
Download,
Loader2,
FileText,
ExternalLink
} from 'lucide-react'
DialogDescription,
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { Download, Loader2, FileText, ExternalLink } from "lucide-react";
interface PDFPreviewModalProps {
open: boolean
onOpenChange: (open: boolean) => void
fileUrl: string | null
fileName: string
onDownload?: () => void
open: boolean;
onOpenChange: (open: boolean) => void;
fileUrl: string | null;
fileName: string;
onDownload?: () => void;
}
export function PDFPreviewModal({
@@ -27,45 +22,40 @@ export function PDFPreviewModal({
onOpenChange,
fileUrl,
fileName,
onDownload
onDownload,
}: PDFPreviewModalProps) {
// Estado para manejar el loading del iframe
const [loading, setLoading] = useState(true)
// Track iframe loading state
const [loading, setLoading] = useState(true);
// Efecto para manejar el timeout del loading
// Hide loading if iframe never fires onLoad
useEffect(() => {
if (open && fileUrl) {
setLoading(true)
setLoading(true);
// Timeout para ocultar loading automáticamente después de 3 segundos
// Algunos iframes no disparan onLoad correctamente
const timeout = setTimeout(() => {
setLoading(false)
}, 3000)
setLoading(false);
}, 3000);
return () => clearTimeout(timeout)
return () => clearTimeout(timeout);
}
}, [open, fileUrl])
}, [open, fileUrl]);
// Manejar cuando el iframe termina de cargar
const handleIframeLoad = () => {
setLoading(false)
}
setLoading(false);
};
// Abrir PDF en nueva pestaña
const openInNewTab = () => {
if (fileUrl) {
window.open(fileUrl, '_blank')
}
window.open(fileUrl, "_blank");
}
};
// Reiniciar loading cuando cambia el archivo
const handleOpenChange = (open: boolean) => {
if (open) {
setLoading(true)
}
onOpenChange(open)
setLoading(true);
}
onOpenChange(open);
};
return (
<Dialog open={open} onOpenChange={handleOpenChange}>
@@ -75,81 +65,68 @@ export function PDFPreviewModal({
<FileText className="w-5 h-5" />
{fileName}
</DialogTitle>
<DialogDescription>
Vista previa del documento PDF
</DialogDescription>
<DialogDescription>PDF preview</DialogDescription>
</DialogHeader>
{/* Barra de controles */}
{/* Controls */}
<div className="flex items-center justify-between gap-4 px-6 py-3 border-b bg-gray-50">
<div className="flex items-center gap-2">
<Button
variant="outline"
size="sm"
onClick={openInNewTab}
title="Abrir en nueva pestaña"
title="Open in new tab"
>
<ExternalLink className="w-4 h-4 mr-2" />
Abrir en pestaña nueva
Open in new tab
</Button>
</div>
{/* Botón de descarga */}
{/* Download button */}
{onDownload && (
<Button
variant="outline"
size="sm"
onClick={onDownload}
title="Descargar archivo"
title="Download file"
>
<Download className="w-4 h-4 mr-2" />
Descargar
Download
</Button>
)}
</div>
{/* Área de visualización del PDF con iframe */}
<div className="flex-1 relative bg-gray-100">
{/* PDF iframe */}
<div className="flex-1 relative bg-gray-100 overflow-hidden min-h-0">
{!fileUrl ? (
<div className="flex items-center justify-center h-full text-center text-gray-500 p-8">
<div>
<FileText className="w-16 h-16 mx-auto mb-4 text-gray-400" />
<p>No se ha proporcionado un archivo para previsualizar</p>
<p>No file available for preview</p>
</div>
</div>
) : (
<>
{/* Indicador de carga */}
{/* Loading state */}
{loading && (
<div className="absolute inset-0 flex items-center justify-center bg-white z-10">
<div className="text-center">
<Loader2 className="w-12 h-12 animate-spin text-blue-500 mx-auto mb-4" />
<p className="text-gray-600">Cargando PDF...</p>
<p className="text-gray-600">Loading PDF</p>
</div>
</div>
)}
{/*
Iframe para mostrar el PDF
El navegador maneja toda la visualización, zoom, scroll, etc.
Esto muestra el PDF exactamente como se vería si lo abrieras directamente
*/}
<iframe
src={fileUrl}
className="w-full h-full border-0"
title={`Vista previa de ${fileName}`}
title={`Preview of ${fileName}`}
onLoad={handleIframeLoad}
style={{ minHeight: '600px' }}
/>
</>
)}
</div>
{/* Footer con información */}
<div className="px-6 py-3 border-t bg-gray-50 text-xs text-gray-500 text-center">
{fileName}
</div>
</DialogContent>
</Dialog>
)
);
}

View File

@@ -84,7 +84,7 @@ export function Sidebar({
const handleCreateDataroom = async () => {
const trimmed = newDataroomName.trim();
if (!trimmed) {
setCreateError("El nombre es obligatorio");
setCreateError("Name is required");
return;
}
@@ -108,7 +108,7 @@ export function Sidebar({
setCreateError(
error instanceof Error
? error.message
: "No se pudo crear el dataroom. Inténtalo nuevamente.",
: "Could not create the dataroom. Please try again.",
);
} finally {
setCreatingDataroom(false);
@@ -168,15 +168,15 @@ export function Sidebar({
tema: string,
e: React.MouseEvent<HTMLButtonElement>,
) => {
e.stopPropagation(); // Evitar que se seleccione el tema al hacer clic en el icono
e.stopPropagation(); // Prevent selecting the dataroom when clicking delete
const confirmed = window.confirm(
`¿Estás seguro de que deseas eliminar el dataroom "${tema}"?\n\n` +
`Esto eliminará:\n` +
`El dataroom de la base de datos\n` +
`Todos los archivos del tema en Azure Blob Storage\n` +
`La colección "${tema}" en Qdrant (si existe)\n\n` +
`Esta acción no se puede deshacer.`,
`Are you sure you want to delete the dataroom "${tema}"?\n\n` +
`This will remove:\n` +
`The dataroom from the database\n` +
`All files stored for this topic in Azure Blob Storage\n` +
`The "${tema}" collection in Qdrant (if it exists)\n\n` +
`This action cannot be undone.`,
);
if (!confirmed) return;
@@ -191,10 +191,10 @@ export function Sidebar({
console.error(`Error deleting dataroom "${tema}":`, error);
// If dataroom deletion fails, fall back to legacy deletion
// Eliminar todos los archivos del tema en Azure Blob Storage
// Delete all topic files in Azure Blob Storage
await api.deleteTema(tema);
// Intentar eliminar la colección en Qdrant (si existe)
// Attempt to delete the Qdrant collection (if it exists)
try {
const collectionExists = await api.checkCollectionExists(tema);
if (collectionExists.exists) {
@@ -202,7 +202,7 @@ export function Sidebar({
}
} catch (collectionError) {
console.warn(
`No se pudo eliminar la colección "${tema}" de Qdrant:`,
`Could not delete the "${tema}" collection from Qdrant:`,
collectionError,
);
}
@@ -216,9 +216,9 @@ export function Sidebar({
setSelectedTema(null);
}
} catch (error) {
console.error(`Error eliminando dataroom "${tema}":`, error);
console.error(`Error deleting dataroom "${tema}":`, error);
alert(
`Error al eliminar el dataroom: ${error instanceof Error ? error.message : "Error desconocido"}`,
`Unable to delete dataroom: ${error instanceof Error ? error.message : "Unknown error"}`,
);
} finally {
setDeletingTema(null);
@@ -251,9 +251,7 @@ export function Sidebar({
className="text-slate-400 hover:text-slate-100"
onClick={onToggleCollapse}
disabled={disabled}
aria-label={
collapsed ? "Expandir barra lateral" : "Contraer barra lateral"
}
aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"}
>
{collapsed ? (
<ChevronRight className="h-4 w-4" />
@@ -279,7 +277,7 @@ export function Sidebar({
</h2>
)}
{renderWithTooltip(
"Crear dataroom",
"Create",
<Button
variant="ghost"
size="sm"
@@ -293,15 +291,15 @@ export function Sidebar({
disabled={disabled || creatingDataroom}
>
<Plus className="h-4 w-4" />
{!collapsed && <span>Crear dataroom</span>}
{!collapsed && <span>Create</span>}
</Button>,
)}
</div>
{/* Lista de temas */}
{/* Dataroom list */}
{loading ? (
<div className="text-sm text-slate-400 px-3 py-2 text-center">
{collapsed ? "..." : "Cargando..."}
{collapsed ? "..." : "Loading..."}
</div>
) : Array.isArray(temas) && temas.length > 0 ? (
temas.map((tema) => (
@@ -331,7 +329,7 @@ export function Sidebar({
onClick={(e) => handleDeleteTema(tema, e)}
disabled={deletingTema === tema || disabled}
className="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded hover:bg-red-500/20 opacity-0 group-hover:opacity-100 transition-opacity disabled:opacity-50"
title="Eliminar dataroom y colección"
title="Delete dataroom and collection"
>
<Trash2 className="h-4 w-4 text-red-400" />
</button>
@@ -341,8 +339,8 @@ export function Sidebar({
) : (
<div className="text-sm text-slate-400 px-3 py-2 text-center">
{Array.isArray(temas) && temas.length === 0
? "No hay datarooms"
: "Cargando datarooms..."}
? "No datarooms found"
: "Loading datarooms..."}
</div>
)}
</div>
@@ -357,7 +355,7 @@ export function Sidebar({
>
{onNavigateToSchemas &&
renderWithTooltip(
"Gestionar Schemas",
"Manage schemas",
<Button
variant="default"
size="sm"
@@ -370,12 +368,12 @@ export function Sidebar({
>
<Database className={cn("h-4 w-4", !collapsed && "mr-2")} />
<span className={cn(collapsed && "sr-only")}>
Gestionar Schemas
Manage Schemas
</span>
</Button>,
)}
{renderWithTooltip(
"Actualizar datarooms",
"Refresh datarooms",
<Button
variant="ghost"
size="sm"
@@ -388,7 +386,7 @@ export function Sidebar({
>
<RefreshCcw className={cn("mr-2 h-4 w-4", collapsed && "mr-0")} />
<span className={cn(collapsed && "sr-only")}>
Actualizar datarooms
Refresh datarooms
</span>
</Button>,
)}
@@ -403,14 +401,14 @@ export function Sidebar({
aria-describedby="create-dataroom-description"
>
<DialogHeader>
<DialogTitle>Crear dataroom</DialogTitle>
<DialogTitle>Create dataroom</DialogTitle>
<DialogDescription id="create-dataroom-description">
Define un nombre único para organizar tus archivos.
Choose a unique name to organize your files.
</DialogDescription>
</DialogHeader>
<div className="space-y-3">
<div className="space-y-2">
<Label htmlFor="dataroom-name">Nombre del dataroom</Label>
<Label htmlFor="dataroom-name">Dataroom name</Label>
<Input
id="dataroom-name"
value={newDataroomName}
@@ -420,7 +418,7 @@ export function Sidebar({
setCreateError(null);
}
}}
placeholder="Ej: normativa, contratos, fiscal..."
placeholder="e.g., policies, contracts, finance..."
autoFocus
/>
{createError && (
@@ -434,13 +432,13 @@ export function Sidebar({
onClick={() => handleCreateDialogOpenChange(false)}
disabled={creatingDataroom}
>
Cancelar
Cancel
</Button>
<Button
onClick={handleCreateDataroom}
disabled={creatingDataroom || newDataroomName.trim() === ""}
>
{creatingDataroom ? "Creando..." : "Crear dataroom"}
{creatingDataroom ? "Creating…" : "Create"}
</Button>
</DialogFooter>
</DialogContent>

View File

@@ -721,3 +721,71 @@ $20
extraction_timestamp
$26
2025-11-09T16:12:46.318554
*2
$3
DEL
$56
:app.models.dataroom.DataRoom:01K9J2R5ZGS96G60P0G80W248Z
*10
$4
HSET
$56
:app.models.dataroom.DataRoom:01K9MSH70T90HY2VB6DPJVQZFQ
$2
pk
$26
01K9MSH70T90HY2VB6DPJVQZFQ
$4
name
$9
NEW HEART
$10
collection
$9
new_heart
$7
storage
$9
new_heart
*10
$4
HSET
$56
:app.models.dataroom.DataRoom:01K9MSJ57MS3DZFBG5TQXBDD6W
$2
pk
$26
01K9MSJ57MS3DZFBG5TQXBDD6W
$4
name
$5
OHANA
$10
collection
$5
ohana
$7
storage
$5
ohana
*10
$4
HSET
$56
:app.models.dataroom.DataRoom:01K9MSJJTH48BR7KQ27PXB2C3S
$2
pk
$26
01K9MSJJTH48BR7KQ27PXB2C3S
$4
name
$5
SOSFS
$10
collection
$5
sosfs
$7
storage
$5
sosfs

Binary file not shown.