{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "schedule-03",
  "description": "Deadlines and renewals in date order, each with a countdown and an urgency badge.",
  "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/schedule.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/schedule/schedule-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  UrgencyLabel,\n  formatCountdown,\n  getDay,\n  getDayOffset,\n  getUrgency,\n} from '@/registry/components/dashboardblocks/schedule'\nimport { formatCurrency, formatDate } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Deadline {\n  /** What is owed or renewed, in dollars. */\n  amount?: number\n  /** Shows the amount as a recurring price, such as `a year`. */\n  billed?: 'month' | 'year'\n  detail?: string\n  due: Date\n  id: string\n  title: string\n}\n\ninterface Schedule3Props extends BlockStateProps {\n  /** Leave out, or pass none, to show the empty state. */\n  deadlines?: Deadline[]\n  now: Date\n  soonDays?: number\n  /** @default 'UTC' */\n  timeZone?: string\n  title: string\n}\n\nconst NOW = Date.UTC(2026, 8, 28, 9, 40)\nconst inDays = (days: number) => new Date(NOW + days * 86_400_000)\n\nconst exampleProps: Schedule3Props = {\n  deadlines: [\n    {\n      amount: 4_200,\n      detail: 'Invoice INV-2291',\n      due: inDays(-2),\n      id: 'd1',\n      title: 'Payment to Cloudline Hosting',\n    },\n    {\n      detail: 'api.example.com',\n      due: inDays(0),\n      id: 'd2',\n      title: 'TLS certificate expires',\n    },\n    {\n      amount: 12_480,\n      billed: 'year',\n      detail: 'Contract renewal',\n      due: inDays(3),\n      id: 'd3',\n      title: 'Figma Organization',\n    },\n    {\n      detail: 'Quarterly filing',\n      due: inDays(6),\n      id: 'd4',\n      title: 'VAT return Q3',\n    },\n    {\n      amount: 38_000,\n      billed: 'year',\n      detail: 'Contract renewal',\n      due: inDays(17),\n      id: 'd5',\n      title: 'Datadog Pro',\n    },\n    {\n      amount: 24,\n      billed: 'year',\n      detail: 'Domain renewal',\n      due: inDays(41),\n      id: 'd6',\n      title: 'example.com',\n    },\n  ],\n  now: new Date(NOW),\n  title: 'Deadlines and renewals',\n}\n\nconst Schedule3 = (props: Schedule3Props) => {\n  const {\n    deadlines = [],\n    now,\n    soonDays = 7,\n    errorMessage,\n    status,\n    timeZone = 'UTC',\n    title,\n  } = props\n  const rows = [...deadlines]\n    .sort((a, b) => a.due.getTime() - b.due.getTime())\n    .map((deadline) => ({\n      ...deadline,\n      offset: getDayOffset(deadline.due, now, timeZone),\n      urgency: getUrgency(deadline.due, now, timeZone, soonDays),\n    }))\n  const overdue = rows.filter((row) => row.urgency === 'overdue').length\n  const soon = rows.filter(\n    (row) => row.urgency === 'today' || row.urgency === 'soon',\n  ).length\n  const hasAmounts = rows.some((row) => row.amount !== undefined)\n\n  return (\n    <BlockStateProvider\n      errorMessage={errorMessage}\n      state={getBlockState(status, deadlines)}\n    >\n      <Card>\n        <CardContent>\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                  {overdue === 0 ? 'Nothing overdue' : `${overdue} overdue`}, and {soon}{' '}\n                  due in the next {soonDays} days.\n                </p>\n              </BlockReady>\n            </header>\n            <div className='border-t'>\n              <BlockStateRows rows={5} />\n              <ul className='empty:hidden'>\n                {!status &&\n                  rows.map((row) => {\n                    const countdown =\n                      row.urgency === 'overdue'\n                        ? `${-row.offset} ${row.offset === -1 ? 'day' : 'days'} overdue`\n                        : row.urgency === 'today'\n                          ? 'Due today'\n                          : `Due ${formatCountdown(row.due, now, timeZone)}`\n                    return (\n                      <li\n                        key={row.id}\n                        className='flex items-start gap-4 border-b py-2.5 last:border-b-0'\n                      >\n                        <div className='flex min-w-0 flex-1 flex-col gap-0.5'>\n                          <span className='text-sm font-medium break-words'>\n                            {row.title}\n                          </span>\n                          {row.detail && (\n                            <span className='text-muted-foreground truncate text-sm'>\n                              {row.detail}\n                            </span>\n                          )}\n                        </div>\n                        {hasAmounts && (\n                          <p className='flex w-20 shrink-0 flex-col items-end gap-0.5 text-right text-sm tabular-nums'>\n                            {row.amount !== undefined && (\n                              <>\n                                <span>{formatCurrency(row.amount)}</span>\n                                {row.billed && (\n                                  <span className='text-muted-foreground'>\n                                    a {row.billed}\n                                  </span>\n                                )}\n                              </>\n                            )}\n                          </p>\n                        )}\n                        <p className='flex shrink-0 flex-col items-end gap-0.5 text-right'>\n                          <UrgencyLabel urgency={row.urgency} label={countdown} />\n                          <time\n                            dateTime={getDay(row.due, timeZone)\n                              .toISOString()\n                              .slice(0, 10)}\n                            className='text-muted-foreground text-sm whitespace-nowrap tabular-nums'\n                          >\n                            {formatDate(getDay(row.due, timeZone), 'weekday-day')}\n                          </time>\n                        </p>\n                      </li>\n                    )\n                  })}\n              </ul>\n            </div>\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Schedule3, exampleProps as schedule3ExampleProps, type Schedule3Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/schedule/schedule-03.tsx"
    }
  ],
  "meta": {
    "shows": "Deadlines and renewals in date order, each with a countdown and an urgency badge.",
    "size": "half",
    "usedWith": [
      "schedule-01",
      "billing-01",
      "checklist-04"
    ],
    "component": "Schedule3",
    "props": "{ deadlines?: { amount?: number; billed?: \"month\" | \"year\"; detail?: string; due: Date; id: string; title: string }[]; now: Date; soonDays?: number; timeZone?: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
