share route itens

This commit is contained in:
2025-11-24 19:11:20 -03:00
parent 4db2123bc5
commit 21840506b0
31 changed files with 460 additions and 703 deletions

View File

@@ -1,5 +1,7 @@
'use client'
import { columns as columns_, type Order } from '@repo/ui/routes/orders/columns'
import { formatCNPJ, formatCPF } from '@brazilian-utils/brazilian-utils'
import { type ColumnDef } from '@tanstack/react-table'
@@ -7,23 +9,7 @@ import { Abbr } from '@repo/ui/components/abbr'
import { Avatar, AvatarFallback } from '@repo/ui/components/ui/avatar'
import { initials } from '@repo/ui/lib/utils'
// This type is used to define the shape of our data.
// You can use a Zod schema here if you want.
export type Order = {
id: string
total: number
status: 'pending' | 'processing' | 'success' | 'failed'
payment_method: 'PIX' | 'CREDIT_CARD' | 'MANUAL' | 'failed'
name: string
}
const formatted = new Intl.DateTimeFormat('pt-BR', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
})
export type { Order }
export const columns: ColumnDef<Order>[] = [
{
@@ -65,54 +51,5 @@ export const columns: ColumnDef<Order>[] = [
return <></>
}
},
{
accessorKey: 'payment_method',
header: 'Forma de pag.'
},
{
accessorKey: 'status',
header: 'Status'
},
{
accessorKey: 'total',
header: 'Valor total',
cell: ({ row }) => {
const amount = parseFloat(row.getValue('total'))
const formatted = new Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL'
}).format(amount)
return <div className="font-medium">{formatted}</div>
}
},
{
header: 'Comprado em',
cell: ({ row }) => {
const createdAt = new Date(row.original.create_date)
return formatted.format(createdAt)
}
},
{
header: 'Vencimento em',
cell: ({ row }) => {
try {
const dueDate = new Date(row.original.due_date)
return formatted.format(dueDate)
} catch {
return 'N/A'
}
}
},
{
header: 'Pago em',
cell: ({ row }) => {
if (row.original.payment_date) {
const createdAt = new Date(row.original.payment_date)
return formatted.format(createdAt)
}
return <></>
}
}
...columns_
]