Se agrega id de ruta en las tabs y se corrigen redirecciones
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { useEffect, useState } from 'react'
|
|
||||||
import {
|
import {
|
||||||
Plus,
|
Plus,
|
||||||
Search,
|
Search,
|
||||||
@@ -8,25 +7,8 @@ import {
|
|||||||
Edit3,
|
Edit3,
|
||||||
Save,
|
Save,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { Card, CardContent } from '@/components/ui/card'
|
import { useEffect, useState } from 'react'
|
||||||
import { Button } from '@/components/ui/button'
|
|
||||||
import { Input } from '@/components/ui/input'
|
|
||||||
import { Textarea } from '@/components/ui/textarea'
|
|
||||||
import { Badge } from '@/components/ui/badge'
|
|
||||||
import {
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogHeader,
|
|
||||||
DialogTitle,
|
|
||||||
DialogTrigger,
|
|
||||||
} from '@/components/ui/dialog'
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from '@/components/ui/select'
|
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -37,10 +19,29 @@ import {
|
|||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/components/ui/alert-dialog'
|
} from '@/components/ui/alert-dialog'
|
||||||
import { cn } from '@/lib/utils'
|
import { Badge } from '@/components/ui/badge'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Card, CardContent } from '@/components/ui/card'
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
} from '@/components/ui/dialog'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
import { Textarea } from '@/components/ui/textarea'
|
||||||
import { useSubjectBibliografia } from '@/data/hooks/useSubjects'
|
import { useSubjectBibliografia } from '@/data/hooks/useSubjects'
|
||||||
//import { toast } from 'sonner';
|
import { cn } from '@/lib/utils'
|
||||||
//import { mockLibraryResources } from '@/data/mockMateriaData';
|
// import { toast } from 'sonner';
|
||||||
|
// import { mockLibraryResources } from '@/data/mockMateriaData';
|
||||||
|
|
||||||
export const mockLibraryResources = [
|
export const mockLibraryResources = [
|
||||||
{
|
{
|
||||||
@@ -84,19 +85,20 @@ export interface BibliografiaEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface BibliografiaTabProps {
|
interface BibliografiaTabProps {
|
||||||
bibliografia: BibliografiaEntry[]
|
bibliografia: Array<BibliografiaEntry>
|
||||||
onSave: (bibliografia: BibliografiaEntry[]) => void
|
onSave: (bibliografia: Array<BibliografiaEntry>) => void
|
||||||
isSaving: boolean
|
isSaving: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BibliographyItem({
|
export function BibliographyItem({
|
||||||
bibliografia,
|
bibliografia,
|
||||||
|
asignaturaId,
|
||||||
onSave,
|
onSave,
|
||||||
isSaving,
|
isSaving,
|
||||||
}: BibliografiaTabProps) {
|
}: BibliografiaTabProps) {
|
||||||
const { data: bibliografia2, isLoading: loadinmateria } =
|
const { data: bibliografia2, isLoading: loadinmateria } =
|
||||||
useSubjectBibliografia('9d4dda6a-488f-428a-8a07-38081592a641')
|
useSubjectBibliografia(asignaturaId)
|
||||||
const [entries, setEntries] = useState<BibliografiaEntry[]>(bibliografia)
|
const [entries, setEntries] = useState<Array<BibliografiaEntry>>(bibliografia)
|
||||||
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false)
|
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false)
|
||||||
const [isLibraryDialogOpen, setIsLibraryDialogOpen] = useState(false)
|
const [isLibraryDialogOpen, setIsLibraryDialogOpen] = useState(false)
|
||||||
const [deleteId, setDeleteId] = useState<string | null>(null)
|
const [deleteId, setDeleteId] = useState<string | null>(null)
|
||||||
@@ -128,7 +130,7 @@ export function BibliographyItem({
|
|||||||
}
|
}
|
||||||
setEntries([...entries, newEntry])
|
setEntries([...entries, newEntry])
|
||||||
setIsAddDialogOpen(false)
|
setIsAddDialogOpen(false)
|
||||||
//toast.success('Referencia manual añadida');
|
// toast.success('Referencia manual añadida');
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAddFromLibrary = (
|
const handleAddFromLibrary = (
|
||||||
@@ -145,7 +147,7 @@ export function BibliographyItem({
|
|||||||
}
|
}
|
||||||
setEntries([...entries, newEntry])
|
setEntries([...entries, newEntry])
|
||||||
setIsLibraryDialogOpen(false)
|
setIsLibraryDialogOpen(false)
|
||||||
//toast.success('Añadido desde biblioteca');
|
// toast.success('Añadido desde biblioteca');
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdateCita = (id: string, cita: string) => {
|
const handleUpdateCita = (id: string, cita: string) => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useState, useMemo } from 'react'
|
import { format, parseISO } from 'date-fns'
|
||||||
|
import { es } from 'date-fns/locale'
|
||||||
import {
|
import {
|
||||||
History,
|
History,
|
||||||
FileText,
|
FileText,
|
||||||
@@ -6,31 +7,30 @@ import {
|
|||||||
BookMarked,
|
BookMarked,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
FileCheck,
|
FileCheck,
|
||||||
User,
|
|
||||||
Filter,
|
Filter,
|
||||||
Calendar,
|
Calendar,
|
||||||
Loader2,
|
Loader2,
|
||||||
Eye,
|
Eye,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { Card, CardContent } from '@/components/ui/card'
|
import { useState, useMemo } from 'react'
|
||||||
import { Button } from '@/components/ui/button'
|
|
||||||
import { Badge } from '@/components/ui/badge'
|
import { Badge } from '@/components/ui/badge'
|
||||||
import {
|
import { Button } from '@/components/ui/button'
|
||||||
DropdownMenu,
|
import { Card, CardContent } from '@/components/ui/card'
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuCheckboxItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from '@/components/ui/dropdown-menu'
|
|
||||||
import { cn } from '@/lib/utils'
|
|
||||||
import { format, parseISO } from 'date-fns'
|
|
||||||
import { es } from 'date-fns/locale'
|
|
||||||
import { useSubjectHistorial } from '@/data/hooks/useSubjects'
|
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/components/ui/dialog'
|
} from '@/components/ui/dialog'
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuCheckboxItem,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from '@/components/ui/dropdown-menu'
|
||||||
|
import { useSubjectHistorial } from '@/data/hooks/useSubjects'
|
||||||
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
const tipoConfig: Record<string, { label: string; icon: any; color: string }> =
|
const tipoConfig: Record<string, { label: string; icon: any; color: string }> =
|
||||||
{
|
{
|
||||||
@@ -53,11 +53,9 @@ const tipoConfig: Record<string, { label: string; icon: any; color: string }> =
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HistorialTab() {
|
export function HistorialTab({ asignaturaId }) {
|
||||||
// 1. Obtenemos los datos directamente dentro del componente
|
// 1. Obtenemos los datos directamente dentro del componente
|
||||||
const { data: rawData, isLoading } = useSubjectHistorial(
|
const { data: rawData, isLoading } = useSubjectHistorial(asignaturaId)
|
||||||
'9d4dda6a-488f-428a-8a07-38081592a641',
|
|
||||||
)
|
|
||||||
|
|
||||||
const [filtros, setFiltros] = useState<Set<string>>(
|
const [filtros, setFiltros] = useState<Set<string>>(
|
||||||
new Set(['datos', 'contenido', 'bibliografia', 'ia', 'documento']),
|
new Set(['datos', 'contenido', 'bibliografia', 'ia', 'documento']),
|
||||||
@@ -164,7 +162,7 @@ export function HistorialTab() {
|
|||||||
groups[dateKey].push(cambio)
|
groups[dateKey].push(cambio)
|
||||||
return groups
|
return groups
|
||||||
},
|
},
|
||||||
{} as Record<string, any[]>,
|
{} as Record<string, Array<any>>,
|
||||||
)
|
)
|
||||||
|
|
||||||
const sortedDates = Object.keys(groupedHistorial).sort((a, b) =>
|
const sortedDates = Object.keys(groupedHistorial).sort((a, b) =>
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { Link, useRouterState } from '@tanstack/react-router'
|
import {
|
||||||
|
createFileRoute,
|
||||||
|
Link,
|
||||||
|
useParams,
|
||||||
|
useRouterState,
|
||||||
|
} from '@tanstack/react-router'
|
||||||
import { ArrowLeft, GraduationCap, Pencil, Sparkles } from 'lucide-react'
|
import { ArrowLeft, GraduationCap, Pencil, Sparkles } from 'lucide-react'
|
||||||
import { useCallback, useState, useEffect } from 'react'
|
import { useCallback, useState, useEffect } from 'react'
|
||||||
|
|
||||||
@@ -79,12 +84,21 @@ function EditableHeaderField({
|
|||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const Route = createFileRoute(
|
||||||
|
'/planes/$planId/asignaturas/$asignaturaId',
|
||||||
|
)({
|
||||||
|
component: MateriaDetailPage,
|
||||||
|
})
|
||||||
|
|
||||||
export default function MateriaDetailPage() {
|
export default function MateriaDetailPage() {
|
||||||
const routerState = useRouterState()
|
const routerState = useRouterState()
|
||||||
const state = routerState.location.state as any
|
const state = routerState.location.state as any
|
||||||
const { data: asignaturasApi, isLoading: loadingAsig } = useSubject(
|
const { asignaturaId } = useParams({
|
||||||
state?.realId,
|
from: '/planes/$planId/asignaturas/$asignaturaId',
|
||||||
)
|
})
|
||||||
|
const { data: asignaturasApi, isLoading: loadingAsig } =
|
||||||
|
useSubject(asignaturaId)
|
||||||
// 1. Asegúrate de tener estos estados en tu componente principal
|
// 1. Asegúrate de tener estos estados en tu componente principal
|
||||||
const [messages, setMessages] = useState<Array<IAMessage>>([])
|
const [messages, setMessages] = useState<Array<IAMessage>>([])
|
||||||
const [datosGenerales, setDatosGenerales] = useState({})
|
const [datosGenerales, setDatosGenerales] = useState({})
|
||||||
@@ -179,7 +193,7 @@ export default function MateriaDetailPage() {
|
|||||||
<section className="bg-gradient-to-b from-[#0b1d3a] to-[#0e2a5c] text-white">
|
<section className="bg-gradient-to-b from-[#0b1d3a] to-[#0e2a5c] text-white">
|
||||||
<div className="mx-auto max-w-7xl px-6 py-10">
|
<div className="mx-auto max-w-7xl px-6 py-10">
|
||||||
<Link
|
<Link
|
||||||
to="/planes"
|
to="/planes/$planId"
|
||||||
className="mb-4 flex items-center gap-2 text-sm text-blue-200 hover:text-white"
|
className="mb-4 flex items-center gap-2 text-sm text-blue-200 hover:text-white"
|
||||||
>
|
>
|
||||||
<ArrowLeft className="h-4 w-4" /> Volver al plan
|
<ArrowLeft className="h-4 w-4" /> Volver al plan
|
||||||
@@ -280,6 +294,7 @@ export default function MateriaDetailPage() {
|
|||||||
<TabsContent value="bibliografia">
|
<TabsContent value="bibliografia">
|
||||||
<BibliographyItem
|
<BibliographyItem
|
||||||
bibliografia={bibliografia}
|
bibliografia={bibliografia}
|
||||||
|
id={asignaturaId}
|
||||||
onSave={handleSaveBibliografia}
|
onSave={handleSaveBibliografia}
|
||||||
isSaving={isSaving}
|
isSaving={isSaving}
|
||||||
/>
|
/>
|
||||||
@@ -313,7 +328,7 @@ export default function MateriaDetailPage() {
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="historial">
|
<TabsContent value="historial">
|
||||||
<HistorialTab />
|
<HistorialTab asignaturaId={asignaturaId} />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ function MateriasPage() {
|
|||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
realId: materia.id, // 👈 ID largo oculto
|
realId: materia.id, // 👈 ID largo oculto
|
||||||
|
asignaturaId: materia.id,
|
||||||
} as any,
|
} as any,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user