import { ColumnDef } from '@tanstack/react-table' import { cn } from '@/lib/utils' import { Badge } from '@/components/ui/badge' import { Checkbox } from '@/components/ui/checkbox' import LongText from '@/components/long-text' import { callTypes, userTypes } from '../data/data' import { User } from '../data/schema' import { DataTableColumnHeader } from './data-table-column-header' import { DataTableRowActions } from './data-table-row-actions' export const columns: ColumnDef[] = [ { id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label='Select all' className='translate-y-[2px]' /> ), meta: { className: cn( 'sticky md:table-cell left-0 z-10 rounded-tl', 'bg-background transition-colors duration-200 group-hover/row:bg-muted group-data-[state=selected]/row:bg-muted' ), }, cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label='Select row' className='translate-y-[2px]' /> ), enableSorting: false, enableHiding: false, }, { accessorKey: 'username', header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue('username')} ), meta: { className: cn( 'drop-shadow-[0_1px_2px_rgb(0_0_0_/_0.1)] dark:drop-shadow-[0_1px_2px_rgb(255_255_255_/_0.1)] lg:drop-shadow-none', 'bg-background transition-colors duration-200 group-hover/row:bg-muted group-data-[state=selected]/row:bg-muted', 'sticky left-6 md:table-cell' ), }, enableHiding: false, }, { id: 'fullName', header: ({ column }) => ( ), cell: ({ row }) => { const { firstName, lastName } = row.original const fullName = `${firstName} ${lastName}` return {fullName} }, meta: { className: 'w-36' }, }, { accessorKey: 'email', header: ({ column }) => ( ), cell: ({ row }) => (
{row.getValue('email')}
), }, { accessorKey: 'phoneNumber', header: ({ column }) => ( ), cell: ({ row }) =>
{row.getValue('phoneNumber')}
, enableSorting: false, }, { accessorKey: 'status', header: ({ column }) => ( ), cell: ({ row }) => { const { status } = row.original const badgeColor = callTypes.get(status) return (
{row.getValue('status')}
) }, filterFn: (row, id, value) => { return value.includes(row.getValue(id)) }, enableHiding: false, enableSorting: false, }, { accessorKey: 'role', header: ({ column }) => ( ), cell: ({ row }) => { const { role } = row.original const userType = userTypes.find(({ value }) => value === role) if (!userType) { return null } return (
{userType.icon && ( )} {row.getValue('role')}
) }, filterFn: (row, id, value) => { return value.includes(row.getValue(id)) }, enableSorting: false, enableHiding: false, }, { id: 'actions', cell: DataTableRowActions, }, ]