| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 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<User>[] = [
- {
- id: 'select',
- header: ({ table }) => (
- <Checkbox
- checked={
- table.getIsAllPageRowsSelected() ||
- (table.getIsSomePageRowsSelected() && 'indeterminate')
- }
- onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
- aria-label='Select all'
- className='translate-y-0.5'
- />
- ),
- cell: ({ row }) => (
- <Checkbox
- checked={row.getIsSelected()}
- onCheckedChange={(value) => 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 }) => (
- <DataTableColumnHeader column={column} title='شناسه' />
- ),
- cell: ({ row }) => <div className='w-15'>#{row.original.id}</div>,
- enableSorting: true,
- },
- {
- accessorKey: 'username',
- header: ({ column }) => (
- <DataTableColumnHeader column={column} title='نام کاربری' />
- ),
- cell: ({ row }) => (
- <LongText className='max-w-36 ps-3'>{row.original.username}</LongText>
- ),
- 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 }) => (
- <DataTableColumnHeader column={column} title='نام کامل' />
- ),
- cell: ({ row }) => (
- <LongText className='max-w-40'>{row.original.full_name}</LongText>
- ),
- },
- {
- accessorKey: 'phone',
- header: ({ column }) => (
- <DataTableColumnHeader column={column} title='شماره موبایل' />
- ),
- cell: ({ row }) => <div dir='ltr'>{row.original.phone}</div>,
- },
- // {
- // accessorKey: 'email',
- // header: ({ column }) => (
- // <DataTableColumnHeader column={column} title='ایمیل' />
- // ),
- // cell: ({ row }) => (
- // <div className='text-nowrap'>{row.original.email ?? '-'}</div>
- // ),
- // },
- {
- accessorKey: 'subscription',
- header: ({ column }) => (
- <DataTableColumnHeader column={column} title='اشتراک' />
- ),
- cell: ({ row }) => (
- <div className='text-nowrap'>
- {row.original.subscription?.plan
- ? `${row.original.subscription?.plan?.type} (${planDurations[row.original.subscription?.plan?.duration]})`
- : '-'}
- </div>
- ),
- },
- {
- accessorKey: 'followers_count',
- header: ({ column }) => (
- <DataTableColumnHeader column={column} title='دنبالکننده' />
- ),
- cell: ({ row }) => (
- <Badge variant='secondary'>{row.original.followers_count}</Badge>
- ),
- },
- {
- accessorKey: 'created_at',
- header: ({ column }) => (
- <DataTableColumnHeader column={column} title='تاریخ عضویت' />
- ),
- cell: ({ row }) => {
- return (
- <div className='text-sm text-muted-foreground'>
- {new Date(row.original.created_at).toLocaleDateString('fa-IR')}
- </div>
- )
- },
- },
- {
- id: 'actions',
- cell: DataTableRowActions,
- enableSorting: false,
- enableHiding: false,
- },
- ]
|