{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"integration-cards-sync-status","type":"registry:component","title":"Integration cards · Sync status","description":"Sync health with run-history bars, a failure notice that collapses on retry, a live record counter and an auto-sync switch.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":[],"files":[{"path":"registry/geturui/examples/integration-cards/sync-status.tsx","type":"registry:component","target":"components/examples/integration-cards/sync-status.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { CheckCircle2, LoaderCircle, OctagonAlert, RefreshCw } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SyncRun {\n  id: string;\n  /** e.g. \"Oct 2, 09:14\". */\n  at: string;\n  ok: boolean;\n  /** Seconds the run took; sets the bar height. */\n  seconds: number;\n}\n\nexport interface SyncStatusCardProps {\n  app?: string;\n  appMonogram?: string;\n  runs?: SyncRun[];\n  /** Shown while the latest run is failed. */\n  error?: string;\n  records?: number;\n  /** Records the simulated retry syncs. */\n  retryRecords?: number;\n  /** Timestamp label the retry run gets. */\n  retryAt?: string;\n  nextRun?: string;\n  defaultAutoSync?: boolean;\n  /** Resolve when your real retry finishes; defaults to a simulated run. */\n  onRetry?: () => Promise<void> | void;\n  onAutoSyncChange?: (on: boolean) => void;\n  className?: string;\n}\n\nconst spring = { type: \"spring\", stiffness: 380, damping: 32 } as const;\nconst nf = new Intl.NumberFormat(\"en-US\");\n\n/** Sync health card: run history bars, a failure that collapses away on retry, a live record counter and an auto-sync switch. */\nexport function SyncStatusCard({\n  app = \"Ledgerly\",\n  appMonogram = \"L\",\n  runs = [\n    { id: \"r1\", at: \"Sep 30, 06:00\", ok: true, seconds: 42 },\n    { id: \"r2\", at: \"Sep 30, 12:00\", ok: true, seconds: 38 },\n    { id: \"r3\", at: \"Sep 30, 18:00\", ok: true, seconds: 51 },\n    { id: \"r4\", at: \"Oct 1, 00:00\", ok: true, seconds: 29 },\n    { id: \"r5\", at: \"Oct 1, 06:00\", ok: true, seconds: 44 },\n    { id: \"r6\", at: \"Oct 1, 12:00\", ok: false, seconds: 12 },\n    { id: \"r7\", at: \"Oct 1, 18:00\", ok: true, seconds: 63 },\n    { id: \"r8\", at: \"Oct 2, 00:00\", ok: true, seconds: 35 },\n    { id: \"r9\", at: \"Oct 2, 06:00\", ok: true, seconds: 40 },\n    { id: \"r10\", at: \"Oct 2, 09:14\", ok: false, seconds: 9 },\n  ],\n  error = \"Ledgerly rejected 3 invoices with a missing tax ID. Fix them or retry to skip them.\",\n  records = 12480,\n  retryRecords = 318,\n  retryAt = \"Oct 2, 09:41\",\n  nextRun = \"12:00\",\n  defaultAutoSync = true,\n  onRetry,\n  onAutoSyncChange,\n  className,\n}: SyncStatusCardProps) {\n  const reduce = useReducedMotion();\n  const [history, setHistory] = React.useState(runs);\n  const [phase, setPhase] = React.useState<\"idle\" | \"syncing\">(\"idle\");\n  const [synced, setSynced] = React.useState(0);\n  const [auto, setAuto] = React.useState(defaultAutoSync);\n  const last = history[history.length - 1];\n  const failed = !last.ok;\n  const max = Math.max(...history.map((r) => r.seconds));\n  const autoId = React.useId();\n  const [extra, setExtra] = React.useState(0);\n  const runNo = React.useRef(0);\n  const total = records + extra;\n\n  const finish = React.useCallback(() => {\n    runNo.current += 1;\n    const id = `retry-${runNo.current}`;\n    setHistory((h) => [...h.slice(1), { id, at: retryAt, ok: true, seconds: 31 }]);\n    setExtra((e) => e + retryRecords);\n    setPhase(\"idle\");\n  }, [retryAt, retryRecords]);\n\n  React.useEffect(() => {\n    if (phase !== \"syncing\" || onRetry) return;\n    if (synced >= retryRecords) {\n      const id = window.setTimeout(finish, 250);\n      return () => window.clearTimeout(id);\n    }\n    const id = window.setTimeout(() => setSynced((n) => Math.min(retryRecords, n + Math.ceil(retryRecords / 18))), 70);\n    return () => window.clearTimeout(id);\n  }, [phase, synced, retryRecords, onRetry, finish]);\n\n  async function retry() {\n    setSynced(0);\n    setPhase(\"syncing\");\n    if (onRetry) {\n      await onRetry();\n      finish();\n    }\n  }\n\n  const pill =\n    phase === \"syncing\"\n      ? { cls: \"bg-info/12 text-info\", Icon: LoaderCircle, label: \"Syncing\", spin: true }\n      : failed\n        ? { cls: \"bg-danger/12 text-danger\", Icon: OctagonAlert, label: \"Failed\", spin: false }\n        : { cls: \"bg-success/12 text-success\", Icon: CheckCircle2, label: \"Healthy\", spin: false };\n\n  return (\n    <div className={cn(\"w-full max-w-[400px] rounded-lg border border-border bg-surface-raised p-4 shadow-sm\", className)}>\n      <div className=\"flex items-center gap-3\">\n        <span aria-hidden className=\"grid size-10 shrink-0 place-items-center rounded-md bg-ink font-display text-[16px] font-bold text-bg\">\n          {appMonogram}\n        </span>\n        <div className=\"min-w-0 flex-1\">\n          <p className=\"text-[14px] font-medium text-ink\">{app} sync</p>\n          <p className=\"text-xs text-ink-subtle\">\n            Last run <span className=\"font-mono tabular-nums\">{last.at}</span>\n          </p>\n        </div>\n        <AnimatePresence mode=\"popLayout\" initial={false}>\n          <motion.span\n            key={pill.label}\n            role=\"status\"\n            initial={{ opacity: 0, scale: 0.85, filter: \"blur(6px)\" }}\n            animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n            exit={{ opacity: 0, scale: 0.85, filter: \"blur(6px)\" }}\n            transition={spring}\n            className={cn(\"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium\", pill.cls)}\n          >\n            <pill.Icon aria-hidden className={cn(\"size-3\", pill.spin && \"animate-spin\")} />\n            {pill.label}\n          </motion.span>\n        </AnimatePresence>\n      </div>\n\n      <AnimatePresence initial={false}>\n        {failed && phase === \"idle\" && (\n          <motion.div\n            initial={{ height: 0, opacity: 0 }}\n            animate={{ height: \"auto\", opacity: 1 }}\n            exit={{ height: 0, opacity: 0 }}\n            transition={reduce ? { duration: 0 } : spring}\n            className=\"overflow-hidden\"\n          >\n            <p className=\"mt-3.5 flex gap-2 rounded-md border border-danger/25 bg-danger/8 p-3 text-[12.5px] leading-relaxed text-ink\">\n              <OctagonAlert aria-hidden className=\"mt-0.5 size-4 shrink-0 text-danger\" />\n              {error}\n            </p>\n          </motion.div>\n        )}\n      </AnimatePresence>\n\n      <dl className=\"mt-4 grid grid-cols-2 gap-3\">\n        <div className=\"rounded-md bg-surface-sunken p-3\">\n          <dt className=\"text-[11px] text-ink-subtle\">{phase === \"syncing\" ? \"Records this run\" : \"Records synced\"}</dt>\n          <dd className=\"mt-0.5 font-mono text-[18px] font-medium text-ink tabular-nums\">{nf.format(phase === \"syncing\" ? synced : total)}</dd>\n        </div>\n        <div className=\"rounded-md bg-surface-sunken p-3\">\n          <dt className=\"text-[11px] text-ink-subtle\">Next scheduled run</dt>\n          <dd className=\"mt-0.5 font-mono text-[18px] font-medium text-ink tabular-nums\">{auto ? nextRun : \"Paused\"}</dd>\n        </div>\n      </dl>\n\n      <div className=\"mt-4\">\n        <p className=\"mb-2 flex justify-between text-[11px] text-ink-subtle\">\n          <span>Last {history.length} runs</span>\n          <span>\n            <span className=\"font-mono tabular-nums\">{history.filter((r) => !r.ok).length}</span> failed\n          </span>\n        </p>\n        <ol className=\"flex h-12 items-end gap-1\">\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            {history.map((r) => (\n              <motion.li\n                key={r.id}\n                layout\n                initial={{ opacity: 0, scaleY: reduce ? 1 : 0 }}\n                animate={{ opacity: 1, scaleY: 1 }}\n                exit={{ opacity: 0, scaleX: 0 }}\n                transition={spring}\n                title={`${r.at} · ${r.ok ? \"Succeeded\" : \"Failed\"} · ${r.seconds}s`}\n                className={cn(\"flex-1 origin-bottom rounded-[3px]\", r.ok ? \"bg-ink/20\" : \"bg-danger\")}\n                style={{ height: `${Math.max(14, (r.seconds / max) * 100)}%` }}\n              >\n                <span className=\"sr-only\">\n                  {r.at}: {r.ok ? \"succeeded\" : \"failed\"} in {r.seconds} seconds\n                </span>\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ol>\n      </div>\n\n      <div className=\"mt-4 flex items-center gap-3 border-t border-border pt-4\">\n        <label htmlFor={autoId} className=\"flex flex-1 cursor-pointer items-center gap-2.5 text-[12.5px] text-ink-muted\">\n          <button\n            id={autoId}\n            type=\"button\"\n            role=\"switch\"\n            aria-checked={auto}\n            onClick={() => {\n              setAuto(!auto);\n              onAutoSyncChange?.(!auto);\n            }}\n            className={cn(\"relative h-6 w-10 shrink-0 rounded-full p-0.5 outline-none transition-colors focus-visible:shadow-[var(--focus-ring)]\", auto ? \"bg-ink\" : \"bg-ink/15\")}\n          >\n            <motion.span layout transition={spring} className={cn(\"block size-5 rounded-full bg-surface-raised shadow-sm\", auto && \"ml-auto\")} />\n          </button>\n          Auto-sync every 6 hours\n        </label>\n        <motion.button\n          type=\"button\"\n          whileTap={{ scale: 0.96 }}\n          disabled={phase === \"syncing\"}\n          onClick={retry}\n          className={cn(\n            \"inline-flex h-9 items-center gap-1.5 rounded-full px-4 text-[13px] font-medium outline-none transition-colors focus-visible:shadow-[var(--focus-ring)] disabled:opacity-70\",\n            failed ? \"bg-volt text-on-volt\" : \"border border-border-strong text-ink hover:bg-surface-hover\",\n          )}\n        >\n          <RefreshCw aria-hidden className={cn(\"size-3.5\", phase === \"syncing\" && \"animate-spin\")} />\n          {phase === \"syncing\" ? \"Syncing…\" : failed ? \"Retry sync\" : \"Sync now\"}\n        </motion.button>\n      </div>\n    </div>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["examples","integrations","apps","connect","oauth","permissions","sync","status","settings"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/integration-cards#sync-status"}}