From 9c588cfd8fbcf7dbb5fc0928260111fdc177b72c Mon Sep 17 00:00:00 2001 From: Guillermo Arrieta Medina Date: Thu, 12 Feb 2026 13:24:24 -0600 Subject: [PATCH] =?UTF-8?q?PasoResumen=20muestra=20resumen=20antes=20de=20?= =?UTF-8?q?crear=20m=C3=BAltiples=20asignaturas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../asignaturas/wizard/PasoResumenCard.tsx | 297 ++++++++++++------ .../nueva/hooks/useNuevaAsignaturaWizard.ts | 14 +- src/types/supabase.ts | 10 +- 3 files changed, 211 insertions(+), 110 deletions(-) diff --git a/src/components/asignaturas/wizard/PasoResumenCard.tsx b/src/components/asignaturas/wizard/PasoResumenCard.tsx index 973e155..80e375c 100644 --- a/src/components/asignaturas/wizard/PasoResumenCard.tsx +++ b/src/components/asignaturas/wizard/PasoResumenCard.tsx @@ -9,12 +9,13 @@ import { CardHeader, CardTitle, } from '@/components/ui/card' -import { usePlan, useSubjectEstructuras } from '@/data' +import { usePlan, usePlanLineas, useSubjectEstructuras } from '@/data' import { formatFileSize } from '@/features/planes/utils/format-file-size' export function PasoResumenCard({ wizard }: { wizard: NewSubjectWizardState }) { const { data: plan } = usePlan(wizard.plan_estudio_id) const { data: estructuras } = useSubjectEstructuras() + const { data: lineasPlan } = usePlanLineas(wizard.plan_estudio_id) const estructuraNombre = (() => { const estructuraId = wizard.datosBasicos.estructuraId @@ -26,6 +27,8 @@ export function PasoResumenCard({ wizard }: { wizard: NewSubjectWizardState }) { const modoLabel = (() => { if (wizard.tipoOrigen === 'MANUAL') return 'Manual (Vacía)' if (wizard.tipoOrigen === 'IA') return 'Generada con IA' + if (wizard.tipoOrigen === 'IA_SIMPLE') return 'Generada con IA (Simple)' + if (wizard.tipoOrigen === 'IA_MULTIPLE') return 'Generación múltiple (IA)' if (wizard.tipoOrigen === 'CLONADO_INTERNO') return 'Clonada (Sistema)' if (wizard.tipoOrigen === 'CLONADO_TRADICIONAL') return 'Clonada (Archivo)' return '—' @@ -41,6 +44,10 @@ export function PasoResumenCard({ wizard }: { wizard: NewSubjectWizardState }) { const repositoriosRef = wizard.iaConfig?.repositoriosReferencia ?? [] const adjuntos = wizard.iaConfig?.archivosAdjuntos ?? [] + const materiasSeleccionadas = wizard.sugerencias.filter((s) => s.selected) + const iaMultipleEnfoque = wizard.iaMultiple?.enfoque.trim() ?? '' + const iaMultipleCantidad = wizard.iaMultiple?.cantidadDeSugerencias ?? 10 + return ( @@ -72,7 +79,9 @@ export function PasoResumenCard({ wizard }: { wizard: NewSubjectWizardState }) { {wizard.tipoOrigen === 'MANUAL' && ( )} - {wizard.tipoOrigen === 'IA' && ( + {(wizard.tipoOrigen === 'IA' || + wizard.tipoOrigen === 'IA_SIMPLE' || + wizard.tipoOrigen === 'IA_MULTIPLE') && ( )} {(wizard.tipoOrigen === 'CLONADO_INTERNO' || @@ -83,112 +92,202 @@ export function PasoResumenCard({ wizard }: { wizard: NewSubjectWizardState }) { -
-
- Nombre: - - {wizard.datosBasicos.nombre || '—'} - -
-
- Código: - - {wizard.datosBasicos.codigo || '—'} - -
-
- Tipo: - - {wizard.datosBasicos.tipo || '—'} - -
-
- Créditos: - {creditosText} -
-
- Estructura: - {estructuraNombre} -
-
- Horas académicas: - - {wizard.datosBasicos.horasAcademicas ?? '—'} - -
-
- - Horas independientes:{' '} - - - {wizard.datosBasicos.horasIndependientes ?? '—'} - -
-
+ {wizard.tipoOrigen === 'IA_MULTIPLE' ? ( + <> +
+
+
+ Configuración +
+
+ Se crearán {materiasSeleccionadas.length} asignatura(s) a + partir de tus selecciones. +
+
-
-
Configuración IA
-
-
- - Enfoque académico:{' '} - - - {wizard.iaConfig?.descripcionEnfoqueAcademico || '—'} - -
-
- - Instrucciones adicionales:{' '} - - - {wizard.iaConfig?.instruccionesAdicionalesIA || '—'} - +
+
+ Estructura +
+
+ {estructuraNombre} +
+
-
-
Archivos de referencia
- {archivosRef.length ? ( -
    - {archivosRef.map((id) => ( -
  • {id}
  • - ))} -
+
+
+
+ Materias seleccionadas +
+
+ {materiasSeleccionadas.length} en total +
+
+ + {materiasSeleccionadas.length === 0 ? ( +
+ No hay materias seleccionadas. +
) : ( -
+
+ {materiasSeleccionadas.map((m) => { + const lineaNombre = m.linea_plan_id + ? (lineasPlan?.find((l) => l.id === m.linea_plan_id) + ?.nombre ?? m.linea_plan_id) + : '—' + + const cicloText = + typeof m.numero_ciclo === 'number' && + Number.isFinite(m.numero_ciclo) + ? String(m.numero_ciclo) + : '—' + + return ( +
+
+
+ {m.nombre} +
+
+ + Línea: {lineaNombre} + + + Ciclo: {cicloText} + +
+
+ +
+ {m.descripcion || '—'} +
+
+ ) + })} +
)}
- -
-
Repositorios de referencia
- {repositoriosRef.length ? ( -
    - {repositoriosRef.map((id) => ( -
  • {id}
  • - ))} -
- ) : ( -
- )} + + ) : ( + <> +
+
+ Nombre: + + {wizard.datosBasicos.nombre || '—'} + +
+
+ Código: + + {wizard.datosBasicos.codigo || '—'} + +
+
+ Tipo: + + {wizard.datosBasicos.tipo || '—'} + +
+
+ Créditos: + {creditosText} +
+
+ Estructura: + {estructuraNombre} +
+
+ + Horas académicas:{' '} + + + {wizard.datosBasicos.horasAcademicas ?? '—'} + +
+
+ + Horas independientes:{' '} + + + {wizard.datosBasicos.horasIndependientes ?? '—'} + +
-
-
Archivos adjuntos
- {adjuntos.length ? ( -
    - {adjuntos.map((f) => ( -
  • - {f.file.name}{' '} - · {formatFileSize(f.file.size)} -
  • - ))} -
- ) : ( -
- )} +
+
Configuración IA
+
+
+ + Enfoque académico:{' '} + + + {wizard.iaConfig?.descripcionEnfoqueAcademico || '—'} + +
+
+ + Instrucciones adicionales:{' '} + + + {wizard.iaConfig?.instruccionesAdicionalesIA || '—'} + +
+ +
+
Archivos de referencia
+ {archivosRef.length ? ( +
    + {archivosRef.map((id) => ( +
  • {id}
  • + ))} +
+ ) : ( +
+ )} +
+ +
+
+ Repositorios de referencia +
+ {repositoriosRef.length ? ( +
    + {repositoriosRef.map((id) => ( +
  • {id}
  • + ))} +
+ ) : ( +
+ )} +
+ +
+
Archivos adjuntos
+ {adjuntos.length ? ( +
    + {adjuntos.map((f) => ( +
  • + + {f.file.name} + {' '} + · {formatFileSize(f.file.size)} +
  • + ))} +
+ ) : ( +
+ )} +
+
-
-
+ + )}
diff --git a/src/features/asignaturas/nueva/hooks/useNuevaAsignaturaWizard.ts b/src/features/asignaturas/nueva/hooks/useNuevaAsignaturaWizard.ts index 81d2ee0..60af693 100644 --- a/src/features/asignaturas/nueva/hooks/useNuevaAsignaturaWizard.ts +++ b/src/features/asignaturas/nueva/hooks/useNuevaAsignaturaWizard.ts @@ -48,15 +48,17 @@ export function useNuevaAsignaturaWizard(planId: string) { wizard.tipoOrigen === 'CLONADO_TRADICIONAL' const canContinueDesdeBasicos = - !!wizard.datosBasicos.nombre && - wizard.datosBasicos.tipo !== null && - wizard.datosBasicos.creditos !== null && - wizard.datosBasicos.creditos > 0 && - !!wizard.datosBasicos.estructuraId + (!!wizard.datosBasicos.nombre && + wizard.datosBasicos.tipo !== null && + wizard.datosBasicos.creditos !== null && + wizard.datosBasicos.creditos > 0 && + !!wizard.datosBasicos.estructuraId) || + (wizard.tipoOrigen === 'IA_MULTIPLE' && + wizard.sugerencias.filter((s) => s.selected).length > 0) const canContinueDesdeDetalles = (() => { if (wizard.tipoOrigen === 'MANUAL') return true - if (wizard.tipoOrigen === 'IA') { + if (wizard.tipoOrigen === 'IA_SIMPLE') { return !!wizard.iaConfig?.descripcionEnfoqueAcademico } if (wizard.tipoOrigen === 'CLONADO_INTERNO') { diff --git a/src/types/supabase.ts b/src/types/supabase.ts index 9a75d6d..222236a 100644 --- a/src/types/supabase.ts +++ b/src/types/supabase.ts @@ -7,11 +7,6 @@ export type Json = | Array export type Database = { - // Allows to automatically instantiate createClient with right options - // instead of createClient(URL, KEY) - __InternalSupabase: { - PostgrestVersion: '12.2.3 (519615d)' - } graphql_public: { Tables: { [_ in never]: never @@ -98,6 +93,7 @@ export type Database = { creado_por: string | null creditos: number datos: Json + estado: Database['public']['Enums']['estado_asignatura'] estructura_id: string | null horas_academicas: number | null horas_independientes: number | null @@ -122,6 +118,7 @@ export type Database = { creado_por?: string | null creditos: number datos?: Json + estado?: Database['public']['Enums']['estado_asignatura'] estructura_id?: string | null horas_academicas?: number | null horas_independientes?: number | null @@ -146,6 +143,7 @@ export type Database = { creado_por?: string | null creditos?: number datos?: Json + estado?: Database['public']['Enums']['estado_asignatura'] estructura_id?: string | null horas_academicas?: number | null horas_independientes?: number | null @@ -1089,6 +1087,7 @@ export type Database = { unaccent_immutable: { Args: { '': string }; Returns: string } } Enums: { + estado_asignatura: 'borrador' | 'revisada' | 'aprobada' | 'generando' estado_tarea_revision: 'PENDIENTE' | 'COMPLETADA' | 'OMITIDA' fuente_cambio: 'HUMANO' | 'IA' nivel_plan_estudio: @@ -1261,6 +1260,7 @@ export const Constants = { }, public: { Enums: { + estado_asignatura: ['borrador', 'revisada', 'aprobada', 'generando'], estado_tarea_revision: ['PENDIENTE', 'COMPLETADA', 'OMITIDA'], fuente_cambio: ['HUMANO', 'IA'], nivel_plan_estudio: [