"use client" import * as React from "react" import { ColumnDef, ColumnFiltersState, PaginationState, SortingState, VisibilityState, flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from "@tanstack/react-table" import { Button } from "@/components/ui/button" import { data } from "./data" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { ChevronLeft, ChevronRight, TrendingDown, TrendingUp } from "lucide-react" export type CompanyData = { company: string; category: string; views: number; revenue: string; sales: number; up: boolean; } export const columns: ColumnDef[] = [ { accessorKey: "company", header: "Company", cell: ({ row }) => (
SC

Biffco Enterprises Ltd.

Biffco@example.com
), }, { accessorKey: "category", header: "Category", cell: ({ row }) => ( {row.getValue("category")} ), }, { accessorKey: "sales", header: "Sales", cell: ({ row }) => (
{row.getValue("sales")} { row?.original.up ? : }
) }, { accessorKey: "views", header: "Views", cell: ({ row }) => ( {row.getValue("views")} ) }, { accessorKey: "revenue", header: "Revenue", cell: ({ row }) => ( {row.getValue("revenue")} ) } ] const CompanyTable = () => { const [sorting, setSorting] = React.useState([]) const [columnFilters, setColumnFilters] = React.useState([]) const [columnVisibility, setColumnVisibility] = React.useState({}) const [rowSelection, setRowSelection] = React.useState({}) const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize: 6, }) const table = useReactTable({ data, columns, onSortingChange: setSorting, onColumnFiltersChange: setColumnFilters, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), getFilteredRowModel: getFilteredRowModel(), onColumnVisibilityChange: setColumnVisibility, onRowSelectionChange: setRowSelection, onPaginationChange: setPagination, state: { sorting, columnFilters, columnVisibility, rowSelection, pagination }, }) return (
{table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( {header.isPlaceholder ? null : flexRender( header.column.columnDef.header, header.getContext() )} ))} ))} {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( {flexRender( cell.column.columnDef.cell, cell.getContext() )} ))} )) ) : ( No results. )}
{table.getPageOptions().map((page, pageIndex) => ( ))}
) } export default CompanyTable;