Author SHA1 Message Date
roberto.silva 8bb8399ec5 Merge branch 'feature/PdfAndHistorico' 2025-11-05 15:20:52 -06:00
Guillermo.Arrieta 6e2b3d72f1 Se envían correctamente los ids de los archivos de referencia para su procesamiento en el backend 2025-10-27 17:14:50 -06:00
Guillermo.Arrieta 0c5c3f935b comm 2025-10-27 15:45:16 -06:00
Guillermo.Arrieta 8da08b6bf1 La pantalla se volvía negra al abrir el dialogo de eliminar carrera
La razón es que se rendereaba un dialogo de borrado por carrera, pero al abrir uno se abrian los demás también
2025-10-24 13:01:33 -06:00
roberto.silva 1fe8f2b6a8 Se corrigen bugs sobre crear carreras, filtrado y que aparezcan las materias cuando se crean 2025-10-24 12:36:39 -06:00
+14 -14
View File
@@ -104,7 +104,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
setDbFiles((data || []).map((file: any) => ({ setDbFiles((data || []).map((file: any) => ({
id: file.documentos_id, id: file.documentos_id,
titulo: file.titulo_archivo, titulo: file.titulo_archivo,
s3_file_path: file.titulo_archivo, s3_file_path: `prueba-referencias/documento_${file.documentos_id}.pdf`,
fecha_subida: file.fecha_subida, fecha_subida: file.fecha_subida,
tags: file.tags || [], tags: file.tags || [],
}))); })));
@@ -118,35 +118,35 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
const isSelected = useCallback((path: string) => selectedFiles.includes(path), [selectedFiles]); const isSelected = useCallback((path: string) => selectedFiles.includes(path), [selectedFiles]);
const toggleSelected = useCallback((path: string) => { const toggleSelected = useCallback((id: string) => {
setSelectedFiles(prev => prev.includes(path) ? prev.filter(p => p !== path) : [...prev, path]); setSelectedFiles(prev => prev.includes(id) ? prev.filter(p => p !== id) : [...prev, id]);
}, []); }, []);
const replaceSelection = useCallback((path: string) => { const replaceSelection = useCallback((id: string) => {
setSelectedFiles([path]); setSelectedFiles([id]);
}, []); }, []);
const rangeSelect = useCallback((start: number, end: number) => { const rangeSelect = useCallback((start: number, end: number) => {
const [s, e] = start < end ? [start, end] : [end, start]; const [s, e] = start < end ? [start, end] : [end, start];
const paths = dbFiles.slice(s, e + 1).map(f => f.s3_file_path); const ids = dbFiles.slice(s, e + 1).map(f => f.id);
setSelectedFiles(prev => Array.from(new Set([...prev, ...paths]))); setSelectedFiles(prev => Array.from(new Set([...prev, ...ids])));
}, [dbFiles]); }, [dbFiles]);
const handleCardClick = useCallback((e: React.MouseEvent, index: number, file: { s3_file_path: string }) => { const handleCardClick = useCallback((e: React.MouseEvent, index: number, file: { id: string }) => {
const path = file.s3_file_path; const id = file.id;
if (e.shiftKey && lastSelectedIndex !== null) { if (e.shiftKey && lastSelectedIndex !== null) {
rangeSelect(lastSelectedIndex, index); rangeSelect(lastSelectedIndex, index);
} else if (e.metaKey || e.ctrlKey) { } else if (e.metaKey || e.ctrlKey) {
toggleSelected(path); toggleSelected(id);
setLastSelectedIndex(index); setLastSelectedIndex(index);
} else { } else {
if (isSelected(path) && selectedFiles.length === 1) { if (isSelected(id) && selectedFiles.length === 1) {
// si ya es el único seleccionado, des-selecciona // si ya es el único seleccionado, des-selecciona
setSelectedFiles([]); setSelectedFiles([]);
setLastSelectedIndex(null); setLastSelectedIndex(null);
} else { } else {
replaceSelection(path); replaceSelection(id);
setLastSelectedIndex(index); setLastSelectedIndex(index);
} }
} }
@@ -167,7 +167,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
prompt: prompt, prompt: prompt,
insert: true, insert: true,
files: selectedFiles, files: selectedFiles,
uuid: auth.user?.id, created_by: auth.user?.id,
}) })
const newId = (res as any)?.id || (res as any)?.plan?.id || (res as any)?.data?.id const newId = (res as any)?.id || (res as any)?.plan?.id || (res as any)?.data?.id
if (newId) { if (newId) {
@@ -261,7 +261,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen
<div role="grid" className="grid gap-4 xs:grid-cols-2 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5"> <div role="grid" className="grid gap-4 xs:grid-cols-2 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">
{dbFiles.map((file, index) => { {dbFiles.map((file, index) => {
const ext = fileExt(file.titulo); const ext = fileExt(file.titulo);
const selected = isSelected(file.s3_file_path); const selected = isSelected(file.id);
console.log(file); console.log(file);
return ( return (