"use client"; import type { ColumnDef, ColumnFiltersState, SortingState, } from "@tanstack/react-table"; import { flexRender, getCoreRowModel, getFilteredRowModel, getSortedRowModel, useReactTable, } from "@tanstack/react-table"; import { ArrowUpDown, Search } from "lucide-react"; import { useState } from "react"; import type { CommunityPlugin } from "@/lib/community-plugins-data"; import { communityPlugins } from "@/lib/community-plugins-data"; const columns: ColumnDef[] = [ { accessorKey: "name", header: ({ column }) => { return ( ); }, cell: ({ row }) => { const author = row.original.author; return (
{row.original.name}
{author?.name} {author?.name}
); }, }, { accessorKey: "description", header: "Description", cell: ({ row }) => { return (
{row.original.description}
); }, }, ]; export function CommunityPluginsTable() { const [sorting, setSorting] = useState([]); const [columnFilters, setColumnFilters] = useState([]); const [globalFilter, setGlobalFilter] = useState(""); const table = useReactTable({ data: communityPlugins, columns, getCoreRowModel: getCoreRowModel(), getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel(), onSortingChange: setSorting, onColumnFiltersChange: setColumnFilters, onGlobalFilterChange: setGlobalFilter, state: { sorting, columnFilters, globalFilter, }, }); return (

Showing {table.getRowModel().rows.length} of {communityPlugins.length}{" "} plugins

setGlobalFilter(e.target.value)} className="w-full rounded-lg border bg-background pl-10 pr-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" />
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( ))} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( ))} )) ) : ( )}
{header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext(), )}
{flexRender( cell.column.columnDef.cell, cell.getContext(), )}
No plugins found.
); }