'use client' import type { WebhookDeliveryEntry } from '@admin/actions/webhooks' import type { ColumnDef } from '@tanstack/react-table' import { SortIndicator } from '@admin/components/shared/sort-indicator' import { Badge } from '@admin/components/ui/badge' import { Button } from '@admin/components/ui/button' import { formatDistanceToNow } from 'date-fns' export const logsColumns: ColumnDef[] = [ { accessorKey: 'statusCode', size: 110, header: ({ column }) => { const sortDirection = column.getIsSorted() const sortLabel = sortDirection === 'asc' ? 'sorted ascending' : sortDirection === 'desc' ? 'sorted descending' : 'not sorted' return ( ) }, cell: ({ row }) => ( {row.original.statusCode ?? 'error'} ) }, { accessorKey: 'event', size: 260, header: ({ column }) => { const sortDirection = column.getIsSorted() const sortLabel = sortDirection === 'asc' ? 'sorted ascending' : sortDirection === 'desc' ? 'sorted descending' : 'not sorted' return ( ) }, cell: ({ row }) => {row.original.event} }, { accessorKey: 'webhookName', size: 220, header: ({ column }) => { const sortDirection = column.getIsSorted() const sortLabel = sortDirection === 'asc' ? 'sorted ascending' : sortDirection === 'desc' ? 'sorted descending' : 'not sorted' return ( ) }, cell: ({ row }) => {row.original.webhookName} }, { accessorKey: 'attempt', size: 100, header: ({ column }) => { const sortDirection = column.getIsSorted() const sortLabel = sortDirection === 'asc' ? 'sorted ascending' : sortDirection === 'desc' ? 'sorted descending' : 'not sorted' return ( ) }, cell: ({ row }) => {row.original.attempt} }, { accessorKey: 'durationMs', size: 110, header: ({ column }) => { const sortDirection = column.getIsSorted() const sortLabel = sortDirection === 'asc' ? 'sorted ascending' : sortDirection === 'desc' ? 'sorted descending' : 'not sorted' return ( ) }, cell: ({ row }) => ( {row.original.durationMs} ms ) }, { accessorKey: 'createdAt', size: 160, header: ({ column }) => { const sortDirection = column.getIsSorted() const sortLabel = sortDirection === 'asc' ? 'sorted ascending' : sortDirection === 'desc' ? 'sorted descending' : 'not sorted' return ( ) }, cell: ({ row }) => ( {formatDistanceToNow(new Date(row.original.createdAt), { addSuffix: true })} ) } ]