{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "error-pages-04",
  "description": "A maintenance page with what is being done, when it ends, progress through the window, the latest updates and an email sign-up.",
  "registryDependencies": [
    "button",
    "input",
    "https://www.dashboardblocks.com/r/radix/error-pages.json",
    "https://www.dashboardblocks.com/r/radix/usage-meter.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/error-pages/error-pages-04.tsx",
      "content": "'use client'\n\nimport {\n  ErrorPageLayout,\n  formatDuration,\n} from '@/registry/components/dashboardblocks/error-pages'\nimport { UsageBar } from '@/registry/components/dashboardblocks/usage-meter'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatDate } from '@/registry/lib/dashboardblocks/format'\nimport { type FormEvent, type ReactNode, useId, useState } from 'react'\nimport { flushSync } from 'react-dom'\n\nimport { Button } from '@/components/ui/button'\nimport { Input } from '@/components/ui/input'\n\ninterface MaintenanceUpdate {\n  at: Date\n  id: string\n  text: string\n}\n\ninterface ErrorPages4Props {\n  brand?: ReactNode\n  endsAt: Date\n  /** Pass a fixed date, so the page renders the same on the server and in the browser. */\n  now: Date\n  onSubscribe?: (email: string) => void\n  startsAt: Date\n  statusHref?: string\n  /** Newest first. */\n  updates: MaintenanceUpdate[]\n  work: string\n}\n\nconst START = Date.UTC(2026, 8, 27, 14, 0)\nconst minutesIn = (minutes: number) => new Date(START + minutes * 60_000)\n\nconst exampleProps: ErrorPages4Props = {\n  brand: (\n    <>\n      <span className='bg-primary text-primary-foreground flex size-7 items-center justify-center rounded-md [&_svg]:size-4'>\n        <IconPlaceholder\n          lucide='BlocksIcon'\n          tabler='IconCube'\n          hugeicons='CubeIcon'\n          phosphor='CubeIcon'\n          remixicon='RiBox3Line'\n        />\n      </span>\n      Acme Analytics\n    </>\n  ),\n  endsAt: minutesIn(60),\n  now: minutesIn(35),\n  onSubscribe: () => {},\n  startsAt: minutesIn(0),\n  statusHref: '#',\n  updates: [\n    {\n      at: minutesIn(32),\n      id: 'u3',\n      text: 'Data is copied. Checking that every dashboard matches.',\n    },\n    { at: minutesIn(12), id: 'u2', text: 'Copying data to the new warehouse.' },\n    { at: minutesIn(0), id: 'u1', text: 'Maintenance started. Dashboards are offline.' },\n  ],\n  work: 'We’re moving your data to a faster warehouse. Dashboards, reports and alerts are paused, and no data is lost.',\n}\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\nconst ErrorPages4 = (props: ErrorPages4Props) => {\n  const { brand, endsAt, now, onSubscribe, startsAt, statusHref, updates, work } = props\n  const id = useId()\n  const [email, setEmail] = useState('')\n  const [error, setError] = useState<string | null>(null)\n  const [subscribed, setSubscribed] = useState(false)\n\n  const total = endsAt.getTime() - startsAt.getTime()\n  const elapsed = Math.max(now.getTime() - startsAt.getTime(), 0)\n  const percent = total > 0 ? Math.round((Math.min(elapsed, total) / total) * 100) : 0\n  const overrun = now.getTime() > endsAt.getTime()\n\n  const subscribe = (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault()\n    const address = email.trim()\n    if (!EMAIL.test(address)) {\n      flushSync(() => setError('Enter an email address.'))\n      document.getElementById(`${id}-email`)?.focus()\n      return\n    }\n    setError(null)\n    setSubscribed(true)\n    onSubscribe?.(address)\n  }\n\n  return (\n    <ErrorPageLayout\n      brand={brand}\n      title='Down for maintenance'\n      description={work}\n      footer={\n        statusHref && (\n          <a\n            href={statusHref}\n            className='hover:text-foreground underline underline-offset-4'\n          >\n            Follow along on the status page\n          </a>\n        )\n      }\n    >\n      <div className='flex flex-col gap-3 border-t pt-6'>\n        <div className='flex flex-col gap-1'>\n          <p className='text-muted-foreground text-sm'>\n            {overrun ? 'Planned to be back by' : 'Back by'}\n          </p>\n          <p className='text-4xl font-light tracking-tight tabular-nums'>\n            <time dateTime={endsAt.toISOString()}>{formatDate(endsAt, 'time-zone')}</time>\n          </p>\n          <p className='text-muted-foreground text-sm'>\n            {overrun\n              ? 'It’s taking longer than planned. We’ll post an update soon.'\n              : `Started ${formatDate(startsAt, 'time-zone')}, with ${formatDuration(endsAt.getTime() - now.getTime())} to go.`}\n          </p>\n        </div>\n        <div\n          role='progressbar'\n          aria-label='Maintenance progress'\n          aria-valuenow={percent}\n          aria-valuemin={0}\n          aria-valuemax={100}\n          aria-valuetext={\n            overrun\n              ? 'Past the planned time'\n              : `${percent}% of the planned time has passed`\n          }\n        >\n          <UsageBar\n            color='var(--color-chart-2)'\n            limit={total}\n            overColor='var(--color-orange-500)'\n            size='sm'\n            used={elapsed}\n          />\n        </div>\n      </div>\n\n      {updates.length > 0 && (\n        <section aria-labelledby={`${id}-updates`} className='flex flex-col gap-2'>\n          <h2 id={`${id}-updates`} className='text-sm font-medium'>\n            Updates\n          </h2>\n          <ol className='flex flex-col divide-y border-y'>\n            {updates.map((update, index) => (\n              <li\n                key={update.id}\n                className='grid grid-cols-[5.5rem_minmax(0,1fr)] gap-3 py-2.5 text-sm'\n              >\n                <time\n                  dateTime={update.at.toISOString()}\n                  className='text-muted-foreground tabular-nums'\n                >\n                  {formatDate(update.at, 'time-zone')}\n                </time>\n                <span className={index === 0 ? 'font-medium' : undefined}>\n                  {update.text}\n                </span>\n              </li>\n            ))}\n          </ol>\n        </section>\n      )}\n\n      {onSubscribe &&\n        (subscribed ? (\n          <p role='status' className='text-muted-foreground text-sm'>\n            We’ll email {email.trim()} when everything is back.\n          </p>\n        ) : (\n          <form\n            method='post'\n            noValidate\n            onSubmit={subscribe}\n            className='flex flex-col gap-2'\n          >\n            <label htmlFor={`${id}-email`} className='text-sm font-medium'>\n              Get an email when it’s back\n            </label>\n            <div className='flex gap-2'>\n              <Input\n                id={`${id}-email`}\n                type='email'\n                autoComplete='email'\n                placeholder='name@company.com'\n                value={email}\n                onChange={(event) => setEmail(event.target.value)}\n                aria-invalid={error ? true : undefined}\n                aria-describedby={error ? `${id}-error` : undefined}\n              />\n              <Button type='submit' variant='outline'>\n                Notify me\n              </Button>\n            </div>\n            {error && (\n              <p id={`${id}-error`} className='text-destructive text-sm'>\n                {error}\n              </p>\n            )}\n          </form>\n        ))}\n    </ErrorPageLayout>\n  )\n}\n\nexport {\n  ErrorPages4,\n  exampleProps as errorPages4ExampleProps,\n  type ErrorPages4Props,\n  type MaintenanceUpdate,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/error-pages/error-pages-04.tsx"
    }
  ],
  "meta": {
    "shows": "A maintenance page with what is being done, when it ends, progress through the window, the latest updates and an email sign-up.",
    "size": "page",
    "usedWith": [
      "error-pages-03"
    ],
    "component": "ErrorPages4",
    "props": "{ brand?: ReactNode; endsAt: Date; now: Date; onSubscribe?: (email: string) => void; startsAt: Date; statusHref?: string; updates: { at: Date; id: string; text: string }[]; work: string }"
  },
  "type": "registry:component"
}
