"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 { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Badge, ChevronLeft, ChevronRight, Eye, MoreVertical, Search, 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 = { title: string; code: string; typeTask: string; category: string; date: string; status: string; }; import { data } from "./data"; import { Input } from "@/components/ui/input"; import { InputGroup, InputGroupText } from "@/components/ui/input-group"; import { Link } from "@/components/navigation"; export const columns: ColumnDef[] = [ { accessorKey: "title", header: "Judul", cell: ({ row }) => (

{row.getValue("title")}

), }, { accessorKey: "code", header: "Kode ", cell: ({ row }) => ( {row.getValue("code")} ), }, { accessorKey: "typeTask", header: "Kode ", cell: ({ row }) => ( {row.getValue("typeTask")} ), }, { accessorKey: "category", header: "Jenis Tugas ", cell: ({ row }) => ( {row.getValue("category")} ), }, { accessorKey: "date", header: "Tanggal Unggah ", cell: ({ row }) => ( {row.getValue("date")} ), }, { 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 Delete ); }, }, ]; const TaskTable = () => { 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.getColumn("status")?.setFilterValue(event.target.value) } className="max-w-sm " />
{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 TaskTable;