{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth-01",
  "description": "An invite page showing the workspace, who invited you, your role and the people already there, with a prompt to switch account when the address differs.",
  "registryDependencies": [
    "button",
    "https://www.dashboardblocks.com/r/radix/team.json",
    "https://www.dashboardblocks.com/r/radix/auth.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/auth/auth-01.tsx",
      "content": "'use client'\n\nimport { AuthLayout, WorkspaceAvatar } from '@/registry/components/dashboardblocks/auth'\nimport { AvatarStack, PersonAvatar } from '@/registry/components/dashboardblocks/team'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { type ReactNode, startTransition, useState } from 'react'\n\nimport { Button, buttonVariants } from '@/components/ui/button'\n\nimport { cn } from '@/lib/utils'\n\ninterface InviteWorkspace {\n  logo?: string\n  /** Drawn in the primary colour when there's no `logo`. */\n  mark?: ReactNode\n  members: { avatar?: string; id: string; name: string }[]\n  memberCount: number\n  name: string\n}\n\ninterface Auth1Props {\n  email: string\n  expired?: boolean\n  invitedBy: { avatar?: string; name: string }\n  onAccept?: () => void | Promise<void>\n  onDecline?: () => void\n  role: string\n  /** What the role can do, under its name. */\n  roleDescription?: string\n  signedInAs?: string\n  switchAccountHref: string\n  workspace: InviteWorkspace\n}\n\nconst exampleProps: Auth1Props = {\n  email: 'noah@northwind.io',\n  invitedBy: { avatar: '/images/avatar-04.webp', name: 'Liam Carter' },\n  onAccept: () => new Promise((resolve) => setTimeout(resolve, 800)),\n  role: 'Member',\n  roleDescription: 'Can create and edit dashboards',\n  signedInAs: 'noah@northwind.io',\n  switchAccountHref: '#',\n  workspace: {\n    mark: (\n      <svg viewBox='0 0 24 24' fill='currentColor' aria-hidden>\n        <rect x='4.5' y='2.5' width='5' height='19' rx='2.5' />\n        <path\n          d='M7 5l9.75 14'\n          stroke='currentColor'\n          strokeWidth='5'\n          strokeLinecap='round'\n        />\n        <circle cx='17' cy='6.25' r='3.75' />\n      </svg>\n    ),\n    memberCount: 24,\n    members: [\n      { avatar: '/images/avatar-05.webp', id: 'm1', name: 'Amara Okafor' },\n      { avatar: '/images/avatar-04.webp', id: 'm2', name: 'Liam Carter' },\n      { avatar: '/images/avatar-01.webp', id: 'm3', name: 'Sofia Rossi' },\n      { avatar: '/images/avatar-06.webp', id: 'm4', name: 'Mateo García' },\n    ],\n    name: 'Northwind Finance',\n  },\n}\n\ntype Outcome = 'pending' | 'accepted' | 'declined'\n\nconst Auth1 = (props: Auth1Props) => {\n  const {\n    email,\n    expired = false,\n    invitedBy,\n    onAccept,\n    onDecline,\n    role,\n    roleDescription,\n    signedInAs,\n    switchAccountHref,\n    workspace,\n  } = props\n  const [outcome, setOutcome] = useState<Outcome>('pending')\n  const [joining, setJoining] = useState(false)\n  const [error, setError] = useState<string | null>(null)\n\n  const wrongAccount =\n    signedInAs !== undefined && signedInAs.toLowerCase() !== email.toLowerCase()\n\n  const accept = async () => {\n    setJoining(true)\n    setError(null)\n    try {\n      await onAccept?.()\n      startTransition(() => setOutcome('accepted'))\n    } catch {\n      startTransition(() => setError('Couldn’t join the workspace. Try again.'))\n    } finally {\n      startTransition(() => setJoining(false))\n    }\n  }\n\n  const title = expired\n    ? 'This invite has expired'\n    : outcome === 'accepted'\n      ? `You’ve joined ${workspace.name}`\n      : outcome === 'declined'\n        ? 'Invite declined'\n        : `Join ${workspace.name}`\n\n  const description = expired ? (\n    `Ask ${invitedBy.name} to send a new one.`\n  ) : outcome === 'accepted' ? (\n    'Taking you to the workspace…'\n  ) : outcome === 'declined' ? (\n    `We’ve let ${invitedBy.name} know. You can close this page.`\n  ) : (\n    <>\n      <span className='text-foreground font-medium'>{invitedBy.name}</span> invited{' '}\n      <span className='text-foreground font-medium'>{email}</span> to the workspace.\n    </>\n  )\n\n  return (\n    <AuthLayout\n      media={\n        <WorkspaceAvatar\n          name={workspace.name}\n          logo={workspace.logo}\n          mark={workspace.mark}\n          size='lg'\n        />\n      }\n      title={title}\n      description={description}\n    >\n      {!expired && outcome === 'pending' && (\n        <div className='flex flex-col gap-6'>\n          <dl className='flex flex-col divide-y border-y text-sm'>\n            <div className='flex items-center justify-between gap-4 py-2.5'>\n              <dt className='text-muted-foreground'>Invited by</dt>\n              <dd className='flex min-w-0 items-center gap-2 font-medium'>\n                <PersonAvatar person={invitedBy} size='sm' />\n                <span className='truncate'>{invitedBy.name}</span>\n              </dd>\n            </div>\n            <div className='flex items-center justify-between gap-4 py-2.5'>\n              <dt className='text-muted-foreground'>Role</dt>\n              <dd className='flex flex-col items-end text-right'>\n                <span className='font-medium'>{role}</span>\n                {roleDescription && (\n                  <span className='text-muted-foreground text-xs'>{roleDescription}</span>\n                )}\n              </dd>\n            </div>\n            <div className='flex items-center justify-between gap-4 py-2.5'>\n              <dt className='text-muted-foreground'>Members</dt>\n              <dd className='flex items-center gap-2'>\n                <AvatarStack\n                  label={`Members of ${workspace.name}`}\n                  people={workspace.members}\n                  size='sm'\n                />\n                <span className='text-muted-foreground text-xs whitespace-nowrap tabular-nums'>\n                  {workspace.memberCount} people\n                </span>\n              </dd>\n            </div>\n          </dl>\n\n          {wrongAccount ? (\n            <div className='flex flex-col gap-3'>\n              <p\n                role='alert'\n                className='bg-muted/50 flex items-start gap-2 rounded-lg px-3 py-2 text-sm text-pretty [&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0'\n              >\n                <IconPlaceholder\n                  lucide='TriangleAlertIcon'\n                  tabler='IconAlertTriangle'\n                  hugeicons='Alert02Icon'\n                  phosphor='WarningIcon'\n                  remixicon='RiErrorWarningLine'\n                  aria-hidden\n                  className='text-orange-700 dark:text-orange-400'\n                />\n                <span>\n                  You’re signed in as <span className='font-medium'>{signedInAs}</span>.\n                  Switch to <span className='font-medium'>{email}</span> to accept.\n                </span>\n              </p>\n              <a href={switchAccountHref} className={cn(buttonVariants(), 'w-full')}>\n                Switch account\n              </a>\n            </div>\n          ) : (\n            <div className='flex flex-col gap-2'>\n              <Button disabled={joining} onClick={() => void accept()}>\n                {joining ? 'Joining' : 'Accept invite'}\n              </Button>\n              <Button\n                variant='ghost'\n                disabled={joining}\n                onClick={() => {\n                  setOutcome('declined')\n                  onDecline?.()\n                }}\n              >\n                Decline\n              </Button>\n              {error && (\n                <p role='alert' className='text-destructive text-sm'>\n                  {error}\n                </p>\n              )}\n            </div>\n          )}\n        </div>\n      )}\n      {outcome === 'accepted' && (\n        <p role='status' className='sr-only'>\n          Joined {workspace.name}\n        </p>\n      )}\n    </AuthLayout>\n  )\n}\n\nexport { Auth1, exampleProps as auth1ExampleProps, type Auth1Props, type InviteWorkspace }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/auth/auth-01.tsx"
    }
  ],
  "meta": {
    "shows": "An invite page showing the workspace, who invited you, your role and the people already there, with a prompt to switch account when the address differs.",
    "size": "page",
    "usedWith": [
      "auth-02"
    ],
    "component": "Auth1",
    "props": "{ email: string; expired?: boolean; invitedBy: { avatar?: string; name: string }; onAccept?: () => void | Promise<void>; onDecline?: () => void; role: string; roleDescription?: string; signedInAs?: string; switchAccountHref: string; workspace: { logo?: string; mark?: ReactNode; members: { avatar?: string; id: string; name: string }[]; memberCount: number; name: string } }"
  },
  "type": "registry:component"
}
