import type { Member } from '@admin/types/auth' import type { ColumnDef } from '@tanstack/react-table' import { SortIndicator } from '@admin/components/shared/sort-indicator' import { Avatar, AvatarFallback } from '@admin/components/ui/avatar' import { Badge } from '@admin/components/ui/badge' import { Button } from '@admin/components/ui/button' import { getUserInitials } from '@admin/utils/user/get-user-initials' import { Edit, ShieldCheck } from 'lucide-react' import { EditRoleDialog } from './edit-role-dialog' import { TeamRowActions } from './team-row-actions' export const columns: ColumnDef[] = [ { accessorKey: 'email', meta: { label: 'Member' }, header: ({ column }) => { const sortDirection = column.getIsSorted() return ( ) }, cell: ({ row }) => { const email = row.getValue('email') as string const name = row.original.name return (
{getUserInitials(name || email)}
{name || 'N/A'}
{email}
) } }, { accessorKey: 'emailVerified', meta: { label: 'Status' }, header: 'Status', cell: ({ row }) => { const verified = row.getValue('emailVerified') as boolean return ( {verified ? ( Verified ) : ( Unverified )} ) } }, { accessorKey: 'role', meta: { label: 'Role' }, header: 'Role', cell: ({ row, table }) => { const role = row.getValue('role') as string const currentUser = table.options.meta?.currentUser const isCurrentUser = currentUser?.email === row.original.email if (isCurrentUser) { return ( {role} (you) ) } return ( {role} ) } }, { accessorKey: 'createdAt', meta: { label: 'Joined', mobile: 'labelled' }, header: ({ column }) => { const sortDirection = column.getIsSorted() return ( ) }, cell: ({ row }) => { const date = new Date(row.getValue('createdAt')) return (
{date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}
) } }, { id: 'actions', size: 80, enableResizing: false, meta: { width: '80px' }, cell: ({ row, table }) => (
) } ]