diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index c809b44..1b59351 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -14,6 +14,8 @@ import { Route as AuthenticatedRouteImport } from './routes/_authenticated' import { Route as IndexRouteImport } from './routes/index' import { Route as AuthenticatedPlanesRouteImport } from './routes/_authenticated/planes' import { Route as AuthenticatedFacultadesRouteImport } from './routes/_authenticated/facultades' +import { Route as AuthenticatedDashboardRouteImport } from './routes/_authenticated/dashboard' +import { Route as AuthenticatedAsignaturasRouteImport } from './routes/_authenticated/asignaturas' import { Route as AuthenticatedPlanesPlanIdRouteImport } from './routes/_authenticated/planes/$planId' import { Route as AuthenticatedFacultadFacultadIdRouteImport } from './routes/_authenticated/facultad/$facultadId' import { Route as AuthenticatedPlanesPlanIdModalRouteImport } from './routes/_authenticated/planes/$planId/modal' @@ -42,6 +44,17 @@ const AuthenticatedFacultadesRoute = AuthenticatedFacultadesRouteImport.update({ path: '/facultades', getParentRoute: () => AuthenticatedRoute, } as any) +const AuthenticatedDashboardRoute = AuthenticatedDashboardRouteImport.update({ + id: '/dashboard', + path: '/dashboard', + getParentRoute: () => AuthenticatedRoute, +} as any) +const AuthenticatedAsignaturasRoute = + AuthenticatedAsignaturasRouteImport.update({ + id: '/asignaturas', + path: '/asignaturas', + getParentRoute: () => AuthenticatedRoute, + } as any) const AuthenticatedPlanesPlanIdRoute = AuthenticatedPlanesPlanIdRouteImport.update({ id: '/$planId', @@ -64,6 +77,8 @@ const AuthenticatedPlanesPlanIdModalRoute = export interface FileRoutesByFullPath { '/': typeof IndexRoute '/login': typeof LoginRoute + '/asignaturas': typeof AuthenticatedAsignaturasRoute + '/dashboard': typeof AuthenticatedDashboardRoute '/facultades': typeof AuthenticatedFacultadesRoute '/planes': typeof AuthenticatedPlanesRouteWithChildren '/facultad/$facultadId': typeof AuthenticatedFacultadFacultadIdRoute @@ -73,6 +88,8 @@ export interface FileRoutesByFullPath { export interface FileRoutesByTo { '/': typeof IndexRoute '/login': typeof LoginRoute + '/asignaturas': typeof AuthenticatedAsignaturasRoute + '/dashboard': typeof AuthenticatedDashboardRoute '/facultades': typeof AuthenticatedFacultadesRoute '/planes': typeof AuthenticatedPlanesRouteWithChildren '/facultad/$facultadId': typeof AuthenticatedFacultadFacultadIdRoute @@ -84,6 +101,8 @@ export interface FileRoutesById { '/': typeof IndexRoute '/_authenticated': typeof AuthenticatedRouteWithChildren '/login': typeof LoginRoute + '/_authenticated/asignaturas': typeof AuthenticatedAsignaturasRoute + '/_authenticated/dashboard': typeof AuthenticatedDashboardRoute '/_authenticated/facultades': typeof AuthenticatedFacultadesRoute '/_authenticated/planes': typeof AuthenticatedPlanesRouteWithChildren '/_authenticated/facultad/$facultadId': typeof AuthenticatedFacultadFacultadIdRoute @@ -95,6 +114,8 @@ export interface FileRouteTypes { fullPaths: | '/' | '/login' + | '/asignaturas' + | '/dashboard' | '/facultades' | '/planes' | '/facultad/$facultadId' @@ -104,6 +125,8 @@ export interface FileRouteTypes { to: | '/' | '/login' + | '/asignaturas' + | '/dashboard' | '/facultades' | '/planes' | '/facultad/$facultadId' @@ -114,6 +137,8 @@ export interface FileRouteTypes { | '/' | '/_authenticated' | '/login' + | '/_authenticated/asignaturas' + | '/_authenticated/dashboard' | '/_authenticated/facultades' | '/_authenticated/planes' | '/_authenticated/facultad/$facultadId' @@ -164,6 +189,20 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof AuthenticatedFacultadesRouteImport parentRoute: typeof AuthenticatedRoute } + '/_authenticated/dashboard': { + id: '/_authenticated/dashboard' + path: '/dashboard' + fullPath: '/dashboard' + preLoaderRoute: typeof AuthenticatedDashboardRouteImport + parentRoute: typeof AuthenticatedRoute + } + '/_authenticated/asignaturas': { + id: '/_authenticated/asignaturas' + path: '/asignaturas' + fullPath: '/asignaturas' + preLoaderRoute: typeof AuthenticatedAsignaturasRouteImport + parentRoute: typeof AuthenticatedRoute + } '/_authenticated/planes/$planId': { id: '/_authenticated/planes/$planId' path: '/$planId' @@ -214,12 +253,16 @@ const AuthenticatedPlanesRouteWithChildren = AuthenticatedPlanesRoute._addFileChildren(AuthenticatedPlanesRouteChildren) interface AuthenticatedRouteChildren { + AuthenticatedAsignaturasRoute: typeof AuthenticatedAsignaturasRoute + AuthenticatedDashboardRoute: typeof AuthenticatedDashboardRoute AuthenticatedFacultadesRoute: typeof AuthenticatedFacultadesRoute AuthenticatedPlanesRoute: typeof AuthenticatedPlanesRouteWithChildren AuthenticatedFacultadFacultadIdRoute: typeof AuthenticatedFacultadFacultadIdRoute } const AuthenticatedRouteChildren: AuthenticatedRouteChildren = { + AuthenticatedAsignaturasRoute: AuthenticatedAsignaturasRoute, + AuthenticatedDashboardRoute: AuthenticatedDashboardRoute, AuthenticatedFacultadesRoute: AuthenticatedFacultadesRoute, AuthenticatedPlanesRoute: AuthenticatedPlanesRouteWithChildren, AuthenticatedFacultadFacultadIdRoute: AuthenticatedFacultadFacultadIdRoute, diff --git a/src/routes/_authenticated.tsx b/src/routes/_authenticated.tsx index 3ed4b4f..e29c5cf 100644 --- a/src/routes/_authenticated.tsx +++ b/src/routes/_authenticated.tsx @@ -22,7 +22,6 @@ import { LayoutDashboard, GraduationCap, FileText, - Settings, LogOut, KeySquare, IdCard, @@ -40,9 +39,8 @@ export const Route = createFileRoute("/_authenticated")({ const nav = [ { to: "/planes", label: "Planes", icon: GraduationCap }, - { to: "/materias", label: "Materias", icon: FileText }, + { to: "/asignaturas", label: "Asignaturas", icon: FileText }, { to: "/dashboard", label: "Dashboard", icon: LayoutDashboard }, - { to: "/ajustes", label: "Ajustes", icon: Settings }, ] as const function getInitials(name?: string) { diff --git a/src/routes/_authenticated/asignaturas.tsx b/src/routes/_authenticated/asignaturas.tsx new file mode 100644 index 0000000..d0d0c93 --- /dev/null +++ b/src/routes/_authenticated/asignaturas.tsx @@ -0,0 +1,9 @@ +import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/_authenticated/asignaturas')({ + component: RouteComponent, +}) + +function RouteComponent() { + return
Hello "/_authenticated/asignaturas"!
+} diff --git a/src/routes/_authenticated/dashboard.tsx b/src/routes/_authenticated/dashboard.tsx new file mode 100644 index 0000000..9e5ee54 --- /dev/null +++ b/src/routes/_authenticated/dashboard.tsx @@ -0,0 +1,9 @@ +import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/_authenticated/dashboard')({ + component: RouteComponent, +}) + +function RouteComponent() { + return
Hello "/_authenticated/dashboard"!
+} diff --git a/src/routes/_authenticated/facultad/$facultadId.tsx b/src/routes/_authenticated/facultad/$facultadId.tsx index 1d4b498..156d900 100644 --- a/src/routes/_authenticated/facultad/$facultadId.tsx +++ b/src/routes/_authenticated/facultad/$facultadId.tsx @@ -203,7 +203,7 @@ function RouteComponent() { {recientes.length === 0 &&
  • Sin actividad
  • } {recientes.map((r) => (
  • - + {r.tipo === 'plan' ? : } {r.nombre ?? '—'} diff --git a/src/routes/_authenticated/planes.tsx b/src/routes/_authenticated/planes.tsx index affc653..cfbd754 100644 --- a/src/routes/_authenticated/planes.tsx +++ b/src/routes/_authenticated/planes.tsx @@ -1,5 +1,5 @@ import { createFileRoute, useRouter, Link } from "@tanstack/react-router" -import { useEffect, useMemo, useState } from "react" +import { useMemo, useState } from "react" import { supabase, useSupabaseAuth } from "@/auth/supabase" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" @@ -7,7 +7,6 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import * as Icons from "lucide-react" import { Plus, RefreshCcw, Building2, ScrollText, BookOpen } from "lucide-react" -import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" export type PlanDeEstudios = { id: string; nombre: string; nivel: string | null; duracion: string | null; @@ -38,6 +37,7 @@ export const Route = createFileRoute("/_authenticated/planes")({ if (error) throw new Error(error.message) return (data ?? []) as PlanRow[] }, + }) /* ---------- helpers de estilo suave ---------- */ @@ -62,10 +62,9 @@ function RouteComponent() { const [q, setQ] = useState("") const data = Route.useLoaderData() as PlanRow[] const router = useRouter() - const search = Route.useSearch<{ planId?: string }>() // usaremos ?planId=... para el modal const showFacultad = auth.claims?.role === "lci" || auth.claims?.role === "vicerrectoria" - const showCarrera = auth.claims?.role === "secretario_academico" + const showCarrera = showFacultad || auth.claims?.role === "secretario_academico" const filtered = useMemo(() => { const term = q.trim().toLowerCase() @@ -106,11 +105,7 @@ function RouteComponent() { return ( {showCarrera && p.carreras?.nombre && ( - + {p.carreras?.nombre} )} {showFacultad && fac?.nombre && ( - + {fac?.nombre} )} @@ -157,95 +152,6 @@ function RouteComponent() { )} - - {/* MODAL: se muestra si existe ?planId=... */} - - router.navigate({ to: "/planes", replace: true }) - } /> ) } - -/* ---------- Modal (carga ligera por id) ---------- */ -function PlanPreviewModal({ planId, onClose }: { planId?: string; onClose: () => void }) { - const [loading, setLoading] = useState(false) - const [plan, setPlan] = useState(null) - - useEffect(() => { - let alive = true - async function fetchPlan() { - if (!planId) return - setLoading(true) - const { data, error } = await supabase - .from("plan_estudios") - .select(` - id, nombre, nivel, duracion, total_creditos, estado, - carreras ( - nombre, - facultades:facultades ( nombre, color, icon ) - ) - `) - .eq("id", planId) - .single() - if (!alive) return - if (!error) setPlan(data as any) - setLoading(false) - } - fetchPlan() - return () => { alive = false } - }, [planId]) - - const fac = plan?.carreras?.facultades - const [r, g, b] = hexToRgb(fac?.color) - const headerStyle = { background: `linear-gradient(135deg, rgba(${r},${g},${b},.14), rgba(${r},${g},${b},.06))` } - - return ( - onClose()}> - -
    - - {plan?.nombre ?? "Cargando…"} -
    - {plan?.carreras?.nombre ?? "—"} {fac?.nombre ? `· ${fac?.nombre}` : ""} -
    -
    -
    - -
    - {loading &&
    Cargando…
    } - {!loading && plan && ( - <> -
    -
    Nivel: {plan.nivel ?? "—"}
    -
    Duración: {plan.duracion ?? "—"}
    -
    Créditos: {plan.total_creditos ?? "—"}
    -
    Estado: {plan.estado ?? "—"}
    -
    - -
    - - Ver ficha - - - Ver asignaturas - -
    - - )} -
    -
    -
    - ) -} diff --git a/src/routes/_authenticated/planes/$planId/modal.tsx b/src/routes/_authenticated/planes/$planId/modal.tsx index 2e1bf6f..27cf7b1 100644 --- a/src/routes/_authenticated/planes/$planId/modal.tsx +++ b/src/routes/_authenticated/planes/$planId/modal.tsx @@ -33,7 +33,7 @@ export const Route = createFileRoute("/_authenticated/planes/$planId/modal")({ .eq("id", params.planId) .single() if (error) throw error - return data as PlanDetail + return data }, })