'use client' import { ColumnDef, ColumnFiltersState, flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, SortingState, useReactTable, VisibilityState, } from '@tanstack/react-table' import { ChevronDown, MoreVertical } from 'lucide-react' import * as React from 'react' import { Button, Card, Checkbox, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Input, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from 'ui' import { TanStackTableHeadSort } from 'ui-patterns/Table' const data: Payment[] = [ { id: 'm5gr84i9', amount: 316, status: 'success', email: 'wallace@example.com', }, { id: '3u1reuv4', amount: 242, status: 'success', email: 'wendolene@example.com', }, { id: 'derv1ws0', amount: 837, status: 'processing', email: 'piella@example.com', }, { id: '5kma53ae', amount: 874, status: 'success', email: 'victor@example.com', }, { id: 'bhqecj4p', amount: 721, status: 'failed', email: 'feathers@example.com', }, ] export type Payment = { id: string amount: number status: 'pending' | 'processing' | 'success' | 'failed' email: string } export const columns: ColumnDef[] = [ { id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" /> ), enableSorting: false, enableHiding: false, }, { accessorKey: 'status', header: ({ column }) => Status, enableSorting: true, cell: ({ row }) =>
{row.getValue('status')}
, }, { accessorKey: 'email', header: ({ column }) => Email, enableSorting: true, cell: ({ row }) =>
{row.getValue('email')}
, }, { accessorKey: 'amount', header: ({ column }) => ( Amount ), enableSorting: true, cell: ({ row }) => { const amount = parseFloat(row.getValue('amount')) // Format the amount as a dollar amount const formatted = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', }).format(amount) return
{formatted}
}, }, { id: 'actions', enableHiding: false, header: () => Actions, cell: ({ row }) => { const payment = row.original return ( {table .getAllColumns() .filter((column) => column.getCanHide()) .map((column) => { return ( column.toggleVisibility(!!value)} > {column.id} ) })} {/* Table */} {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => { const columnId = header.column.id const sort = header.column.getIsSorted() return ( {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 found

Your search did not return any results

)}
{/* Count and pagination controls */}
{table.getFilteredSelectedRowModel().rows.length} of{' '} {table.getFilteredRowModel().rows.length} row(s) selected
) }