"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 { Badge, ChevronLeft, ChevronRight, Eye, MoreVertical, SquarePen, Trash2, TrendingDown, TrendingUp, } from "lucide-react"; import { cn } from "@/lib/utils"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export type CompanyData = { company: string; category: string; revenue: string; sales: number; status: string; up: boolean; }; export const columns: ColumnDef[] = [ { accessorKey: "company", header: "Judul", cell: ({ row }) => (
SC

Biffco Enterprises Ltd.

Biffco@example.com
), }, { accessorKey: "category", header: "Tanggal Unggah", cell: ({ row }) => ( {row.getValue("category")} ), }, { accessorKey: "sales", header: "Tipe Konten", cell: ({ row }) => (
{row.getValue("sales")} {row?.original.up ? ( ) : ( )}
), }, { accessorKey: "status", header: "Status", cell: ({ row }) => { const statusColors: Record = { paid: "bg-success/20 text-success", due: "bg-warning/20 text-warning", canceled: "bg-destructive/20 text-destructive", }; const status = row.getValue("status"); return ( {status} ); }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return ( View Edit Delete ); }, }, ]; 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;