{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "error-pages-02",
  "description": "A no access page naming who can grant access, with a request form and the account you are signed in with.",
  "registryDependencies": [
    "button",
    "textarea",
    "https://www.dashboardblocks.com/r/radix/team.json",
    "https://www.dashboardblocks.com/r/radix/error-pages.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/error-pages/error-pages-02.tsx",
      "content": "'use client'\n\nimport { ErrorPageLayout } from '@/registry/components/dashboardblocks/error-pages'\nimport { PersonAvatar } from '@/registry/components/dashboardblocks/team'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { type FormEvent, type ReactNode, startTransition, useId, useState } from 'react'\n\nimport { Button, buttonVariants } from '@/components/ui/button'\nimport { Textarea } from '@/components/ui/textarea'\n\ninterface ErrorPages2Props {\n  brand?: ReactNode\n  homeHref: string\n  onRequestAccess?: (message: string) => void | Promise<void>\n  owner: { avatar?: string; name: string }\n  /** Starts in the sent state, when a request is already waiting. */\n  requested?: boolean\n  resource: string\n  signedInAs: string\n  switchAccountHref: string\n}\n\nconst exampleProps: ErrorPages2Props = {\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  homeHref: '#',\n  onRequestAccess: () => new Promise((resolve) => setTimeout(resolve, 800)),\n  owner: { avatar: '/images/avatar-05.webp', name: 'Amara Okafor' },\n  resource: 'the Revenue overview dashboard',\n  signedInAs: 'noah@acme.co',\n  switchAccountHref: '#',\n}\n\nconst ErrorPages2 = (props: ErrorPages2Props) => {\n  const {\n    brand,\n    homeHref,\n    onRequestAccess,\n    owner,\n    resource,\n    signedInAs,\n    switchAccountHref,\n  } = props\n  const id = useId()\n  const [message, setMessage] = useState('')\n  const [sending, setSending] = useState(false)\n  const [sent, setSent] = useState(props.requested ?? false)\n  const [error, setError] = useState<string | null>(null)\n\n  const request = async (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault()\n    setSending(true)\n    setError(null)\n    try {\n      await onRequestAccess?.(message.trim())\n      startTransition(() => setSent(true))\n    } catch {\n      startTransition(() => setError('The request didn’t send. Try again.'))\n    } finally {\n      startTransition(() => setSending(false))\n    }\n  }\n\n  return (\n    <ErrorPageLayout\n      brand={brand}\n      code='403'\n      title='You don’t have access'\n      description={`You need permission to view ${resource}.`}\n    >\n      <div className='flex flex-col gap-4 border-t pt-6'>\n        <div className='flex items-center gap-3'>\n          <PersonAvatar person={owner} />\n          <p className='text-sm'>\n            <span className='font-medium'>{owner.name}</span>{' '}\n            <span className='text-muted-foreground'>can give you access.</span>\n          </p>\n        </div>\n        {sent ? (\n          <p\n            role='status'\n            className='flex items-start gap-2 text-sm text-emerald-700 dark:text-emerald-400 [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0'\n          >\n            <IconPlaceholder\n              lucide='CircleCheckIcon'\n              tabler='IconCircleCheck'\n              hugeicons='CheckmarkCircle02Icon'\n              phosphor='CheckCircleIcon'\n              remixicon='RiCheckboxCircleLine'\n              aria-hidden\n            />\n            Request sent. We’ll email you when {owner.name.split(' ')[0]} replies.\n          </p>\n        ) : (\n          <form\n            method='post'\n            onSubmit={(event) => void request(event)}\n            className='flex flex-col gap-3'\n          >\n            <label htmlFor={`${id}-message`} className='text-sm font-medium'>\n              Message{' '}\n              <span className='text-muted-foreground font-normal'>(optional)</span>\n            </label>\n            <Textarea\n              id={`${id}-message`}\n              rows={3}\n              placeholder='Why you need access'\n              value={message}\n              onChange={(event) => setMessage(event.target.value)}\n              aria-describedby={error ? `${id}-error` : undefined}\n            />\n            {error && (\n              <p id={`${id}-error`} className='text-destructive text-sm'>\n                {error}\n              </p>\n            )}\n            <Button type='submit' disabled={sending} className='self-start'>\n              {sending ? 'Sending' : 'Request access'}\n            </Button>\n          </form>\n        )}\n      </div>\n      <div className='flex flex-col items-start gap-3 border-t pt-6 text-sm'>\n        <p className='text-muted-foreground'>\n          Signed in as <span className='text-foreground font-medium'>{signedInAs}</span>.{' '}\n          <a\n            href={switchAccountHref}\n            className='text-foreground font-medium underline underline-offset-4'\n          >\n            Switch account\n          </a>\n        </p>\n        <a href={homeHref} className={buttonVariants({ variant: 'outline' })}>\n          <IconPlaceholder\n            lucide='ArrowLeftIcon'\n            tabler='IconArrowLeft'\n            hugeicons='ArrowLeft01Icon'\n            phosphor='ArrowLeftIcon'\n            remixicon='RiArrowLeftLine'\n            data-icon='inline-start'\n          />\n          Back to dashboards\n        </a>\n      </div>\n    </ErrorPageLayout>\n  )\n}\n\nexport { ErrorPages2, exampleProps as errorPages2ExampleProps, type ErrorPages2Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/error-pages/error-pages-02.tsx"
    }
  ],
  "meta": {
    "shows": "A no access page naming who can grant access, with a request form and the account you are signed in with.",
    "size": "page",
    "usedWith": [
      "error-pages-01"
    ],
    "component": "ErrorPages2",
    "props": "{ brand?: ReactNode; homeHref: string; onRequestAccess?: (message: string) => void | Promise<void>; owner: { avatar?: string; name: string }; requested?: boolean; resource: string; signedInAs: string; switchAccountHref: string }"
  },
  "type": "registry:component"
}
