import { useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { DashboardLayout } from "@/layouts/dashboard-layout"; import { DataTable } from "@/components/ui/data-table"; import { Button } from "@/components/ui/button"; import { Plus, FileDown, FileUp } from "lucide-react"; import { AdGroup, LdapConnection } from "@shared/schema"; import { Badge } from "@/components/ui/badge"; export default function GroupsPage() { const [selectedConnection, setSelectedConnection] = useState(null); const [pageIndex, setPageIndex] = useState(0); const [pageSize, setPageSize] = useState(10); const { data: connections = [], isLoading: isLoadingConnections } = useQuery({ queryKey: ["/api/ldap-connections"], }); const { data: groups = [], isLoading: isLoadingGroups } = useQuery({ queryKey: [ `/api/connections/${selectedConnection}/ad-groups`, { select: "id,sAMAccountName,distinguishedName,description,groupType" } ], enabled: !!selectedConnection, }); const columns = [ { header: "Group Name", accessorKey: "sAMAccountName", }, { header: "Description", accessorKey: "description", }, { header: "Group Type", accessorKey: "groupType", }, { header: "Distinguished Name", accessorKey: "distinguishedName", cell: (row: AdGroup) => (
{row.distinguishedName}
), }, ]; return (
{connections.map((connection) => ( setSelectedConnection(connection.id)} > {connection.name} ))} {connections.length === 0 && !isLoadingConnections && (
No LDAP connections available. Add a connection first.
)}
); }