import React from "react"; import { useNavigate } from "react-router-dom"; import type { TicketListItem } from "../../types/ticket"; interface TicketTableProps { tickets: TicketListItem[]; sortCol: keyof TicketListItem; sortDir: "asc" | "desc"; onSort: (col: keyof TicketListItem) => void; } const columns: { key: keyof TicketListItem; label: string }[] = [ { key: "ticket_id", label: "Ticket ID" }, { key: "priority", label: "Priority" }, { key: "title", label: "Title" }, { key: "category", label: "Category" }, { key: "type", label: "Type" }, { key: "status", label: "Status" }, { key: "created_at", label: "Created" }, { key: "updated_at", label: "Updated" }, ]; const TicketTable: React.FC = ({ tickets, sortCol, sortDir, onSort, }) => { const navigate = useNavigate(); return ( {columns.map((col) => ( ))} {tickets.length === 0 && ( )} {tickets.map((t) => ( ))}
onSort(col.key)} className={sortCol === col.key ? `sort-${sortDir}` : ""} > {col.label}
No tickets found
navigate(`/ticket/${t.ticket_id}`)} > {t.ticket_id} {t.priority} {t.title} {t.category} {t.type} {t.status} {new Date(t.created_at).toLocaleString()} {new Date(t.updated_at).toLocaleString()}
); }; export default TicketTable;