61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
'use client';
|
|
|
|
import { useMemo } from 'react';
|
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
|
|
import type { TicketListItem } from '@/types';
|
|
|
|
import { TicketStatusBadge } from './TicketStatusBadge';
|
|
import { formatDate } from '@/utils/date';
|
|
|
|
export function useTicketColumns(): ColumnDef<TicketListItem>[] {
|
|
return useMemo(
|
|
() => [
|
|
{
|
|
accessorKey: 'ticket_name',
|
|
header: 'Ticket',
|
|
size: 180,
|
|
cell: ({ row }) => (
|
|
<span className="font-medium">{row.original.ticket_name}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: 'status',
|
|
header: 'Status',
|
|
size: 150,
|
|
cell: ({ row }) => <TicketStatusBadge status={row.original.status} />,
|
|
},
|
|
{
|
|
accessorKey: 'chainage_name',
|
|
header: 'Segment',
|
|
size: 180,
|
|
cell: ({ row }) => row.original.chainage_name || 'N/A',
|
|
},
|
|
{
|
|
accessorKey: 'detection_count',
|
|
header: 'Detections',
|
|
size: 120,
|
|
},
|
|
{
|
|
accessorKey: 'assigned_to_name',
|
|
header: 'Assigned To',
|
|
size: 220,
|
|
cell: ({ row }) => row.original.assigned_to_name || 'N/A',
|
|
},
|
|
{
|
|
accessorKey: 'created_by_name',
|
|
header: 'Uploaded By',
|
|
size: 220,
|
|
cell: ({ row }) => row.original.created_by_name || 'N/A',
|
|
},
|
|
{
|
|
accessorKey: 'updated_at',
|
|
header: 'Updated',
|
|
size: 180,
|
|
cell: ({ row }) => formatDate(row.original.updated_at),
|
|
},
|
|
],
|
|
[],
|
|
);
|
|
}
|