import { type ColumnDef } from '@tanstack/react-table' import { cn } from '@/lib/utils' import { Badge } from '@/components/ui/badge' import { Checkbox } from '@/components/ui/checkbox' import { DataTableColumnHeader } from '@/components/data-table' import { LongText } from '@/components/long-text' import { type User } from '@/types/users.types' import { DataTableRowActions } from './data-table-row-actions' import { planDurations } from '@/constants/users/users-constants' export const usersColumns: ColumnDef[] = [ { id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label='Select all' className='translate-y-0.5' /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label='Select row' className='translate-y-0.5' /> ), enableSorting: false, enableHiding: false, meta: { className: cn('inset-s-0 z-10 rounded-tl-[inherit] max-md:sticky'), }, }, { accessorKey: 'id', header: ({ column }) => ( ), cell: ({ row }) =>
#{row.original.id}
, enableSorting: true, }, { accessorKey: 'username', header: ({ column }) => ( ), cell: ({ row }) => ( {row.original.username} ), enableHiding: false, 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)]', 'inset-s-6 ps-0.5 max-md:sticky', '@4xl/content:table-cell', '@4xl/content:drop-shadow-none' ), }, }, { accessorKey: 'full_name', header: ({ column }) => ( ), cell: ({ row }) => ( {row.original.full_name} ), }, { accessorKey: 'phone', header: ({ column }) => ( ), cell: ({ row }) =>
{row.original.phone}
, }, // { // accessorKey: 'email', // header: ({ column }) => ( // // ), // cell: ({ row }) => ( //
{row.original.email ?? '-'}
// ), // }, { accessorKey: 'subscription', header: ({ column }) => ( ), cell: ({ row }) => (
{row.original.subscription?.plan ? `${row.original.subscription?.plan?.type} (${planDurations[row.original.subscription?.plan?.duration]})` : '-'}
), }, { accessorKey: 'followers_count', header: ({ column }) => ( ), cell: ({ row }) => ( {row.original.followers_count} ), }, { accessorKey: 'created_at', header: ({ column }) => ( ), cell: ({ row }) => { return (
{new Date(row.original.created_at).toLocaleDateString('fa-IR')}
) }, }, { id: 'actions', cell: DataTableRowActions, enableSorting: false, enableHiding: false, }, ]