{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pipeline-03",
  "description": "Items that have been in a stage longer than expected, longest first, with how long they have waited and who owns them.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/pipeline.json",
    "https://www.dashboardblocks.com/r/radix/table.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/pipeline/pipeline-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  PipelineAge,\n  type PipelineItem,\n  PipelineOwner,\n  type PipelineStage,\n  formatAge,\n  getDaysInStage,\n  isStuck,\n} from '@/registry/components/dashboardblocks/pipeline'\nimport {\n  DataTable,\n  DataTableBody,\n  DataTableCell,\n  DataTableHead,\n  DataTableHeader,\n  DataTableRow,\n  DataTableStateRows,\n} from '@/registry/components/dashboardblocks/table'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Pipeline3Props extends BlockStateProps {\n  /** Defaults to a sentence counting the stuck items and naming the one waiting longest. */\n  description?: string\n  /** Leave out, or pass none, to show the empty state. */\n  items?: PipelineItem[]\n  noun?: string\n  now: Date\n  stages: PipelineStage[]\n  title: string\n}\n\nconst NOW = Date.UTC(2026, 8, 25, 14, 30)\nconst daysAgo = (days: number) => new Date(NOW - days * 86_400_000)\n\nconst exampleProps: Pipeline3Props = {\n  items: [\n    {\n      enteredStageAt: daysAgo(2),\n      id: 'c1',\n      owner: 'Priya Nair',\n      ownerAvatar: '/images/avatar-02.webp',\n      stage: 'screen',\n      subtitle: 'Senior frontend engineer',\n      title: 'Daniel Okafor',\n    },\n    {\n      enteredStageAt: daysAgo(9),\n      id: 'c2',\n      owner: 'Priya Nair',\n      ownerAvatar: '/images/avatar-02.webp',\n      stage: 'screen',\n      subtitle: 'Product designer',\n      title: 'Sofia Lindqvist',\n    },\n    {\n      enteredStageAt: daysAgo(4),\n      id: 'c3',\n      owner: 'Tom Becker',\n      ownerAvatar: '/images/avatar-17.webp',\n      stage: 'interview',\n      subtitle: 'Data engineer',\n      title: 'Ravi Menon',\n    },\n    {\n      enteredStageAt: daysAgo(15),\n      id: 'c4',\n      owner: 'Tom Becker',\n      ownerAvatar: '/images/avatar-17.webp',\n      stage: 'interview',\n      subtitle: 'Senior frontend engineer',\n      title: 'Hannah Cole',\n    },\n    {\n      enteredStageAt: daysAgo(11),\n      id: 'c5',\n      owner: 'Grace Kim',\n      ownerAvatar: '/images/avatar-11.webp',\n      stage: 'interview',\n      subtitle: 'Engineering manager',\n      title: 'Marco Bianchi',\n    },\n    {\n      enteredStageAt: daysAgo(6),\n      id: 'c6',\n      owner: 'Grace Kim',\n      ownerAvatar: '/images/avatar-11.webp',\n      stage: 'feedback',\n      subtitle: 'Product designer',\n      title: 'Amara Diallo',\n    },\n    {\n      enteredStageAt: daysAgo(1),\n      id: 'c7',\n      owner: 'Tom Becker',\n      ownerAvatar: '/images/avatar-17.webp',\n      stage: 'feedback',\n      subtitle: 'Data engineer',\n      title: 'Leo Martins',\n    },\n    {\n      enteredStageAt: daysAgo(8),\n      id: 'c8',\n      owner: 'Priya Nair',\n      ownerAvatar: '/images/avatar-02.webp',\n      stage: 'offer',\n      subtitle: 'Support lead',\n      title: 'Nora Haddad',\n    },\n    {\n      enteredStageAt: daysAgo(3),\n      id: 'c9',\n      owner: 'Grace Kim',\n      ownerAvatar: '/images/avatar-11.webp',\n      stage: 'offer',\n      subtitle: 'Senior frontend engineer',\n      title: 'Ethan Brooks',\n    },\n  ],\n  noun: 'candidates',\n  now: new Date(NOW),\n  stages: [\n    { expectedDays: 5, id: 'screen', label: 'Phone screen' },\n    { expectedDays: 10, id: 'interview', label: 'Interviews' },\n    { expectedDays: 3, id: 'feedback', label: 'Feedback' },\n    { expectedDays: 5, id: 'offer', label: 'Offer out' },\n  ],\n  title: 'Stuck candidates',\n}\n\nconst Pipeline3 = (props: Pipeline3Props) => {\n  const { items = [], noun = 'items', now, stages, errorMessage, status, title } = props\n  const state = getBlockState(status, items)\n  const stageById = new Map(stages.map((stage) => [stage.id, stage]))\n\n  const stuck = items\n    .map((item) => {\n      const stage = stageById.get(item.stage)\n      const days = getDaysInStage(item.enteredStageAt, now)\n      return { days, item, stage }\n    })\n    .filter(({ days, stage }) => stage && isStuck(days, stage.expectedDays))\n    .sort(\n      (a, b) =>\n        b.days / (b.stage?.expectedDays || 1) - a.days / (a.stage?.expectedDays || 1),\n    )\n\n  const longest = stuck[0]\n  const {\n    description = longest\n      ? `${stuck.length} of ${items.length} ${noun} past their stage’s time limit; ${longest.item.title} is ${formatAge(longest.days - (longest.stage?.expectedDays ?? 0), 'long')} over.`\n      : `All ${items.length} ${noun} are within their stage’s time limit.`,\n  } = props\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container/data-table 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'>{description}</p>\n              </BlockReady>\n            </header>\n            {!state && stuck.length === 0 ? (\n              <p className='text-muted-foreground flex items-center gap-2 border-t pt-4 text-sm'>\n                <IconPlaceholder\n                  lucide='CircleCheckIcon'\n                  tabler='IconCircleCheck'\n                  hugeicons='CheckmarkCircle02Icon'\n                  phosphor='CheckCircleIcon'\n                  remixicon='RiCheckboxCircleLine'\n                  aria-hidden\n                  className='size-4 text-emerald-700 dark:text-emerald-400'\n                />\n                Nothing is stuck.\n              </p>\n            ) : (\n              <DataTable caption={`${title}: ${description}`}>\n                <DataTableHeader>\n                  <DataTableRow>\n                    <DataTableHead>Name</DataTableHead>\n                    <DataTableHead>Stage</DataTableHead>\n                    <DataTableHead>In stage</DataTableHead>\n                    <DataTableHead>Over by</DataTableHead>\n                    <DataTableHead>Owner</DataTableHead>\n                  </DataTableRow>\n                </DataTableHeader>\n                <DataTableBody>\n                  <DataTableStateRows colSpan={5} rows={3} />\n                  {!state &&\n                    stuck.map(({ days, item, stage }) => {\n                      const expected = stage?.expectedDays ?? 0\n                      return (\n                        <DataTableRow key={item.id}>\n                          <DataTableCell primary truncate>\n                            <span className='block truncate'>{item.title}</span>\n                            {item.subtitle && (\n                              <span className='text-muted-foreground block truncate text-xs font-normal'>\n                                {item.subtitle}\n                              </span>\n                            )}\n                          </DataTableCell>\n                          <DataTableCell className='whitespace-nowrap'>\n                            {stage?.label}\n                          </DataTableCell>\n                          <DataTableCell>\n                            <span className='inline-flex flex-wrap items-baseline gap-x-1.5'>\n                              <PipelineAge days={days} expectedDays={expected} />\n                              <span\n                                aria-hidden\n                                className='text-muted-foreground text-xs whitespace-nowrap'\n                              >\n                                of {expected}d\n                              </span>\n                            </span>\n                          </DataTableCell>\n                          <DataTableCell className='whitespace-nowrap tabular-nums'>\n                            {formatAge(days - expected, 'long')}\n                          </DataTableCell>\n                          <DataTableCell>\n                            <PipelineOwner\n                              avatar={item.ownerAvatar}\n                              name={item.owner ?? 'Unassigned'}\n                              showName\n                            />\n                          </DataTableCell>\n                        </DataTableRow>\n                      )\n                    })}\n                </DataTableBody>\n              </DataTable>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Pipeline3, exampleProps as pipeline3ExampleProps, type Pipeline3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/pipeline/pipeline-03.tsx"
    }
  ],
  "meta": {
    "shows": "Items that have been in a stage longer than expected, longest first, with how long they have waited and who owns them.",
    "size": "full",
    "usedWith": [
      "pipeline-01",
      "pipeline-02"
    ],
    "component": "Pipeline3",
    "props": "{ description?: string; items?: { enteredStageAt: Date; id: string; owner?: string; ownerAvatar?: string; stage: string; subtitle?: string; title: string; value?: number }[]; noun?: string; now: Date; stages: { expectedDays?: number; id: string; label: string; probability?: number }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
