diff --git a/src/routes/_authenticated/classes.$id.tsx b/src/routes/_authenticated/classes.$id.tsx new file mode 100644 index 0000000..7f20572 --- /dev/null +++ b/src/routes/_authenticated/classes.$id.tsx @@ -0,0 +1,46 @@ +import { createFileRoute, Link } from "@tanstack/react-router"; +import { useQuery } from "@tanstack/react-query"; +import { supabase } from "@/integrations/supabase/client"; +import { useAuth } from "@/hooks/use-auth"; +import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; +import { ArrowLeft, Lock, Loader2 } from "lucide-react"; +import { RosterManager, GradebookGrid, GradingConfigEditor } from "@/components/gradebook"; + +export const Route = createFileRoute("/_authenticated/classes/$id")({ + head: () => ({ meta: [{ title: "Class — School Portal" }] }), + component: ClassDetail, +}); + +function ClassDetail() { + const { id } = Route.useParams(); + const { user, roles } = useAuth(); + const isAdmin = roles.includes("admin"); + + const { data: cls, isLoading } = useQuery({ + queryKey: ["class", id], + queryFn: async () => (await supabase.from("classes").select("*").eq("id", id).single()).data, + }); + const isTeacher = !!cls && cls.teacher_id === user?.id; + const canEdit = isAdmin || isTeacher; + + if (isLoading) return
; + if (!canEdit) return

Not available

You don't have access to this class.

; + + return ( +
+ All classes +

{cls?.name}

+ + + + Gradebook + Roster + Grading setup + + + + + +
+ ); +}