From 101758da244572f9c8c313247b9c0490b5ca11fe Mon Sep 17 00:00:00 2001 From: Guillermo Arrieta Medina Date: Mon, 6 Oct 2025 12:50:38 -0600 Subject: [PATCH] =?UTF-8?q?Se=20quit=C3=B3=20bot=C3=B3n=20de=20editar=20pr?= =?UTF-8?q?ompt,=20se=20arregl=C3=B3=20el=20bug=20de=20no=20encontrar=20el?= =?UTF-8?q?=20plan=20de=20estudios=20por=20el=20uuid=20al=20estar=20idle?= =?UTF-8?q?=20la=20p=C3=A1gina,=20y=20se=20arregl=C3=B3=20el=20bug=20de=20?= =?UTF-8?q?visualizaci=C3=B3n=20de=20archivos=20en=20el=20modal=20de=20cre?= =?UTF-8?q?ar=20plan=20de=20estudios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Academic-sections: ya se renderea condicionalmente el botón de editar prompt. AddAsignaturaButton: se quitaron llamadas redundantes de invalidateQueries. CreatePlanDialog: ya no se selecciona la columna de s3_file_path porque ya no existe. $planId: el bug de no encontrar el plan de estudios por el uuid al estar idle la página probablemente era causado por llamar de manera redundante a planByIdOptions(), asignaturasCountOptions() y asignaturasPreviewOptions() en el componente. Ahora desde el loader se obtiene toda la información del plan de estudios y sus asignaturas. --- src/components/planes/AddAsignaturaButton.tsx | 6 ++--- src/components/planes/CreatePlanDialog.tsx | 2 +- src/components/planes/academic-sections.tsx | 24 ++++++++++--------- src/routes/_authenticated/plan/$planId.tsx | 18 +++++++------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/components/planes/AddAsignaturaButton.tsx b/src/components/planes/AddAsignaturaButton.tsx index 17f5754..d5e639b 100644 --- a/src/components/planes/AddAsignaturaButton.tsx +++ b/src/components/planes/AddAsignaturaButton.tsx @@ -50,8 +50,6 @@ export function AddAsignaturaButton({ planId, onAdded }: { planId: string; onAdd if (error) { alert(error.message); return } setOpen(false) onAdded?.() - qc.invalidateQueries({ queryKey: asignaturaKeys.preview(planId) }) - qc.invalidateQueries({ queryKey: asignaturaKeys.count(planId) }) } async function createWithAI() { @@ -69,8 +67,8 @@ export function AddAsignaturaButton({ planId, onAdded }: { planId: string; onAdd confetti({ particleCount: 120, spread: 80, origin: { y: 0.6 } }) setOpen(false) onAdded?.() - qc.invalidateQueries({ queryKey: asignaturaKeys.preview(planId) }) - qc.invalidateQueries({ queryKey: asignaturaKeys.count(planId) }) + // qc.invalidateQueries({ queryKey: asignaturaKeys.preview(planId) }) + // qc.invalidateQueries({ queryKey: asignaturaKeys.count(planId) }) } catch (e: any) { alert(e?.message ?? "Error al generar la asignatura") } finally { setSaving(false) } diff --git a/src/components/planes/CreatePlanDialog.tsx b/src/components/planes/CreatePlanDialog.tsx index f9b409f..fde48b5 100644 --- a/src/components/planes/CreatePlanDialog.tsx +++ b/src/components/planes/CreatePlanDialog.tsx @@ -90,7 +90,7 @@ export function CreatePlanDialog({ open, onOpenChange }: { open: boolean; onOpen try { const { data, error } = await supabase .from("documentos") - .select("documentos_id, titulo_archivo, s3_file_path, fecha_subida, tags") + .select("documentos_id, titulo_archivo, fecha_subida, tags") .ilike("titulo_archivo", `%${debouncedSearchTerm}%`) .range((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage - 1); diff --git a/src/components/planes/academic-sections.tsx b/src/components/planes/academic-sections.tsx index 441c844..e143526 100644 --- a/src/components/planes/academic-sections.tsx +++ b/src/components/planes/academic-sections.tsx @@ -109,6 +109,7 @@ function SectionPanel({ title, icon: Icon, color, children, id }: { title: strin ===================================================== */ export function AcademicSections({ planId, color }: { planId: string; color?: string | null }) { const qc = useQueryClient() + if(!planId) return
Cargando…
const { data: plan } = useSuspenseQuery(planTextOptions(planId)) const [editing, setEditing] = useState(null) @@ -175,17 +176,18 @@ export function AcademicSections({ planId, color }: { planId: string; color?: st > Copiar - + {s.key !== "prompt" && + ()} ) diff --git a/src/routes/_authenticated/plan/$planId.tsx b/src/routes/_authenticated/plan/$planId.tsx index af8ed4b..61d0b47 100644 --- a/src/routes/_authenticated/plan/$planId.tsx +++ b/src/routes/_authenticated/plan/$planId.tsx @@ -21,7 +21,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { DeletePlanButton } from "@/components/planes/DeletePlan" import { AddAsignaturaButton } from "@/components/planes/AddAsignaturaButton" -type LoaderData = { planId: string } +type LoaderData = { plan: PlanFull; asignaturas: AsignaturaLite[] } export const Route = createFileRoute("/_authenticated/plan/$planId")({ component: RouteComponent, @@ -34,24 +34,24 @@ export const Route = createFileRoute("/_authenticated/plan/$planId")({ loader: async ({ params, context: { queryClient } }): Promise => { const { planId } = params - await Promise.all([ + if (!planId) throw new Error("planId is required") + console.log("Cargando planId", planId) + const [plan, asignaturas] = await Promise.all([ queryClient.ensureQueryData(planByIdOptions(planId)), - queryClient.ensureQueryData(asignaturasCountOptions(planId)), + // queryClient.ensureQueryData(asignaturasCountOptions(planId)), queryClient.ensureQueryData(asignaturasPreviewOptions(planId)), ]) - return { planId } + + return { plan, asignaturas } }, }) // ...existing code... function RouteComponent() { const qc = useQueryClient() - const { planId } = Route.useLoaderData() as LoaderData + const { plan, asignaturas: asignaturasPreview } = Route.useLoaderData() as LoaderData const auth = useSupabaseAuth() - - const { data: plan } = useSuspenseQuery(planByIdOptions(planId)) - const { data: asignaturasCount } = useSuspenseQuery(asignaturasCountOptions(planId)) - const { data: asignaturasPreview } = useSuspenseQuery(asignaturasPreviewOptions(planId)) + const asignaturasCount = asignaturasPreview.length const showFacultad = auth.claims?.role === 'lci' || auth.claims?.role === 'vicerrectoria' const showCarrera = auth.claims?.role === 'secretario_academico'