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 { Button } from "@/components/ui/button"; import { Plus, ChevronRight } from "lucide-react"; export const Route = createFileRoute("/_authenticated/students")({ head: () => ({ meta: [{ title: "Students — School Portal" }] }), component: StudentsPage, }); function StudentsPage() { const { roles } = useAuth(); const isAdmin = roles.includes("admin"); const { data: students } = useQuery({ queryKey: ["students"], queryFn: async () => { const { data, error } = await supabase .from("students") .select("id, first_name, last_name, dob, allergies, photo_release, class_id, classes(name)") .order("last_name"); if (error) throw error; return data ?? []; }, }); return (
{students?.length ?? 0} students visible to you