{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-retry",
  "title": "Button: corporate sync",
  "description": "An example of Button: corporate sync.",
  "dependencies": [],
  "registryDependencies": [
    "@keyline-ui/button",
    "@keyline-ui/keyline"
  ],
  "files": [
    {
      "path": "src/registry/keyline/examples/button-retry.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { Button } from \"../ui/button\";\n\ntype Signal = \"idle\" | \"pending\" | \"done\" | \"failed\";\n\nexport function CorporateSync() {\n  const [signal, setSignal] = useState<Signal>(\"idle\");\n  const attempts = useRef(0);\n  const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n  useEffect(() => () => clearTimeout(timer.current), []);\n\n  const sync = () => {\n    setSignal(\"pending\");\n    attempts.current += 1;\n    // for the demo, the first attempt fails and the second goes through\n    const fails = attempts.current === 1;\n    timer.current = setTimeout(() => setSignal(fails ? \"failed\" : \"done\"), 1000);\n  };\n\n  return (\n    <div className=\"grid gap-4\">\n      <Button signal={signal} onClick={sync} className=\"justify-self-start\">\n        {signal === \"failed\" ? \"Try again\" : \"Send 3 orders to corporate\"}\n      </Button>\n      <p role=\"status\" className=\"m-0 min-h-10 max-w-[48ch] text-[14px] text-kl-ink-2\">\n        {signal === \"pending\" && \"Sending to the New York office…\"}\n        {signal === \"failed\" && \"Corporate didn’t answer. The 3 orders are still saved here; try again.\"}\n        {signal === \"done\" && \"Sent. Corporate has orders DM-4102, DM-4087 and DM-4120.\"}\n        {signal === \"idle\" && \"3 orders are waiting for the end-of-day sync.\"}\n      </p>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/keyline/examples/button-retry.tsx"
    }
  ],
  "categories": [
    "button"
  ],
  "type": "registry:block"
}