94 lines
2.3 KiB
TypeScript
94 lines
2.3 KiB
TypeScript
'use client'
|
|
|
|
import { type ColumnDef } from '@tanstack/react-table'
|
|
|
|
import { EllipsisVerticalIcon } from 'lucide-react'
|
|
|
|
import { Button } from '@repo/ui/components/ui/button'
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuTrigger
|
|
} from '@repo/ui/components/ui/dropdown-menu'
|
|
import { Abbr } from '@repo/ui/components/abbr'
|
|
import { Avatar, AvatarFallback } from '@repo/ui/components/ui/avatar'
|
|
import { initials } from '@repo/ui/lib/utils'
|
|
import {
|
|
DataTableColumnCpfCnpj,
|
|
DataTableColumnDatetime,
|
|
DataTableColumnHeaderSelect,
|
|
DataTableColumnSelect
|
|
} from '@repo/ui/components/data-table'
|
|
import type { Org } from '@repo/ui/routes/orgs/data'
|
|
|
|
import { CopyToClipboardItem } from '../_app.users._index/columns'
|
|
|
|
export type { Org }
|
|
|
|
export const columns: ColumnDef<Org>[] = [
|
|
{
|
|
id: 'select',
|
|
header: DataTableColumnHeaderSelect,
|
|
cell: DataTableColumnSelect
|
|
},
|
|
{
|
|
header: 'Empresa',
|
|
cell: ({ row }) => {
|
|
const { name, email } = row.original
|
|
|
|
return (
|
|
<div className="flex gap-2.5 items-center">
|
|
<Avatar className="size-10 hidden lg:block">
|
|
<AvatarFallback>{initials(name)}</AvatarFallback>
|
|
</Avatar>
|
|
|
|
<ul>
|
|
<li className="font-bold">
|
|
<Abbr>{name}</Abbr>
|
|
</li>
|
|
<li className="text-muted-foreground text-sm">
|
|
<Abbr>{email}</Abbr>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
)
|
|
}
|
|
},
|
|
{
|
|
accessorKey: 'cnpj',
|
|
header: 'CNPJ',
|
|
cell: DataTableColumnCpfCnpj
|
|
},
|
|
{
|
|
accessorKey: 'createDate',
|
|
header: 'Cadastrado em',
|
|
cell: DataTableColumnDatetime
|
|
},
|
|
{
|
|
id: 'actions',
|
|
cell: ActionMenu
|
|
}
|
|
]
|
|
|
|
function ActionMenu({ row }: { row: any }) {
|
|
return (
|
|
<div className="flex justify-end items-center">
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="ghost"
|
|
className="data-[state=open]:bg-muted text-muted-foreground cursor-pointer"
|
|
size="icon-sm"
|
|
>
|
|
<EllipsisVerticalIcon />
|
|
<span className="sr-only">Abrir menu</span>
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-36 *:cursor-pointer">
|
|
<CopyToClipboardItem text={row.id} />
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
)
|
|
}
|