{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kanban-03",
  "description": "A support queue of tickets with priority and time left to their SLA, where a full column refuses more tickets.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/kanban.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/kanban/kanban-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  KanbanAddCard,\n  KanbanAssignees,\n  KanbanBoard,\n  KanbanCard,\n  KanbanCardMenu,\n  KanbanCardTitle,\n  KanbanColumn,\n  type KanbanColumnDef,\n  type KanbanItem,\n  KanbanPriority,\n  type KanbanPriorityLevel,\n  getColumnItems,\n  moveItem,\n} from '@/registry/components/dashboardblocks/kanban'\nimport { StatusLabel } from '@/registry/components/dashboardblocks/status-label'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { useMemo, useState } from 'react'\n\ninterface Ticket extends KanbanItem {\n  assignee?: string\n  channel: 'chat' | 'email'\n  customer?: string\n  number: number\n  priority: KanbanPriorityLevel\n  slaDueAt: Date\n}\n\ninterface Kanban3Props extends BlockStateProps {\n  columns: KanbanColumnDef[]\n  /** Pass a fixed date, so SLA times render the same on the server and in the browser. */\n  now: Date\n  onAdd?: (ticket: Ticket) => Promise<void>\n  onMove?: (id: string, column: string, index: number) => void\n  pausedColumns: string[]\n  slaHours: number\n  /** Leave out, or pass none, to show the empty state. */\n  tickets?: Ticket[]\n  title: string\n}\n\nconst NOW = Date.UTC(2026, 8, 28, 10)\nconst noTickets: Ticket[] = []\n\nconst inMinutes = (minutes: number) => new Date(NOW + minutes * 60_000)\n\nconst exampleProps: Kanban3Props = {\n  columns: [\n    { color: 'var(--color-chart-3)', id: 'new', title: 'New' },\n    { color: 'var(--color-chart-2)', id: 'open', title: 'Open', wipLimit: 5 },\n    { color: 'var(--color-chart-5)', id: 'waiting', title: 'Waiting on customer' },\n    {\n      color: 'var(--color-destructive)',\n      id: 'escalated',\n      title: 'Escalated',\n      wipLimit: 2,\n    },\n    { color: 'var(--color-chart-4)', id: 'solved', title: 'Solved' },\n  ],\n  now: new Date(NOW),\n  pausedColumns: ['waiting', 'solved'],\n  slaHours: 8,\n  tickets: [\n    {\n      channel: 'email',\n      column: 'new',\n      customer: 'Grace Liu, Fernway',\n      id: 't4829',\n      number: 4829,\n      priority: 'high',\n      slaDueAt: inMinutes(35),\n      title: 'Invoices show the wrong VAT rate',\n    },\n    {\n      channel: 'chat',\n      column: 'new',\n      customer: 'Omar Haddad, Lumen Studio',\n      id: 't4831',\n      number: 4831,\n      priority: 'medium',\n      slaDueAt: inMinutes(210),\n      title: 'How do I add a second admin?',\n    },\n    {\n      assignee: 'Sofia Marin',\n      channel: 'email',\n      column: 'open',\n      customer: 'Dan Whitaker, Northwind',\n      id: 't4812',\n      number: 4812,\n      priority: 'urgent',\n      slaDueAt: inMinutes(-25),\n      title: 'SSO login loops back to the sign-in page',\n    },\n    {\n      assignee: 'Kwame Asante',\n      channel: 'chat',\n      column: 'open',\n      customer: 'Ines Duarte, Copperleaf',\n      id: 't4818',\n      number: 4818,\n      priority: 'high',\n      slaDueAt: inMinutes(50),\n      title: 'Export to Sheets stopped syncing',\n    },\n    {\n      assignee: 'Sofia Marin',\n      channel: 'email',\n      column: 'open',\n      customer: 'Helen Park, Brightline',\n      id: 't4820',\n      number: 4820,\n      priority: 'low',\n      slaDueAt: inMinutes(1_440),\n      title: 'Request for a copy of our DPA',\n    },\n    {\n      assignee: 'Kwame Asante',\n      channel: 'email',\n      column: 'waiting',\n      customer: 'Ravi Menon, Atlas Freight',\n      id: 't4806',\n      number: 4806,\n      priority: 'medium',\n      slaDueAt: inMinutes(300),\n      title: 'Webhook retries after a 200 response',\n    },\n    {\n      assignee: 'Mei Chen',\n      channel: 'chat',\n      column: 'escalated',\n      customer: 'Tom Byrne, Vantage Retail',\n      id: 't4801',\n      number: 4801,\n      priority: 'urgent',\n      slaDueAt: inMinutes(-90),\n      title: 'Orders missing from yesterday’s report',\n    },\n    {\n      assignee: 'Mei Chen',\n      channel: 'email',\n      column: 'escalated',\n      customer: 'Ana Souza, Kestrel Bank',\n      id: 't4809',\n      number: 4809,\n      priority: 'high',\n      slaDueAt: inMinutes(95),\n      title: 'Audit log gaps on Sep 26',\n    },\n    {\n      assignee: 'Sofia Marin',\n      channel: 'chat',\n      column: 'solved',\n      customer: 'Leo Grant, Halcyon Travel',\n      id: 't4797',\n      number: 4797,\n      priority: 'medium',\n      slaDueAt: inMinutes(-600),\n      title: 'Change the billing email',\n    },\n  ],\n  title: 'Support queue',\n}\n\nasync function saveTicket() {\n  await new Promise((resolve) => setTimeout(resolve, 300))\n}\n\nfunction formatSpan(minutes: number) {\n  if (minutes < 60) return `${minutes}m`\n  if (minutes < 1_440) return `${Math.round(minutes / 60)}h`\n  return `${Math.round(minutes / 1_440)}d`\n}\n\nfunction SlaLabel({ due, now, paused }: { due: Date; now: Date; paused: boolean }) {\n  const minutes = Math.round((due.getTime() - now.getTime()) / 60_000)\n  if (paused)\n    return (\n      <StatusLabel variant='text' className='text-xs' tone='neutral'>\n        SLA paused\n      </StatusLabel>\n    )\n  if (minutes < 0)\n    return (\n      <StatusLabel variant='text' className='text-xs tabular-nums' tone='bad'>\n        {formatSpan(-minutes)} over SLA\n      </StatusLabel>\n    )\n  return (\n    <StatusLabel\n      variant='text'\n      className='text-xs tabular-nums'\n      tone={minutes < 60 ? 'warning' : 'neutral'}\n    >\n      {formatSpan(minutes)} to SLA\n    </StatusLabel>\n  )\n}\n\nconst channelIcons = {\n  chat: (\n    <IconPlaceholder\n      lucide='MessageSquareIcon'\n      tabler='IconMessage'\n      hugeicons='MessageIcon'\n      phosphor='ChatCircleIcon'\n      remixicon='RiChat1Line'\n      aria-hidden\n    />\n  ),\n  email: (\n    <IconPlaceholder\n      lucide='MailIcon'\n      tabler='IconMail'\n      hugeicons='MailIcon'\n      phosphor='EnvelopeIcon'\n      remixicon='RiMailLine'\n      aria-hidden\n    />\n  ),\n}\n\nconst Kanban3 = (props: Kanban3Props) => {\n  const {\n    columns,\n    now,\n    onAdd = saveTicket,\n    onMove,\n    pausedColumns,\n    slaHours,\n    errorMessage,\n    status,\n    tickets: loadedTickets = noTickets,\n    title,\n  } = props\n  const [added, setAdded] = useState<Ticket[]>([])\n  const [moves, setMoves] = useState<{ column: string; id: string; index: number }[]>([])\n  const tickets = useMemo(\n    () =>\n      moves.reduce(\n        (current, move) => moveItem(current, move.id, move.column, move.index),\n        [...added, ...loadedTickets],\n      ),\n    [added, loadedTickets, moves],\n  )\n  const state = getBlockState(status, tickets)\n  const unsolved = tickets.filter((ticket) => !pausedColumns.includes(ticket.column))\n  const breached = unsolved.filter((ticket) => ticket.slaDueAt < now).length\n  const [firstColumn] = columns\n\n  async function add(ticketTitle: string) {\n    const number = Math.max(0, ...tickets.map((ticket) => ticket.number)) + 1\n    const ticket: Ticket = {\n      channel: 'email',\n      column: firstColumn.id,\n      id: `t${number}`,\n      number,\n      priority: 'medium',\n      slaDueAt: new Date(now.getTime() + slaHours * 3_600_000),\n      title: ticketTitle,\n    }\n    setAdded((current) => [ticket, ...current])\n    await onAdd(ticket)\n  }\n\n  const addTicket = (\n    <KanbanAddCard\n      label='Add ticket'\n      onAdd={(value) => void add(value)}\n      placeholder='Subject'\n    />\n  )\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <section className='@container flex flex-col gap-3'>\n        <header className='flex flex-col gap-0.5'>\n          <h2 className='font-semibold tracking-tight'>{title}</h2>\n          <BlockReady className='text-sm'>\n            <p className='text-muted-foreground text-sm'>\n              {unsolved.length} {unsolved.length === 1 ? 'ticket needs' : 'tickets need'}{' '}\n              a reply\n              {breached > 0 ? (\n                <>\n                  , and{' '}\n                  <StatusLabel variant='text' tone='bad'>\n                    {breached} {breached === 1 ? 'is' : 'are'} over SLA\n                  </StatusLabel>\n                  .\n                </>\n              ) : (\n                ', all within SLA.'\n              )}\n            </p>\n          </BlockReady>\n        </header>\n        {state === 'error' && <BlockStateRows className='border-t pt-3' />}\n        {state === 'empty' && (\n          <div className='flex flex-col gap-2 border-t pt-3'>\n            <BlockStateRows className='py-0' />\n            <div className='w-72 max-w-full'>{addTicket}</div>\n          </div>\n        )}\n        {(state === undefined || state === 'loading') && (\n          <KanbanBoard\n            className='pb-2'\n            columns={columns}\n            itemName={{ one: 'ticket', other: 'tickets' }}\n            items={tickets}\n            label={`${title} board`}\n            onMove={(id, column, index) => {\n              setMoves((current) => [...current, { column, id, index }])\n              onMove?.(id, column, index)\n            }}\n            wipLimitMode='block'\n          >\n            {columns.map((column) => (\n              <KanbanColumn\n                key={column.id}\n                column={column}\n                empty={column.id === 'escalated' ? 'Nothing escalated' : undefined}\n                footer={column.id === firstColumn.id && addTicket}\n              >\n                {getColumnItems(tickets, column.id).map((ticket) => (\n                  <KanbanCard key={ticket.id} item={ticket}>\n                    <div className='text-muted-foreground flex min-h-6 items-center gap-2 pr-7 text-xs [&_svg]:size-3.5'>\n                      {channelIcons[ticket.channel]}\n                      <span className='sr-only'>By {ticket.channel}, </span>\n                      <span className='font-mono'>#{ticket.number}</span>\n                      <KanbanPriority priority={ticket.priority} showLabel />\n                    </div>\n                    <div className='flex flex-col gap-0.5'>\n                      <KanbanCardTitle />\n                      <p className='text-muted-foreground truncate text-xs'>\n                        {ticket.customer ?? 'Added on the board'}\n                      </p>\n                    </div>\n                    <KanbanCardMenu className='absolute top-3 right-2' />\n                    {column.id !== 'solved' && (\n                      <div className='flex min-h-6 items-center gap-2'>\n                        <SlaLabel\n                          due={ticket.slaDueAt}\n                          now={now}\n                          paused={pausedColumns.includes(column.id)}\n                        />\n                        {ticket.assignee ? (\n                          <KanbanAssignees\n                            className='ml-auto'\n                            names={[ticket.assignee]}\n                          />\n                        ) : (\n                          <span className='text-muted-foreground ml-auto text-xs'>\n                            Unassigned\n                          </span>\n                        )}\n                      </div>\n                    )}\n                  </KanbanCard>\n                ))}\n              </KanbanColumn>\n            ))}\n          </KanbanBoard>\n        )}\n      </section>\n    </BlockStateProvider>\n  )\n}\n\nexport { Kanban3, exampleProps as kanban3ExampleProps, type Kanban3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/kanban/kanban-03.tsx"
    }
  ],
  "meta": {
    "shows": "A support queue of tickets with priority and time left to their SLA, where a full column refuses more tickets.",
    "size": "full",
    "usedWith": [
      "comments-04",
      "status-01"
    ],
    "component": "Kanban3",
    "props": "{ columns: { color?: string; icon?: ReactNode; id: string; title: string; wipLimit?: number }[]; now: Date; onAdd?: (ticket: { assignee?: string; channel: \"email\" | \"chat\"; customer?: string; number: number; priority: \"low\" | \"high\" | \"medium\" | \"urgent\"; slaDueAt: Date; column: string; id: string; title: string }) => Promise<void>; onMove?: (id: string, column: string, index: number) => void; pausedColumns: string[]; slaHours: number; tickets?: { assignee?: string; channel: \"email\" | \"chat\"; customer?: string; number: number; priority: \"low\" | \"high\" | \"medium\" | \"urgent\"; slaDueAt: Date; column: string; id: string; title: string }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
