{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "request-status",
  "title": "Request command feedback",
  "description": "Renders the pending, unresolved, refused and confirmed states of a command run against a request, and a notice for an approved outcome the record has not yet applied.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0",
    "lucide-react@1.43.0"
  ],
  "registryDependencies": [
    "@registrystack/ui-button",
    "@registrystack/lib-notice",
    "@registrystack/lib-content",
    "@registrystack/lib-format"
  ],
  "files": [
    {
      "path": "request/request-status.tsx",
      "content": "import type { ReactNode } from \"react\";\nimport { ArrowRight } from \"lucide-react\";\nimport type { RequestView } from \"@registrystack/app-runtime\";\nimport { problemView } from \"@registrystack/app-runtime\";\nimport { Button } from \"@/components/ui/button\";\nimport { fillNodes } from \"@/blocks/lib/format\";\nimport { Notice } from \"@/blocks/lib/notice\";\nimport {\n  ConfirmedReceipt,\n  useBlockContent,\n  useLocale,\n} from \"@/blocks/lib/content\";\n\n/**\n * The state of the case, stated before the h1. The caller supplies the\n * sentence, because only it knows the lifecycle.\n */\nexport function StateNotice({\n  state,\n  description,\n}: {\n  state: string;\n  description: string;\n}) {\n  return (\n    <Notice tone={state === \"applied\" ? \"success\" : \"info\"}>\n      <p>{description}</p>\n    </Notice>\n  );\n}\n\n/**\n * A decision a reviewer has neither applied nor let expire. The host reads\n * such a request as approved from BReg's own fields, in a list and on the\n * request page alike.\n */\nexport function approvedNotApplied(request: RequestView | undefined): boolean {\n  return request?.state === \"approved\";\n}\n\n/**\n * The outcome of one command: a plain write, a decision, an upload. Shaped\n * like the runtime's own task state, but with the write's own attempt\n * reference renamed, since a block never keeps or compares an attempt id\n * itself, only shows the one its caller hands it.\n */\nexport interface CommandOutcome {\n  pending: boolean;\n  unknown: boolean;\n  error: Error | null;\n  reference: string | null;\n  retry: () => Promise<unknown>;\n  result:\n    | {\n        outcome: \"confirmed\";\n        receipt: string;\n        resource?: { id: string; entity: string };\n      }\n    | { outcome: \"unknown\" }\n    | null;\n}\n\n/**\n * A command's pending, unconfirmed, failed or confirmed state, in one place\n * so every command in a request (a decision, an upload, a plain write) reads\n * the same way. A plain error is handed to the caller's own error display,\n * since a block carries no protocol-level problem classification.\n */\nexport function CommandFeedback({\n  task,\n  reconcileHref,\n  renderError,\n  onConfirmed,\n  confirmedLabel,\n}: {\n  task: CommandOutcome;\n  reconcileHref: string;\n  renderError: (error: Error) => ReactNode;\n  onConfirmed?: (id: string) => void;\n  confirmedLabel?: string;\n}) {\n  const c = useBlockContent();\n  const locale = useLocale();\n  const result = task.result;\n  const retry = problemView(task.error);\n  if (task.pending) return <Notice>{c.saving}</Notice>;\n  if (task.unknown)\n    return (\n      <Notice tone=\"warning\" title={c.unknownTitle}>\n        <p>{c.unknownBody}</p>\n        {retry.status !== null && (\n          <p>\n            {c.retryRefused}\n            {retry.message !== null && ` ${retry.message}`}\n          </p>\n        )}\n        <p className=\"reference\">\n          {fillNodes(\n            c.labelled,\n            {\n              label: c.receipt,\n              value: <span className=\"font-mono\">{task.reference}</span>,\n            },\n            locale,\n          )}\n        </p>\n        <div className=\"actions\">\n          <Button onClick={() => void task.retry()}>{c.exactRetry}</Button>\n          <Button render={<a href={reconcileHref} />} variant=\"outline\">\n            {c.reconcile}\n          </Button>\n        </div>\n      </Notice>\n    );\n  if (task.error) return renderError(task.error);\n  if (result?.outcome === \"confirmed\")\n    return (\n      <Notice tone=\"success\" title={c.confirmed}>\n        <ConfirmedReceipt receipt={result.receipt} />\n        {onConfirmed && result.resource && (\n          <Button onClick={() => onConfirmed(result.resource!.id)}>\n            {confirmedLabel ?? c.openRequest}\n            <ArrowRight />\n          </Button>\n        )}\n      </Notice>\n    );\n  return null;\n}\n",
      "type": "registry:block",
      "target": "@components/request/request-status.tsx"
    }
  ],
  "type": "registry:block"
}