feat: ticket system base implementation

This commit is contained in:
2026-06-19 01:19:01 +05:30
parent a18fff4d6f
commit 8c3d19a429
19 changed files with 1400 additions and 27 deletions

View File

@@ -0,0 +1,60 @@
'use client';
import { useMemo } from 'react';
import type { ColumnDef } from '@tanstack/react-table';
import type { TicketListItem } from '@/types';
import { TicketStatusBadge } from './TicketStatusBadge';
function formatDate(value: string | null | undefined) {
if (!value) return '-';
return new Intl.DateTimeFormat('en-IN', {
dateStyle: 'medium',
timeStyle: 'short',
}).format(new Date(value));
}
export function useTicketColumns(): ColumnDef<TicketListItem>[] {
return useMemo(
() => [
{
accessorKey: 'id',
header: 'Ticket',
size: 180,
cell: ({ row }) => (
<span className="font-medium">{row.original.id}</span>
),
},
{
accessorKey: 'status',
header: 'Status',
size: 150,
cell: ({ row }) => <TicketStatusBadge status={row.original.status} />,
},
{
accessorKey: 'detection_count',
header: 'Detections',
size: 120,
},
{
accessorKey: 'assigned_to_email',
header: 'Assigned To',
size: 220,
cell: ({ row }) => row.original.assigned_to_email || '-',
},
{
accessorKey: 'created_by_email',
header: 'Uploaded By',
size: 220,
},
{
accessorKey: 'updated_at',
header: 'Updated',
size: 180,
cell: ({ row }) => formatDate(row.original.updated_at),
},
],
[],
);
}