"use client" import * as React from "react" import Chart from "react-apexcharts"; 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 { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu" import { colors } from "@/lib/colors" export type TeamTableProps = { customer: { name: string; image: string; deg: string; }, status: "progress" | "complete"; time: string; chart: null; action:null; } const series = [ { data: [800, 600, 1000, 800, 600, 1000, 800, 900], } ]; const options: any = { chart: { toolbar: { autoSelected: "pan", show: false, }, offsetX: 0, offsetY: 0, zoom: { enabled: false, }, sparkline: { enabled: true, }, }, dataLabels: { enabled: false, }, stroke: { curve: "smooth", width: 2, }, colors: [colors.primary], tooltip: { theme: "dark", }, grid: { show: false, padding: { left: 0, right: 0, }, }, yaxis: { show: false, }, fill: { type: "solid", opacity: [0.1], }, legend: { theme: "dark", show: false, }, xaxis: { low: 0, offsetX: 0, offsetY: 0, show: false, labels: { low: 0, offsetX: 0, show: false, }, axisBorder: { low: 0, offsetX: 0, show: false, }, }, }; export const columns: ColumnDef[] = [ { accessorKey: "customer", header: "ASSIGNEE", cell: ({ row }) => (
SC
{row.original.customer.name}
), }, { accessorKey: "status", header: "status", enableSorting: false, cell: ({ row }) => { return (
{row.getValue("status") === "progress" && ( In progress )} {row.getValue("status") === "complete" && ( Complete )}
) } }, { accessorKey: "time", header: "Time", cell: ({ row }) => ( {row.getValue("time")} ) }, { accessorKey: "chart", header: "Chart", cell: ({ row }) => (
) }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { return (
View Edit Delete
) } } ] const TeamTable = ({ data }: any) => { 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. )}
) } export default TeamTable;