Skip to content
Niko Table

Support Tickets

A support inbox with quick views (Mine, Unassigned, At risk), SLA timers, priority and assignee filters, a priority submenu, and assign / solve actions in bulk or per ticket.

Built only from Niko Table pieces and shadcn/ui components. Install it, then swap the sample data for your own.

Installation

pnpm dlx shadcn@latest add @niko-table/tickets-table

Preview

npx shadcn@latest add @niko-table/tickets-table
tickets-table.tsx
"use client"
import * as React from "react"
import { DataTableRoot } from "@/components/niko-table/core/data-table-root"
import { DataTable } from "@/components/niko-table/core/data-table"
import {
DataTableBody,
DataTableEmptyBody,
DataTableHeader,
} from "@/components/niko-table/core/data-table-structure"
import { useDataTable } from "@/components/niko-table/core/data-table-context"
import { DataTableColumnHeader } from "@/components/niko-table/components/data-table-column-header"
import { DataTableColumnTitle } from "@/components/niko-table/components/data-table-column-title"
import { DataTableColumnSortMenu } from "@/components/niko-table/components/data-table-column-sort"
import { DataTableToolbarSection } from "@/components/niko-table/components/data-table-toolbar-section"
import { DataTableSearchFilter } from "@/components/niko-table/components/data-table-search-filter"
import { DataTableFacetedFilter } from "@/components/niko-table/components/data-table-faceted-filter"
import { DataTableClearFilter } from "@/components/niko-table/components/data-table-clear-filter"
import { DataTableViewMenu } from "@/components/niko-table/components/data-table-view-menu"
import { DataTableSelectionBar } from "@/components/niko-table/components/data-table-selection-bar"
import { DataTablePagination } from "@/components/niko-table/components/data-table-pagination"
import {
DataTableEmptyDescription,
DataTableEmptyFilteredMessage,
DataTableEmptyIcon,
DataTableEmptyMessage,
DataTableEmptyTitle,
} from "@/components/niko-table/components/data-table-empty-state"
import {
DataTableRowMenuScope,
RowMenuItem,
RowMenuSeparator,
RowMenuSub,
RowMenuSubContent,
RowMenuSubTrigger,
useDataTableRow,
} from "@/components/niko-table/components/data-table-row-menu"
import { DataTableRowContextMenuSlot } from "@/components/niko-table/components/data-table-row-context-menu-slot"
import { SYSTEM_COLUMN_IDS } from "@/components/niko-table/lib/constants"
import type { DataTableColumnDef } from "@/components/niko-table/types"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/niko-table/primitives/button"
import { Checkbox } from "@/components/niko-table/primitives/checkbox"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger,
} from "@/components/niko-table/primitives/dropdown-menu"
import {
ChevronDown,
ChevronsUp,
ChevronUp,
Clock,
Inbox,
Minus,
MoreHorizontal,
SearchX,
} from "lucide-react"
import { cn } from "@/lib/utils"
import {
agents,
CURRENT_AGENT,
priorityOptions,
slaOptions,
slaState,
statusOptions,
tickets as sampleTickets,
type Ticket,
type TicketPriority,
} from "./tickets-data"
import {
formatSla,
formatUpdated,
initials,
priorityStyle,
slaStyle,
} from "./tickets-format"
import { TicketViews } from "./ticket-views"
const priorityIcon: Record<
TicketPriority,
React.ComponentType<{ className?: string }>
> = {
urgent: ChevronsUp,
high: ChevronUp,
normal: Minus,
low: ChevronDown,
}
const priorityRank: Record<TicketPriority, number> = {
urgent: 0,
high: 1,
normal: 2,
low: 3,
}
const assigneeOptions = [
...agents.map(agent => ({ label: agent, value: agent })),
{ label: "Unassigned", value: "Unassigned" },
]
type Actions = {
assign: (ids: string[], agent: string) => void
setPriority: (id: string, priority: TicketPriority) => void
solve: (ids: string[]) => void
}
/*
* Row actions: one small piece per action, each reading its row from context.
* `TicketsTable` composes them into ONE fragment that both the "⋯" dropdown
* and the right-click menu render.
*/
function AssignToMeItem({ assign }: Pick<Actions, "assign">) {
const ticket = useDataTableRow<Ticket>()
return (
<RowMenuItem
disabled={ticket.assignee === CURRENT_AGENT || ticket.status === "solved"}
onClick={() => assign([ticket.id], CURRENT_AGENT)}
>
Assign to me
</RowMenuItem>
)
}
function PrioritySubmenu({ setPriority }: Pick<Actions, "setPriority">) {
const ticket = useDataTableRow<Ticket>()
return (
<RowMenuSub>
<RowMenuSubTrigger>Priority</RowMenuSubTrigger>
<RowMenuSubContent>
{priorityOptions.map(option => (
<RowMenuItem
key={option.value}
disabled={option.value === ticket.priority}
onClick={() =>
setPriority(ticket.id, option.value as TicketPriority)
}
>
{option.label}
</RowMenuItem>
))}
</RowMenuSubContent>
</RowMenuSub>
)
}
function SolveItem({ solve }: Pick<Actions, "solve">) {
const ticket = useDataTableRow<Ticket>()
return (
<RowMenuItem
disabled={ticket.status === "solved"}
onClick={() => solve([ticket.id])}
>
Mark as solved
</RowMenuItem>
)
}
function sortableHeader() {
return (
<DataTableColumnHeader>
<DataTableColumnTitle />
<DataTableColumnSortMenu />
</DataTableColumnHeader>
)
}
function Person({ name }: { name: string }) {
return (
<span className="flex items-center gap-2">
<Avatar className="size-6">
<AvatarFallback className="text-[10px]">
{initials(name)}
</AvatarFallback>
</Avatar>
<span className="truncate">{name}</span>
</span>
)
}
function useTicketColumns(rowMenu: React.ReactNode) {
return React.useMemo<DataTableColumnDef<Ticket>[]>(
() => [
{
id: SYSTEM_COLUMN_IDS.SELECT,
size: 40,
enableSorting: false,
enableHiding: false,
header: ({ table }) => (
<Checkbox
// Plain boolean: Radix and Base UI checkboxes take indeterminate differently.
checked={table.getIsAllPageRowsSelected()}
onCheckedChange={value => table.toggleAllPageRowsSelected(!!value)}
aria-label="Select all tickets on this page"
/>
),
cell: ({ row }) => (
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={value => row.toggleSelected(!!value)}
aria-label={`Select ticket ${row.original.id}`}
/>
),
},
{
accessorKey: "subject",
meta: { label: "Ticket" },
header: sortableHeader,
cell: ({ row }) => (
<div className="flex max-w-md min-w-0 flex-col">
<span className="flex items-center gap-2">
<span className="font-mono text-xs text-muted-foreground">
{row.original.id}
</span>
<span className="truncate font-medium">
{row.original.subject}
</span>
</span>
<span className="truncate text-xs text-muted-foreground">
{row.original.preview}
</span>
</div>
),
},
{
accessorKey: "requester",
meta: { label: "Requester" },
header: sortableHeader,
cell: ({ row }) => <Person name={row.original.requester} />,
},
{
accessorKey: "priority",
meta: { label: "Priority", options: priorityOptions },
header: sortableHeader,
enableColumnFilter: true,
// Sort by urgency, not alphabetically.
sortingFn: (a: { original: Ticket }, b: { original: Ticket }) =>
priorityRank[a.original.priority] - priorityRank[b.original.priority],
cell: ({ row }) => {
const Icon = priorityIcon[row.original.priority]
return (
<span
className={cn(
"flex items-center gap-1.5 capitalize",
priorityStyle[row.original.priority],
)}
>
<Icon className="size-4" aria-hidden="true" />
<span className="text-foreground">{row.original.priority}</span>
</span>
)
},
},
{
accessorKey: "status",
meta: { label: "Status", options: statusOptions },
header: sortableHeader,
enableColumnFilter: true,
cell: ({ row }) => (
<Badge
variant={row.original.status === "open" ? "default" : "secondary"}
className="capitalize"
>
{row.original.status}
</Badge>
),
},
{
id: "assignee",
accessorFn: ticket => ticket.assignee ?? "Unassigned",
meta: { label: "Assignee", options: assigneeOptions },
header: sortableHeader,
enableColumnFilter: true,
cell: ({ row }) =>
row.original.assignee ? (
<Person name={row.original.assignee} />
) : (
<span className="text-muted-foreground italic">Unassigned</span>
),
},
{
id: "sla",
// Solved tickets sort last.
accessorFn: ticket => ticket.slaMinutes ?? Number.MAX_SAFE_INTEGER,
meta: { label: "SLA" },
header: sortableHeader,
cell: ({ row }) => (
<span
className={cn(
"flex items-center gap-1.5 text-sm whitespace-nowrap tabular-nums",
slaStyle[slaState(row.original)],
)}
>
<Clock className="size-3.5" aria-hidden="true" />
{formatSla(row.original.slaMinutes)}
</span>
),
},
{
id: "slaState",
// Hidden: backs the "At risk" view and the SLA filter.
accessorFn: ticket => slaState(ticket),
meta: { label: "SLA status", options: slaOptions },
enableColumnFilter: true,
enableHiding: false,
},
{
accessorKey: "updatedAt",
meta: { label: "Updated" },
header: sortableHeader,
cell: ({ row }) => (
<span className="whitespace-nowrap text-muted-foreground tabular-nums">
{formatUpdated(row.original.updatedAt)}
</span>
),
},
{
id: "actions",
size: 56,
enableSorting: false,
enableHiding: false,
cell: ({ row }) => (
<div className="flex justify-end">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
className="size-8"
aria-label={`Open actions for ticket ${row.original.id}`}
>
<MoreHorizontal className="size-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DataTableRowMenuScope row={row.original} surface="dropdown">
{rowMenu}
</DataTableRowMenuScope>
</DropdownMenuContent>
</DropdownMenu>
</div>
),
},
],
[rowMenu],
)
}
function TicketsHeader() {
const { table } = useDataTable<Ticket>()
const rows = table.getCoreRowModel().rows.map(row => row.original)
const open = rows.filter(ticket => ticket.status !== "solved")
const breached = open.filter(ticket => slaState(ticket) === "breached")
return (
<div className="flex flex-col gap-0.5">
<h2 className="text-base font-semibold">Support inbox</h2>
<p className="text-sm text-muted-foreground">
{open.length} open ·{" "}
<span className={cn(breached.length > 0 && "text-destructive")}>
{breached.length} past SLA
</span>{" "}
· {open.filter(ticket => ticket.assignee === null).length} unassigned
</p>
</div>
)
}
function TicketsSelectionBar({ assign, solve }: Omit<Actions, "setPriority">) {
const { table } = useDataTable<Ticket>()
const selected = table
.getFilteredSelectedRowModel()
.rows.map(row => row.original)
const ids = selected
.filter(ticket => ticket.status !== "solved")
.map(ticket => ticket.id)
return (
<DataTableSelectionBar
selectedCount={selected.length}
onClear={() => table.resetRowSelection()}
>
<Button
size="sm"
variant="outline"
disabled={ids.length === 0}
onClick={() => {
assign(ids, CURRENT_AGENT)
table.resetRowSelection()
}}
>
Assign to me
</Button>
<Button
size="sm"
variant="outline"
disabled={ids.length === 0}
onClick={() => {
solve(ids)
table.resetRowSelection()
}}
>
Mark solved
</Button>
</DataTableSelectionBar>
)
}
export default function TicketsTable() {
const [tickets, setTickets] = React.useState(sampleTickets)
const [lastAction, setLastAction] = React.useState("")
const update = React.useCallback(
(ids: string[], change: (ticket: Ticket) => Ticket) =>
setTickets(rows =>
rows.map(row => (ids.includes(row.id) ? change(row) : row)),
),
[],
)
const actions = React.useMemo<Actions>(
() => ({
assign: (ids, agent) => {
update(ids, ticket => ({ ...ticket, assignee: agent }))
setLastAction(
`Assigned ${ids.length === 1 ? ids[0] : `${ids.length} tickets`} to ${agent}`,
)
},
setPriority: (id, priority) => {
update([id], ticket => ({ ...ticket, priority }))
setLastAction(`${id} is now ${priority} priority`)
},
solve: ids => {
update(ids, ticket => ({
...ticket,
status: "solved",
slaMinutes: null,
}))
setLastAction(
`Solved ${ids.length === 1 ? ids[0] : `${ids.length} tickets`}`,
)
},
}),
[update],
)
// The row actions, composed ONCE and mounted in both the "⋯" dropdown and
// the right-click menu.
const rowMenu = React.useMemo(
() => (
<>
<AssignToMeItem assign={actions.assign} />
<PrioritySubmenu setPriority={actions.setPriority} />
<RowMenuSeparator />
<SolveItem solve={actions.solve} />
</>
),
[actions],
)
const columns = useTicketColumns(rowMenu)
return (
<div className="w-full rounded-xl border bg-card p-4 text-card-foreground shadow-sm">
<DataTableRoot
data={tickets}
columns={columns}
getRowId={ticket => ticket.id}
initialState={{
columnVisibility: { slaState: false },
sorting: [{ id: "sla", desc: false }],
}}
>
<div className="flex flex-col gap-4">
<div className="flex flex-wrap items-start justify-between gap-3">
<TicketsHeader />
<TicketViews />
</div>
<DataTableToolbarSection className="flex-wrap px-0">
<DataTableSearchFilter
placeholder="Search tickets..."
className="min-w-48 flex-none sm:w-64"
/>
<DataTableFacetedFilter accessorKey="priority" multiple />
<DataTableFacetedFilter accessorKey="status" multiple />
<DataTableFacetedFilter accessorKey="assignee" multiple />
{/* Sorting has a default (most urgent first), so Reset only clears filters. */}
<DataTableClearFilter enableResetSorting={false} />
<div className="ml-auto">
<DataTableViewMenu />
</div>
</DataTableToolbarSection>
<TicketsSelectionBar assign={actions.assign} solve={actions.solve} />
<DataTable>
<DataTableHeader />
<DataTableBody>
<DataTableRowContextMenuSlot>
{rowMenu}
</DataTableRowContextMenuSlot>
<DataTableEmptyBody>
<DataTableEmptyMessage>
<DataTableEmptyIcon>
<Inbox className="size-12" />
</DataTableEmptyIcon>
<DataTableEmptyTitle>Inbox zero</DataTableEmptyTitle>
<DataTableEmptyDescription>
No tickets right now. New ones land here.
</DataTableEmptyDescription>
</DataTableEmptyMessage>
<DataTableEmptyFilteredMessage>
<DataTableEmptyIcon>
<SearchX className="size-12" />
</DataTableEmptyIcon>
<DataTableEmptyTitle>No matching tickets</DataTableEmptyTitle>
<DataTableEmptyDescription>
Try another view, or clear the filters.
</DataTableEmptyDescription>
</DataTableEmptyFilteredMessage>
</DataTableEmptyBody>
</DataTableBody>
</DataTable>
<DataTablePagination />
{lastAction && (
<p className="text-xs text-muted-foreground" aria-live="polite">
{lastAction}
</p>
)}
</div>
</DataTableRoot>
</div>
)
}
ticket-views.tsx
"use client"
import { useDataTable } from "@/components/niko-table/core/data-table-context"
import {
FILTER_OPERATORS,
FILTER_VARIANTS,
JOIN_OPERATORS,
} from "@/components/niko-table/lib/constants"
import { Button } from "@/components/niko-table/primitives/button"
import { ButtonGroup } from "@/components/ui/button-group"
import { CURRENT_AGENT, type Ticket } from "./tickets-data"
/** One preset filter per view: column id → values (empty = show everything). */
const views = {
all: {},
mine: { assignee: [CURRENT_AGENT] },
unassigned: { assignee: ["Unassigned"] },
"at-risk": { slaState: ["breached", "at-risk"] },
solved: { status: ["solved"] },
} satisfies Record<string, Record<string, string[]>>
type View = keyof typeof views
const labels: Record<View, string> = {
all: "All",
mine: "Mine",
unassigned: "Unassigned",
"at-risk": "At risk",
solved: "Solved",
}
/** Same shape the toolbar's faceted filters write, so both stay in sync. */
function toFilters(view: View) {
return Object.entries(views[view]).map(([id, value]) => ({
id,
value: {
id,
value,
variant: FILTER_VARIANTS.MULTI_SELECT,
operator: FILTER_OPERATORS.IN,
filterId: `faceted-${id}`,
joinOperator: JOIN_OPERATORS.AND,
},
}))
}
function filterValues(value: unknown): string[] | undefined {
const inner = (value as { value?: unknown } | undefined)?.value
return Array.isArray(inner) ? inner.map(String) : undefined
}
/** Quick views: preset filters, highlighted while the filters match one. */
export function TicketViews() {
const { table } = useDataTable<Ticket>()
const current = table.state.columnFilters
const active = (Object.keys(views) as View[]).find(view => {
const wanted = Object.entries(views[view]) as [string, string[]][]
return (
wanted.length === current.length &&
wanted.every(([id, values]) => {
const got = filterValues(current.find(f => f.id === id)?.value)
return (
got?.length === values.length && values.every(v => got.includes(v))
)
})
)
})
// Plain buttons, not ToggleGroup: Radix and Base UI ToggleGroups take
// different value shapes (string vs string[]).
return (
<ButtonGroup aria-label="Ticket views">
{(Object.keys(views) as View[]).map(view => (
<Button
key={view}
size="sm"
variant={view === active ? "secondary" : "outline"}
aria-pressed={view === active}
onClick={() => {
table.setColumnFilters(toFilters(view))
table.setPageIndex(0)
}}
>
{labels[view]}
</Button>
))}
</ButtonGroup>
)
}
tickets-format.ts
import type { SlaState, TicketPriority } from "./tickets-data"
import { NOW } from "./tickets-data"
function duration(minutes: number) {
const m = Math.abs(Math.round(minutes))
if (m < 60) return `${m}m`
const h = Math.floor(m / 60)
if (h < 24) return m % 60 ? `${h}h ${m % 60}m` : `${h}h`
return `${Math.floor(h / 24)}d`
}
/** "Due in 1h 20m", "Breached 35m ago", "Met". */
export function formatSla(slaMinutes: number | null) {
if (slaMinutes === null) return "Met"
return slaMinutes < 0
? `Breached ${duration(slaMinutes)} ago`
: `Due in ${duration(slaMinutes)}`
}
/** "12m ago", "3h ago", "2d ago", relative to the sample data's NOW. */
export function formatUpdated(date: Date) {
return `${duration((NOW.getTime() - date.getTime()) / 60_000)} ago`
}
export const slaStyle: Record<SlaState, string> = {
breached: "text-destructive",
"at-risk": "text-warning",
"on-track": "text-muted-foreground",
met: "text-success",
}
export const priorityStyle: Record<TicketPriority, string> = {
urgent: "text-destructive",
high: "text-warning",
normal: "text-muted-foreground",
low: "text-muted-foreground",
}
export function initials(name: string) {
return name
.split(" ")
.filter(Boolean)
.map(part => part[0]?.toUpperCase())
.slice(0, 2)
.join("")
}
tickets-data.ts
export type TicketPriority = "urgent" | "high" | "normal" | "low"
export type TicketStatus = "open" | "pending" | "solved"
export type SlaState = "breached" | "at-risk" | "on-track" | "met"
export type Ticket = {
id: string
subject: string
preview: string
requester: string
email: string
priority: TicketPriority
status: TicketStatus
/** Agent name, or null while unassigned. */
assignee: string | null
tags: string[]
updatedAt: Date
/** Minutes until the response SLA is due (negative once breached); null when solved. */
slaMinutes: number | null
}
/** The agent viewing the inbox ("Assign to me", the "Mine" view). */
export const CURRENT_AGENT = "Riley Park"
export const agents = [CURRENT_AGENT, "Maya Chen", "Tomás Ibarra", "Ngozi Eze"]
/** Fixed "now" for the sample data, so relative times never drift. */
export const NOW = new Date(Date.UTC(2026, 10, 2, 15, 0))
export const priorityOptions = [
{ label: "Urgent", value: "urgent" },
{ label: "High", value: "high" },
{ label: "Normal", value: "normal" },
{ label: "Low", value: "low" },
]
export const statusOptions = [
{ label: "Open", value: "open" },
{ label: "Pending", value: "pending" },
{ label: "Solved", value: "solved" },
]
export const slaOptions = [
{ label: "Breached", value: "breached" },
{ label: "At risk", value: "at-risk" },
{ label: "On track", value: "on-track" },
{ label: "Met", value: "met" },
]
export function slaState(ticket: Pick<Ticket, "slaMinutes">): SlaState {
const { slaMinutes } = ticket
if (slaMinutes === null) return "met"
if (slaMinutes < 0) return "breached"
return slaMinutes <= 120 ? "at-risk" : "on-track"
}
/**
* Sample data, generated rather than hand-written. A seeded PRNG (mulberry32)
* keeps it random-looking but identical on every render. Swap `tickets` for
* your own rows.
*/
function seededRandom(seed: number) {
let a = seed
return () => {
a = (a + 0x6d2b79f5) | 0
let t = Math.imul(a ^ (a >>> 15), 1 | a)
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
}
}
const topics = [
{
subject: "Password reset email never arrives",
preview: "I've requested a reset three times and checked spam.",
tags: ["login"],
},
{
subject: "Invoice shows the wrong VAT number",
preview:
"Our VAT ID changed last month but invoices still show the old one.",
tags: ["billing"],
},
{
subject: "CSV export is missing the notes column",
preview: "Exports from the projects view drop the notes field.",
tags: ["export", "bug"],
},
{
subject: "SSO sign-in loops back to the login page",
preview: "After the Okta redirect we land on the sign-in screen again.",
tags: ["sso", "login"],
},
{
subject: "Webhook deliveries failing with 401",
preview: "Every delivery since this morning returns Unauthorized.",
tags: ["api", "bug"],
},
{
subject: "How do I add more seats?",
preview: "We're onboarding six people next week.",
tags: ["billing"],
},
{
subject: "Dashboard takes 20s to load",
preview: "Only the analytics tab, other pages are fine.",
tags: ["performance"],
},
{
subject: "Charged twice this month",
preview: "Two identical charges on the 1st.",
tags: ["billing", "refund"],
},
{
subject: "Question about API rate limits",
preview: "Are limits per key or per workspace?",
tags: ["api"],
},
{
subject: "Mobile app crashes when uploading photos",
preview: "Happens on Android 15 with images over 10 MB.",
tags: ["mobile", "bug"],
},
{
subject: "Transfer account ownership",
preview: "Our admin left the company; I need owner access.",
tags: ["account"],
},
{
subject: "Data import stuck at 90%",
preview: "The import has shown 90% for two hours.",
tags: ["import", "bug"],
},
]
const firstNames = [
"Alma",
"Ben",
"Carmen",
"Dmitri",
"Esi",
"Felix",
"Gwen",
"Hiro",
"Isla",
"Jalen",
"Kira",
"Luca",
"Marta",
"Noor",
"Otto",
"Priya",
]
const lastNames = [
"Andersen",
"Bauer",
"Chowdhury",
"Dlamini",
"Engel",
"Ferreira",
"Gallo",
"Hayes",
"Ivanova",
"Joshi",
"Kovac",
"Lam",
"Mensah",
"Nolan",
"Ortiz",
"Park",
]
function generateTickets(count: number, seed: number): Ticket[] {
const random = seededRandom(seed)
const pick = <T>(items: readonly T[]) =>
items[Math.floor(random() * items.length)]
return (
Array.from({ length: count }, () => {
const topic = pick(topics)
const first = pick(firstNames)
const last = pick(lastNames)
const priorityRoll = random()
const priority: TicketPriority =
priorityRoll < 0.1
? "urgent"
: priorityRoll < 0.35
? "high"
: priorityRoll < 0.8
? "normal"
: "low"
const statusRoll = random()
const status: TicketStatus =
statusRoll < 0.5 ? "open" : statusRoll < 0.75 ? "pending" : "solved"
// Tighter SLAs for higher priority: urgent 1h, high 4h, normal 8h, low 24h.
const slaHours = { urgent: 1, high: 4, normal: 8, low: 24 }[priority]
const ageMinutes = Math.floor(random() ** 1.5 * slaHours * 60 * 1.25)
const unassigned = status === "open" && random() < 0.35
return {
id: "",
subject: topic.subject,
preview: topic.preview,
requester: `${first} ${last}`,
email: `${first}.${last}`.toLowerCase() + "@example.com",
priority,
status,
assignee: unassigned ? null : pick(agents),
tags: topic.tags,
updatedAt: new Date(NOW.getTime() - ageMinutes * 60_000),
slaMinutes: status === "solved" ? null : slaHours * 60 - ageMinutes,
}
})
.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())
// Number after sorting so newer tickets have higher numbers.
.map((ticket, i) => ({ ...ticket, id: `TCK-${1240 + count - i}` }))
)
}
export const tickets = generateTickets(42, 1242)

Usage

The files land in components/tickets-table/. Render the block anywhere:

import SupportTickets from "@/components/tickets-table/tickets-table"
export default function Page() {
return <SupportTickets />
}

Then replace the generated rows in tickets-data.ts with your own data, or load it from your API and pass it in.