{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popconfirm-sign-out-everywhere",
  "title": "Popconfirm Sign Out Everywhere",
  "description": "A sign-out-of-all-devices button that names how many sessions will end, then confirms with a success flag instead of a page reload.",
  "registryDependencies": [
    "button",
    "@tealmac/flag",
    "@tealmac/popconfirm"
  ],
  "files": [
    {
      "path": "registry/patterns/popconfirm-sign-out-everywhere/popconfirm-sign-out-everywhere.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { LogOut } from \"lucide-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Flag } from \"@/components/ui/flag\"\nimport { Popconfirm } from \"@/components/ui/popconfirm\"\n\nexport interface PopconfirmSignOutEverywhereProps {\n  /** Sessions that will end, not counting the current one. */\n  otherSessions: number\n  /** Ends the other sessions. */\n  onSignOut: () => Promise<void>\n}\n\n/**\n * Names the cost before asking: \"Sign out 3 other devices?\". The current\n * session is kept, so the person is not thrown out of the page they are on.\n * Success is a flag with a recommendation to change the password, not a\n * silent state change.\n */\nexport function PopconfirmSignOutEverywhere({\n  otherSessions,\n  onSignOut,\n}: PopconfirmSignOutEverywhereProps) {\n  const [done, setDone] = React.useState(false)\n  const label = `${otherSessions} other device${otherSessions === 1 ? \"\" : \"s\"}`\n\n  if (done) {\n    return (\n      <Flag\n        appearance=\"success\"\n        title=\"Signed out everywhere else\"\n        description=\"If you did not recognise a device, change your password.\"\n        actions={[{ content: \"Change password\", href: \"#password\" }]}\n        onDismiss={() => setDone(false)}\n      />\n    )\n  }\n\n  return (\n    <Popconfirm\n      title={`Sign out ${label}?`}\n      description=\"This device stays signed in. The others need the password again.\"\n      confirmLabel=\"Sign out\"\n      destructive\n      onConfirm={async () => {\n        await onSignOut()\n        setDone(true)\n      }}\n    >\n      <Button type=\"button\" variant=\"outline\" disabled={otherSessions === 0}>\n        <LogOut className=\"size-4 rtl:-scale-x-100\" aria-hidden />\n        {otherSessions === 0\n          ? \"No other devices\"\n          : \"Sign out of all other devices\"}\n      </Button>\n    </Popconfirm>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}