{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "team-02",
  "description": "Work assigned to each person against their capacity on a shared scale, with anyone over capacity flagged and listed first.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json",
    "https://www.dashboardblocks.com/r/radix/team.json",
    "https://www.dashboardblocks.com/r/radix/use-reveal.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/team/team-02.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 { KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport { StatusLabel } from '@/registry/components/dashboardblocks/status-label'\nimport {\n  type Person,\n  PersonAvatar,\n  WorkloadBar,\n  workloadFill,\n  workloadOverFill,\n} from '@/registry/components/dashboardblocks/team'\nimport { useReveal } from '@/registry/hooks/use-reveal'\nimport { formatNumber, formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Assignee extends Person {\n  assigned: number\n  capacity: number\n  role?: string\n}\n\ninterface Team2Props extends BlockStateProps {\n  /** @default a sentence naming who is over capacity */\n  description?: string\n  /** Leave out, or pass none, to show the empty state. */\n  people?: Assignee[]\n  title: string\n  unit: string\n}\n\nconst exampleProps: Team2Props = {\n  people: [\n    {\n      assigned: 18,\n      avatar: '/images/avatar-05.webp',\n      capacity: 20,\n      id: 'm1',\n      name: 'Amara Okafor',\n      role: 'Manager',\n    },\n    {\n      assigned: 29,\n      avatar: '/images/avatar-04.webp',\n      capacity: 24,\n      id: 'm2',\n      name: 'Liam Carter',\n      role: 'Staff engineer',\n    },\n    {\n      assigned: 14,\n      avatar: '/images/avatar-01.webp',\n      capacity: 20,\n      id: 'm3',\n      name: 'Sofia Rossi',\n      role: 'Designer',\n    },\n    {\n      assigned: 24,\n      avatar: '/images/avatar-06.webp',\n      capacity: 24,\n      id: 'm4',\n      name: 'Mateo García',\n      role: 'Frontend',\n    },\n    {\n      assigned: 9,\n      avatar: '/images/avatar-02.webp',\n      capacity: 16,\n      id: 'm5',\n      name: 'Priya Nair',\n      role: 'Data',\n    },\n    {\n      assigned: 27,\n      avatar: '/images/avatar-07.webp',\n      capacity: 24,\n      id: 'm6',\n      name: 'Jonas Weber',\n      role: 'Backend',\n    },\n  ],\n  title: 'Workload',\n  unit: 'pts',\n}\n\nfunction summarize(people: Assignee[]) {\n  const over = people.filter((person) => person.assigned > person.capacity)\n  const names = over.map((person) => person.name.split(' ')[0])\n  const overText =\n    over.length === 0\n      ? 'Nobody is over capacity.'\n      : `${names.length > 1 ? `${names.slice(0, -1).join(', ')} and ${names.at(-1)} are` : `${names[0]} is`} over capacity.`\n  return `Story points this sprint, busiest first. ${overText}`\n}\n\nconst Team2 = (props: Team2Props) => {\n  const { people = [], errorMessage, status, title, unit } = props\n  const state = getBlockState(status, people)\n  const { ref, revealed } = useReveal<HTMLElement>(true)\n  const max = Math.max(\n    1,\n    ...people.map((person) => Math.max(person.assigned, person.capacity)),\n  )\n  const sorted = [...people].sort(\n    (a, b) => b.assigned / (b.capacity || 1) - a.assigned / (a.capacity || 1),\n  )\n  const assigned = people.reduce((sum, person) => sum + person.assigned, 0)\n  const capacity = people.reduce((sum, person) => sum + person.capacity, 0)\n  const load = capacity > 0 ? assigned / capacity : 0\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section ref={ref} className='@container flex flex-col gap-4'>\n            <header className='flex flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              {props.description ? (\n                <p className='text-muted-foreground text-sm'>{props.description}</p>\n              ) : (\n                <BlockReady className='text-sm'>\n                  <p className='text-muted-foreground text-sm'>{summarize(people)}</p>\n                </BlockReady>\n              )}\n            </header>\n            <div className='flex flex-wrap items-baseline gap-x-2 border-t pt-4'>\n              <KPIValue value={assigned} format={(value) => formatNumber(value)} />\n              {!state && (\n                <span className='text-muted-foreground text-sm'>\n                  of {formatNumber(capacity)} {unit} assigned,{' '}\n                  {formatPercent(load, { maximumFractionDigits: 0 })} of the team’s\n                  capacity\n                </span>\n              )}\n            </div>\n            {state === 'loading' && <BlockStateRows className='border-t' rows={5} />}\n            {!state && (\n              <ul className='flex flex-col divide-y border-t'>\n                {sorted.map((person) => {\n                  const over = person.assigned - person.capacity\n                  return (\n                    <li key={person.id} className='flex flex-col gap-2 py-3'>\n                      <div className='flex items-center gap-3'>\n                        <PersonAvatar person={person} size='sm' />\n                        <span className='flex min-w-0 flex-1 flex-col'>\n                          <span className='truncate text-sm font-medium'>\n                            {person.name}\n                          </span>\n                          {person.role && (\n                            <span className='text-muted-foreground truncate text-xs'>\n                              {person.role}\n                            </span>\n                          )}\n                        </span>\n                        <span className='flex shrink-0 items-baseline gap-2 text-xs tabular-nums'>\n                          {over > 0 && (\n                            <StatusLabel\n                              variant='text'\n                              tone='warning'\n                              className='text-xs'\n                            >\n                              Over by {over}\n                            </StatusLabel>\n                          )}\n                          <span className='text-muted-foreground'>\n                            <span className='text-foreground font-medium'>\n                              {person.assigned}\n                            </span>{' '}\n                            of {person.capacity} {unit}\n                          </span>\n                        </span>\n                      </div>\n                      <WorkloadBar\n                        assigned={person.assigned}\n                        capacity={person.capacity}\n                        max={max}\n                        revealed={revealed}\n                      />\n                    </li>\n                  )\n                })}\n              </ul>\n            )}\n            {(!state || state === 'loading') && (\n              <ul className='text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs'>\n                <li className='flex items-center gap-1.5'>\n                  <span\n                    aria-hidden\n                    className='h-2 w-3 rounded-full'\n                    style={{ backgroundColor: workloadFill }}\n                  />\n                  Assigned\n                </li>\n                <li className='flex items-center gap-1.5'>\n                  <span\n                    aria-hidden\n                    className='h-2 w-3 rounded-full'\n                    style={{ backgroundImage: workloadOverFill }}\n                  />\n                  Over capacity\n                </li>\n                <li className='flex items-center gap-1.5'>\n                  <span aria-hidden className='bg-foreground h-3 w-0.5 rounded-full' />\n                  Capacity\n                </li>\n              </ul>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Team2, exampleProps as team2ExampleProps, type Team2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/team/team-02.tsx"
    }
  ],
  "meta": {
    "shows": "Work assigned to each person against their capacity on a shared scale, with anyone over capacity flagged and listed first.",
    "size": "half",
    "usedWith": [
      "team-03",
      "kanban-01",
      "leaderboard-02"
    ],
    "component": "Team2",
    "props": "{ description?: string; people?: { assigned: number; capacity: number; role?: string; avatar?: string; id: string; name: string; presence?: \"online\" | \"away\" | \"offline\" }[]; title: string; unit: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
