wip
This commit is contained in:
@@ -1,88 +1,19 @@
|
|||||||
import { RefreshCw, Sparkles } from 'lucide-react'
|
import { RefreshCw, Sparkles } from 'lucide-react'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
import type { NewSubjectWizardState } from '@/features/asignaturas/nueva/types'
|
import type {
|
||||||
|
AsignaturaSugerida,
|
||||||
|
NewSubjectWizardState,
|
||||||
|
} from '@/features/asignaturas/nueva/types'
|
||||||
import type { Dispatch, SetStateAction } from 'react'
|
import type { Dispatch, SetStateAction } from 'react'
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Checkbox } from '@/components/ui/checkbox'
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import { Label } from '@/components/ui/label'
|
import { Label } from '@/components/ui/label'
|
||||||
|
import { usePlan } from '@/data'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
// Interfaces
|
|
||||||
interface Suggestion {
|
|
||||||
id: string
|
|
||||||
nombre: string
|
|
||||||
tipo: 'Obligatoria' | 'Optativa'
|
|
||||||
creditos: number
|
|
||||||
horasAcademicas: number
|
|
||||||
horasIndependientes: number
|
|
||||||
descripcion: string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Datos Mock basados en tu imagen
|
|
||||||
const MOCK_SUGGESTIONS: Array<Suggestion> = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
nombre: 'Propiedad Intelectual en Entornos Digitales',
|
|
||||||
tipo: 'Optativa',
|
|
||||||
creditos: 4,
|
|
||||||
horasAcademicas: 32,
|
|
||||||
horasIndependientes: 16,
|
|
||||||
descripcion:
|
|
||||||
'Derechos de autor, patentes de software y marcas en el ecosistema digital.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
nombre: 'Derecho Constitucional Digital',
|
|
||||||
tipo: 'Obligatoria',
|
|
||||||
creditos: 8,
|
|
||||||
horasAcademicas: 64,
|
|
||||||
horasIndependientes: 32,
|
|
||||||
descripcion:
|
|
||||||
'Marco constitucional aplicado al entorno digital y derechos fundamentales en línea.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
nombre: 'Gobernanza de Internet',
|
|
||||||
tipo: 'Optativa',
|
|
||||||
creditos: 4,
|
|
||||||
horasAcademicas: 32,
|
|
||||||
horasIndependientes: 16,
|
|
||||||
descripcion:
|
|
||||||
'Políticas públicas, regulación internacional y gobernanza del ecosistema digital.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '4',
|
|
||||||
nombre: 'Protección de Datos Personales',
|
|
||||||
tipo: 'Obligatoria',
|
|
||||||
creditos: 6,
|
|
||||||
horasAcademicas: 48,
|
|
||||||
horasIndependientes: 24,
|
|
||||||
descripcion:
|
|
||||||
'Regulación y cumplimiento de leyes de protección de datos (GDPR, LFPDPPP).',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '5',
|
|
||||||
nombre: 'Inteligencia Artificial y Ética Jurídica',
|
|
||||||
tipo: 'Optativa',
|
|
||||||
creditos: 4,
|
|
||||||
horasAcademicas: 32,
|
|
||||||
horasIndependientes: 16,
|
|
||||||
descripcion:
|
|
||||||
'Implicaciones legales y éticas del uso de IA en la práctica jurídica.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '6',
|
|
||||||
nombre: 'Ciberseguridad y Derecho Penal',
|
|
||||||
tipo: 'Obligatoria',
|
|
||||||
creditos: 6,
|
|
||||||
horasAcademicas: 48,
|
|
||||||
horasIndependientes: 24,
|
|
||||||
descripcion:
|
|
||||||
'Delitos informáticos, evidencia digital y marco penal en el ciberespacio.',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
export default function PasoSugerenciasForm({
|
export default function PasoSugerenciasForm({
|
||||||
wizard,
|
wizard,
|
||||||
onChange,
|
onChange,
|
||||||
@@ -90,22 +21,28 @@ export default function PasoSugerenciasForm({
|
|||||||
wizard: NewSubjectWizardState
|
wizard: NewSubjectWizardState
|
||||||
onChange: Dispatch<SetStateAction<NewSubjectWizardState>>
|
onChange: Dispatch<SetStateAction<NewSubjectWizardState>>
|
||||||
}) {
|
}) {
|
||||||
const selectedIds = wizard.iaMultiple?.selectedIds ?? []
|
const selectedIds = wizard.sugerencias
|
||||||
|
.filter((s) => s.selected)
|
||||||
|
.map((s) => s.id)
|
||||||
const ciclo = wizard.iaMultiple?.ciclo ?? ''
|
const ciclo = wizard.iaMultiple?.ciclo ?? ''
|
||||||
const enfoque = wizard.iaMultiple?.enfoque ?? ''
|
const enfoque = wizard.iaMultiple?.enfoque ?? ''
|
||||||
|
const [suggestions, setSuggestions] = useState<Array<AsignaturaSugerida>>([])
|
||||||
|
|
||||||
const setIaMultiple = (
|
const setIaMultiple = (
|
||||||
patch: Partial<NonNullable<NewSubjectWizardState['iaMultiple']>>,
|
patch: Partial<NonNullable<NewSubjectWizardState['iaMultiple']>>,
|
||||||
) =>
|
) =>
|
||||||
onChange((w) => ({
|
onChange(
|
||||||
...w,
|
(w): NewSubjectWizardState => ({
|
||||||
iaMultiple: {
|
...w,
|
||||||
ciclo: w.iaMultiple?.ciclo ?? '',
|
iaMultiple: {
|
||||||
enfoque: w.iaMultiple?.enfoque ?? '',
|
ciclo: w.iaMultiple?.ciclo ?? null,
|
||||||
selectedIds: w.iaMultiple?.selectedIds ?? [],
|
enfoque: w.iaMultiple?.enfoque ?? '',
|
||||||
...patch,
|
...patch,
|
||||||
},
|
},
|
||||||
}))
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
const { data: plan } = usePlan(wizard.plan_estudio_id)
|
||||||
|
|
||||||
const toggleAsignatura = (id: string, checked: boolean) => {
|
const toggleAsignatura = (id: string, checked: boolean) => {
|
||||||
const prev = selectedIds
|
const prev = selectedIds
|
||||||
@@ -133,7 +70,8 @@ export default function PasoSugerenciasForm({
|
|||||||
<Input
|
<Input
|
||||||
placeholder="Ej. 3"
|
placeholder="Ej. 3"
|
||||||
value={ciclo}
|
value={ciclo}
|
||||||
onChange={(e) => setIaMultiple({ ciclo: e.target.value })}
|
type="number"
|
||||||
|
onChange={(e) => setIaMultiple({ ciclo: Number(e.target.value) })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -152,7 +90,7 @@ export default function PasoSugerenciasForm({
|
|||||||
{/* Botón Refrescar */}
|
{/* Botón Refrescar */}
|
||||||
<Button type="button" variant="outline" className="h-9 gap-1.5">
|
<Button type="button" variant="outline" className="h-9 gap-1.5">
|
||||||
<RefreshCw className="h-3.5 w-3.5" />
|
<RefreshCw className="h-3.5 w-3.5" />
|
||||||
Nuevas sugerencias
|
Más sugerencias
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -164,7 +102,8 @@ export default function PasoSugerenciasForm({
|
|||||||
Asignaturas sugeridas
|
Asignaturas sugeridas
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-muted-foreground text-xs">
|
<p className="text-muted-foreground text-xs">
|
||||||
Basadas en el plan "Licenciatura en Derecho Digital"
|
Basadas en el plan{' '}
|
||||||
|
{plan ? `${plan.nivel} en ${plan.nombre}` : '...'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-muted text-foreground inline-flex items-center rounded-full px-2.5 py-0.5 text-sm font-semibold">
|
<div className="bg-muted text-foreground inline-flex items-center rounded-full px-2.5 py-0.5 text-sm font-semibold">
|
||||||
@@ -174,7 +113,7 @@ export default function PasoSugerenciasForm({
|
|||||||
|
|
||||||
{/* --- LISTA DE ASIGNATURAS (CON EL ESTILO PEDIDO) --- */}
|
{/* --- LISTA DE ASIGNATURAS (CON EL ESTILO PEDIDO) --- */}
|
||||||
<div className="max-h-80 space-y-1 overflow-y-auto pr-1">
|
<div className="max-h-80 space-y-1 overflow-y-auto pr-1">
|
||||||
{MOCK_SUGGESTIONS.map((asignatura) => {
|
{suggestions.map((asignatura) => {
|
||||||
const isSelected = selectedIds.includes(asignatura.id)
|
const isSelected = selectedIds.includes(asignatura.id)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -203,29 +142,30 @@ export default function PasoSugerenciasForm({
|
|||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<span className="text-foreground text-sm font-medium">
|
<span className="text-foreground text-sm font-medium">
|
||||||
{asignatura.nombre}
|
{asignatura.data.nombre}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{/* Badges de Tipo */}
|
{/* Badges de Tipo */}
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors',
|
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors',
|
||||||
asignatura.tipo === 'Obligatoria'
|
asignatura.data.tipo === 'OBLIGATORIA'
|
||||||
? 'border-blue-200 bg-transparent text-blue-700 dark:border-blue-800 dark:text-blue-300'
|
? 'border-blue-200 bg-transparent text-blue-700 dark:border-blue-800 dark:text-blue-300'
|
||||||
: 'border-yellow-200 bg-transparent text-yellow-700 dark:border-yellow-800 dark:text-yellow-300',
|
: 'border-yellow-200 bg-transparent text-yellow-700 dark:border-yellow-800 dark:text-yellow-300',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{asignatura.tipo}
|
{asignatura.data.tipo}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="text-xs text-slate-500 dark:text-slate-400">
|
<span className="text-xs text-slate-500 dark:text-slate-400">
|
||||||
{asignatura.creditos} cred. · {asignatura.horasAcademicas}h
|
{asignatura.data.creditos} cred. ·{' '}
|
||||||
acad. · {asignatura.horasIndependientes}h indep.
|
{asignatura.data.horasAcademicas}h acad. ·{' '}
|
||||||
|
{asignatura.data.horasIndependientes}h indep.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-muted-foreground mt-1 text-xs">
|
<p className="text-muted-foreground mt-1 text-xs">
|
||||||
{asignatura.descripcion}
|
{asignatura.data.descripcion}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</Label>
|
</Label>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import type { UploadedFile } from '@/components/planes/wizard/PasoDetallesPanel/
|
|||||||
import type { Database } from '@/types/supabase'
|
import type { Database } from '@/types/supabase'
|
||||||
|
|
||||||
const EDGE = {
|
const EDGE = {
|
||||||
|
generate_subject_suggestions: 'generate-subject-suggestions',
|
||||||
subjects_create_manual: 'subjects_create_manual',
|
subjects_create_manual: 'subjects_create_manual',
|
||||||
ai_generate_subject: 'ai-generate-subject',
|
ai_generate_subject: 'ai-generate-subject',
|
||||||
subjects_persist_from_ai: 'subjects_persist_from_ai',
|
subjects_persist_from_ai: 'subjects_persist_from_ai',
|
||||||
@@ -133,6 +134,15 @@ export type AIGenerateSubjectInput = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function generate_subject_suggestions(): Promise<
|
||||||
|
Array<{ [key: string]: any }>
|
||||||
|
> {
|
||||||
|
return invokeEdge<Array<{ [key: string]: any }>>(
|
||||||
|
EDGE.generate_subject_suggestions,
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export async function ai_generate_subject(
|
export async function ai_generate_subject(
|
||||||
input: AIGenerateSubjectInput,
|
input: AIGenerateSubjectInput,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const qk = {
|
|||||||
planHistorial: (planId: string) => ['planes', planId, 'historial'] as const,
|
planHistorial: (planId: string) => ['planes', planId, 'historial'] as const,
|
||||||
planDocumento: (planId: string) => ['planes', planId, 'documento'] as const,
|
planDocumento: (planId: string) => ['planes', planId, 'documento'] as const,
|
||||||
|
|
||||||
|
sugerenciasAsignaturas: () => ['asignaturas', 'sugerencias'] as const,
|
||||||
asignatura: (asignaturaId: string) =>
|
asignatura: (asignaturaId: string) =>
|
||||||
['asignaturas', 'detail', asignaturaId] as const,
|
['asignaturas', 'detail', asignaturaId] as const,
|
||||||
asignaturaBibliografia: (asignaturaId: string) =>
|
asignaturaBibliografia: (asignaturaId: string) =>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export function useNuevaAsignaturaWizard(planId: string) {
|
|||||||
horasIndependientes: null,
|
horasIndependientes: null,
|
||||||
estructuraId: '',
|
estructuraId: '',
|
||||||
},
|
},
|
||||||
|
sugerencias: [],
|
||||||
clonInterno: {},
|
clonInterno: {},
|
||||||
clonTradicional: {
|
clonTradicional: {
|
||||||
archivoWordAsignaturaId: null,
|
archivoWordAsignaturaId: null,
|
||||||
@@ -29,9 +30,9 @@ export function useNuevaAsignaturaWizard(planId: string) {
|
|||||||
archivosAdjuntos: [],
|
archivosAdjuntos: [],
|
||||||
},
|
},
|
||||||
iaMultiple: {
|
iaMultiple: {
|
||||||
ciclo: '',
|
ciclo: null,
|
||||||
enfoque: '',
|
enfoque: '',
|
||||||
selectedIds: ['1', '3', '6'],
|
selectedIds: [],
|
||||||
},
|
},
|
||||||
resumen: {},
|
resumen: {},
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type { UploadedFile } from '@/components/planes/wizard/PasoDetallesPanel/
|
|||||||
import type { Asignatura } from '@/data'
|
import type { Asignatura } from '@/data'
|
||||||
|
|
||||||
export type ModoCreacion = 'MANUAL' | 'IA' | 'CLONADO'
|
export type ModoCreacion = 'MANUAL' | 'IA' | 'CLONADO'
|
||||||
export type SubModoClonado = 'INTERNO' | 'TRADICIONAL'
|
|
||||||
export type TipoAsignatura = 'OBLIGATORIA' | 'OPTATIVA' | 'TRONCAL' | 'OTRO'
|
export type TipoAsignatura = 'OBLIGATORIA' | 'OPTATIVA' | 'TRONCAL' | 'OTRO'
|
||||||
|
|
||||||
export type AsignaturaPreview = {
|
export type AsignaturaPreview = {
|
||||||
@@ -12,6 +11,24 @@ export type AsignaturaPreview = {
|
|||||||
bibliografiaCount: number
|
bibliografiaCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type DataAsignaturaSugerida = {
|
||||||
|
nombre: Asignatura['nombre']
|
||||||
|
codigo?: Asignatura['codigo']
|
||||||
|
tipo: Asignatura['tipo'] | null
|
||||||
|
creditos: Asignatura['creditos'] | null
|
||||||
|
horasAcademicas?: number | null
|
||||||
|
horasIndependientes?: number | null
|
||||||
|
estructuraId: Asignatura['estructura_id'] | null
|
||||||
|
descripcion?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AsignaturaSugerida = {
|
||||||
|
id: string
|
||||||
|
selected: boolean
|
||||||
|
source: 'IA' | 'MANUAL' | 'CLON'
|
||||||
|
data: DataAsignaturaSugerida
|
||||||
|
}
|
||||||
|
|
||||||
export type NewSubjectWizardState = {
|
export type NewSubjectWizardState = {
|
||||||
step: 1 | 2 | 3 | 4
|
step: 1 | 2 | 3 | 4
|
||||||
plan_estudio_id: Asignatura['plan_estudio_id']
|
plan_estudio_id: Asignatura['plan_estudio_id']
|
||||||
@@ -30,6 +47,7 @@ export type NewSubjectWizardState = {
|
|||||||
horasIndependientes?: Asignatura['horas_independientes'] | null
|
horasIndependientes?: Asignatura['horas_independientes'] | null
|
||||||
estructuraId: Asignatura['estructura_id'] | null
|
estructuraId: Asignatura['estructura_id'] | null
|
||||||
}
|
}
|
||||||
|
sugerencias: Array<AsignaturaSugerida>
|
||||||
clonInterno?: {
|
clonInterno?: {
|
||||||
facultadId?: string
|
facultadId?: string
|
||||||
carreraId?: string
|
carreraId?: string
|
||||||
@@ -48,9 +66,9 @@ export type NewSubjectWizardState = {
|
|||||||
archivosAdjuntos?: Array<UploadedFile>
|
archivosAdjuntos?: Array<UploadedFile>
|
||||||
}
|
}
|
||||||
iaMultiple?: {
|
iaMultiple?: {
|
||||||
ciclo: string
|
ciclo: number | null
|
||||||
enfoque: string
|
enfoque: string
|
||||||
selectedIds: Array<string>
|
selectedIds?: Array<string>
|
||||||
}
|
}
|
||||||
resumen: {
|
resumen: {
|
||||||
previewAsignatura?: AsignaturaPreview
|
previewAsignatura?: AsignaturaPreview
|
||||||
|
|||||||
Reference in New Issue
Block a user