{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "team-04",
  "description": "Who is on call now and until when, who is next, and the rest of the rota.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/progress-bar.json",
    "https://www.dashboardblocks.com/r/radix/team.json",
    "https://www.dashboardblocks.com/r/radix/format.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/team/team-04.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 { ProgressBar } from '@/registry/components/dashboardblocks/progress-bar'\nimport {\n  type Person,\n  PersonAvatar,\n  PresenceLabel,\n} from '@/registry/components/dashboardblocks/team'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatDate } from '@/registry/lib/dashboardblocks/format'\nimport { useId } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Shift {\n  end: Date\n  person: Person\n  start: Date\n}\n\ninterface Team4Props extends BlockStateProps {\n  description: string\n  now: Date\n  onPage?: (person: Person) => void\n  /** Leave out, or pass none, to show the empty state. */\n  shifts?: Shift[]\n  /** @default 'UTC' */\n  timeZone?: string\n  title: string\n}\n\nconst NOW = Date.UTC(2026, 8, 25, 14, 30)\nconst monday = (weeks: number) => new Date(Date.UTC(2026, 8, 21 + weeks * 7, 9))\n\nconst exampleProps: Team4Props = {\n  description: 'Platform, primary rotation',\n  now: new Date(NOW),\n  shifts: [\n    {\n      end: monday(0),\n      person: {\n        avatar: '/images/avatar-06.webp',\n        id: 'm4',\n        name: 'Mateo García',\n        presence: 'online',\n      },\n      start: monday(-1),\n    },\n    {\n      end: monday(1),\n      person: {\n        avatar: '/images/avatar-04.webp',\n        id: 'm2',\n        name: 'Liam Carter',\n        presence: 'online',\n      },\n      start: monday(0),\n    },\n    {\n      end: monday(2),\n      person: {\n        avatar: '/images/avatar-01.webp',\n        id: 'm3',\n        name: 'Sofia Rossi',\n        presence: 'away',\n      },\n      start: monday(1),\n    },\n    {\n      end: monday(3),\n      person: {\n        avatar: '/images/avatar-07.webp',\n        id: 'm6',\n        name: 'Jonas Weber',\n        presence: 'offline',\n      },\n      start: monday(2),\n    },\n    {\n      end: monday(4),\n      person: {\n        avatar: '/images/avatar-05.webp',\n        id: 'm1',\n        name: 'Amara Okafor',\n        presence: 'online',\n      },\n      start: monday(3),\n    },\n  ],\n  title: 'On call',\n}\n\nconst MINUTE = 60_000\n\nfunction formatDuration(ms: number) {\n  const minutes = Math.max(0, Math.round(ms / MINUTE))\n  const days = Math.floor(minutes / 1_440)\n  const hours = Math.floor((minutes % 1_440) / 60)\n  const rest = minutes % 60\n  if (days > 0) return hours > 0 ? `${days} d ${hours} h` : `${days} d`\n  if (hours > 0) return rest > 0 ? `${hours} h ${rest} min` : `${hours} h`\n  return `${rest} min`\n}\n\nconst Team4 = (props: Team4Props) => {\n  const {\n    description,\n    now,\n    onPage,\n    shifts = [],\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    title,\n  } = props\n  const state = getBlockState(status, shifts)\n  const id = useId()\n\n  const upcoming = shifts.filter((shift) => shift.end.getTime() > now.getTime())\n  const current = upcoming[0]?.start.getTime() <= now.getTime() ? upcoming[0] : undefined\n  const comingUp = current ? upcoming.slice(1) : upcoming\n  const next = comingUp.at(0)\n  const elapsed = current\n    ? (now.getTime() - current.start.getTime()) /\n      (current.end.getTime() - current.start.getTime())\n    : 0\n\n  const summary = current\n    ? `${current.person.name} until ${formatDate(current.end, 'weekday-day', timeZone)}${next ? `, then ${next.person.name}` : ''}.`\n    : next\n      ? `Nobody right now. ${next.person.name} starts ${formatDate(next.start, 'weekday-day', timeZone)}.`\n      : 'Nobody is on call.'\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section 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              <p className='text-muted-foreground text-sm'>\n                {description}. <BlockReady className='text-sm'>{summary}</BlockReady>\n              </p>\n            </header>\n            <section\n              aria-labelledby={`${id}-now`}\n              className='flex flex-col gap-3 border-t pt-4'\n            >\n              <h3 id={`${id}-now`} className='text-sm font-medium'>\n                On call now\n              </h3>\n              {state ? (\n                <BlockStateRows rows={1} />\n              ) : current ? (\n                <>\n                  <div className='flex flex-wrap items-center gap-3'>\n                    <PersonAvatar person={current.person} showPresence size='lg' />\n                    <div className='flex min-w-0 flex-1 flex-col'>\n                      <span className='truncate text-2xl font-light tracking-tight'>\n                        {current.person.name}\n                      </span>\n                      {current.person.presence && (\n                        <PresenceLabel\n                          presence={current.person.presence}\n                          className='text-xs'\n                        />\n                      )}\n                    </div>\n                    <Button\n                      variant='outline'\n                      size='sm'\n                      onClick={() => onPage?.(current.person)}\n                    >\n                      <IconPlaceholder\n                        lucide='BellRingIcon'\n                        tabler='IconBellRinging'\n                        hugeicons='NotificationSquareIcon'\n                        phosphor='BellRingingIcon'\n                        remixicon='RiNotification3Line'\n                        data-icon='inline-start'\n                      />\n                      Page\n                      <span className='sr-only'> {current.person.name}</span>\n                    </Button>\n                  </div>\n                  <div aria-hidden>\n                    <ProgressBar\n                      className='h-1.5'\n                      fillClassName='motion-reduce:transition-none'\n                      percentage={elapsed * 100}\n                    />\n                  </div>\n                  <p className='text-muted-foreground flex flex-wrap justify-between gap-x-4 gap-y-0.5 text-xs'>\n                    <span>\n                      Hands over{' '}\n                      <time\n                        className='text-foreground font-medium'\n                        dateTime={current.end.toISOString()}\n                      >\n                        {formatDate(current.end, 'weekday-day-time-zone', timeZone)}\n                      </time>\n                    </span>\n                    <span className='tabular-nums'>\n                      in {formatDuration(current.end.getTime() - now.getTime())}\n                    </span>\n                  </p>\n                </>\n              ) : (\n                <p className='text-muted-foreground text-sm'>\n                  Nobody is on call right now.\n                </p>\n              )}\n            </section>\n            {!state && next && (\n              <section\n                aria-labelledby={`${id}-next`}\n                className='flex flex-col gap-1 border-t pt-4'\n              >\n                <h3 id={`${id}-next`} className='text-sm font-medium'>\n                  Coming up\n                </h3>\n                <ol className='flex flex-col divide-y'>\n                  {comingUp.map((shift) => (\n                    <li\n                      key={`${shift.person.id}-${shift.start.toISOString()}`}\n                      className='flex items-center gap-3 py-2.5'\n                    >\n                      <PersonAvatar person={shift.person} size='sm' />\n                      <span className='min-w-0 flex-1 truncate text-sm'>\n                        {shift.person.name}\n                      </span>\n                      <span className='text-muted-foreground shrink-0 text-xs tabular-nums'>\n                        <time dateTime={shift.start.toISOString()}>\n                          {formatDate(shift.start, 'day', timeZone)}\n                        </time>\n                        {' – '}\n                        <time dateTime={shift.end.toISOString()}>\n                          {formatDate(shift.end, 'day', timeZone)}\n                        </time>\n                      </span>\n                    </li>\n                  ))}\n                </ol>\n              </section>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Team4, exampleProps as team4ExampleProps, type Team4Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/team/team-04.tsx"
    }
  ],
  "meta": {
    "shows": "Who is on call now and until when, who is next, and the rest of the rota.",
    "size": "half",
    "usedWith": [
      "schedule-01",
      "alerts-01",
      "team-03"
    ],
    "component": "Team4",
    "props": "{ description: string; now: Date; onPage?: (person: { avatar?: string; id: string; name: string; presence?: \"online\" | \"away\" | \"offline\" }) => void; shifts?: { end: Date; person: { avatar?: string; id: string; name: string; presence?: \"online\" | \"away\" | \"offline\" }; start: Date }[]; timeZone?: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
