update tables

This commit is contained in:
2025-11-25 08:16:34 -03:00
parent 89b92948a6
commit d7fe03bd1f
23 changed files with 432 additions and 651 deletions

View File

@@ -1,9 +1,14 @@
'use client'
import { formatCPF } from '@brazilian-utils/brazilian-utils'
import { type ColumnDef } from '@tanstack/react-table'
import { Abbr } from '@repo/ui/components/abbr'
import {
DataTableColumnDatetime,
DataTableColumnSelect,
DataTableColumnCpfCnpj,
DataTableColumnHeaderSelect
} from '@repo/ui/components/data-table'
import { Avatar, AvatarFallback } from '@repo/ui/components/ui/avatar'
import { initials } from '@repo/ui/lib/utils'
@@ -16,15 +21,12 @@ export type User = {
cpf?: string
}
const formatted = new Intl.DateTimeFormat('pt-BR', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
})
export const columns: ColumnDef<User>[] = [
{
id: 'select',
header: DataTableColumnHeaderSelect,
cell: DataTableColumnSelect
},
{
header: 'Usuário',
cell: ({ row }) => {
@@ -49,37 +51,18 @@ export const columns: ColumnDef<User>[] = [
}
},
{
accessorKey: 'cpf',
header: 'CPF',
cell: ({ row }) => {
const { cpf } = row.original
if (cpf) {
return <>{formatCPF(cpf)}</>
}
return <></>
}
cell: DataTableColumnCpfCnpj
},
{
accessorKey: 'lastLogin',
header: 'Último accesso',
cell: ({ row }) => {
// Post-migration: rename `lastLogin` to `last_login`
if (row.original?.lastLogin) {
const lastLogin = new Date(row.original.lastLogin)
return formatted.format(lastLogin)
}
return <></>
}
cell: DataTableColumnDatetime
},
{
accessorKey: 'createDate',
header: 'Cadastrado em',
meta: {
className: 'w-1/12'
},
cell: ({ row }) => {
const created_at = new Date(row.original.createDate)
return formatted.format(created_at)
}
cell: DataTableColumnDatetime
}
]