{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pages-casework-how-review-works",
  "title": "Casework how review works page",
  "description": "How review works here, from Casework's review policies: the stages, who reviews at each, the deadlines, that a submitter never reviews their own request where a stage excludes its initiator, and the possible outcomes.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0"
  ],
  "registryDependencies": [
    "@registrystack/lib-content",
    "@registrystack/lib-format",
    "@registrystack/pages-casework-landing",
    "@registrystack/pages-casework-review-content",
    "@registrystack/shell-error-panel",
    "@registrystack/shell-loading",
    "@registrystack/shell-page-heading"
  ],
  "files": [
    {
      "path": "pages/casework-how-review-works.tsx",
      "content": "import type {\n  ReviewPolicyStage,\n  ReviewPolicySummary,\n} from \"@registrystack/app-runtime\";\nimport { useReviewPolicies } from \"@registrystack/app-runtime/react\";\nimport { useLocale } from \"@/blocks/lib/content\";\nimport { fill } from \"@/blocks/lib/format\";\nimport { WhenProfile } from \"@/blocks/pages/casework-landing\";\nimport {\n  useReviewPageContent,\n  type ReviewPageContent,\n} from \"@/blocks/pages/casework-review-content\";\nimport { ErrorPanel } from \"@/blocks/shell/error-panel\";\nimport { Loading } from \"@/blocks/shell/loading\";\nimport { PageHeading } from \"@/blocks/shell/page-heading\";\n\n/** The items joined with \"and\", as `locale` joins them. */\nfunction list(items: string[], locale: string): string {\n  return new Intl.ListFormat(locale, { type: \"conjunction\" }).format(items);\n}\n\nfunction Stage({\n  stage,\n  number,\n}: {\n  stage: ReviewPolicyStage;\n  number: number;\n}) {\n  const r = useReviewPageContent();\n  const locale = useLocale();\n  const profiles = [\n    ...new Set(\n      stage.decidingProfiles.map((id) => r.howProfiles[id] ?? r.howProfileUnnamed),\n    ),\n  ];\n  // An id reaches the screen only through the page content's wording; the\n  // queue label is Casework's own display text.\n  const name = r.howStageNames[stage.id] ?? (stage.queueLabel || undefined);\n  return (\n    <li className=\"flex flex-col gap-1\">\n      <h3>\n        {name\n          ? fill(r.howStage, { number: String(number), name }, locale)\n          : fill(r.howStageUnnamed, { number: String(number) }, locale)}\n      </h3>\n      <p>{fill(r.howQueue, { queue: stage.queueLabel }, locale)}</p>\n      <p>{fill(r.howReviewedBy, { profiles: list(profiles, locale) }, locale)}</p>\n      <p>\n        {fill(r.howApprovals, { count: stage.requiredApprovals }, locale)}\n      </p>\n      {stage.excludeInitiator && <p>{r.howExcludesSubmitter}</p>}\n      {stage.excludePreviousStageReviewers && <p>{r.howExcludesEarlier}</p>}\n    </li>\n  );\n}\n\nfunction Policy({\n  policy,\n  number,\n}: {\n  policy: ReviewPolicySummary;\n  number: number;\n}) {\n  const r: ReviewPageContent = useReviewPageContent();\n  const locale = useLocale();\n  const deadlines = policy.clocks.flatMap((id) => r.howDeadlineNames[id] ?? []);\n  const unnamedDeadlines = policy.clocks.some((id) => !r.howDeadlineNames[id]);\n  return (\n    <section className=\"flex flex-col gap-4\" aria-labelledby={`policy-${number}`}>\n      <h2 id={`policy-${number}`}>\n        {r.howPolicyNames[policy.id] ??\n          fill(r.howPolicyUnnamed, { number: String(number) }, locale)}\n      </h2>\n      <ol className=\"flex flex-col gap-4 ps-0 list-none\">\n        {policy.stages.map((stage, index) => (\n          <Stage key={`${stage.id}-${index}`} stage={stage} number={index + 1} />\n        ))}\n      </ol>\n      <div className=\"flex flex-col gap-1\">\n        <h3>{r.howDeadlines}</h3>\n        {policy.clocks.length === 0 ? (\n          <p className=\"muted\">{r.howDeadlinesNone}</p>\n        ) : (\n          <ul>\n            {deadlines.map((name) => (\n              <li key={name}>{name}</li>\n            ))}\n            {unnamedDeadlines && <li>{r.howDeadlineUnnamed}</li>}\n          </ul>\n        )}\n      </div>\n      <div className=\"flex flex-col gap-1\">\n        <h3>{r.howOutcomes}</h3>\n        <ul>\n          {policy.outcomes.map((outcome) => (\n            <li key={outcome.id}>\n              {fill(\n                r.howOutcome,\n                {\n                  label: outcome.label,\n                  meaning:\n                    r.howSettlements[outcome.settlement] ?? outcome.settlement,\n                },\n                locale,\n              )}\n            </li>\n          ))}\n        </ul>\n      </div>\n    </section>\n  );\n}\n\nfunction Policies() {\n  const r = useReviewPageContent();\n  const read = useReviewPolicies();\n  if (read.error)\n    return (\n      <ErrorPanel\n        error={read.error}\n        retry={() => void read.refetch()}\n        unavailableTitle={r.howUnavailable}\n      />\n    );\n  if (!read.data) return <Loading />;\n  if (read.data.items.length === 0) return <p className=\"muted\">{r.howNone}</p>;\n  return (\n    <div className=\"flex flex-col gap-8\">\n      {read.data.items.map((policy, index) => (\n        <Policy key={policy.id} policy={policy} number={index + 1} />\n      ))}\n    </div>\n  );\n}\n\n/**\n * How review works here, from Casework's own review policies: each policy's\n * stages in order, which profiles review at each, the deadlines that run,\n * that a submitter never reviews their own request where a stage excludes its\n * initiator, and how a review can end. The page counts nothing: it reads the\n * policies, never the tasks.\n */\nexport function CaseworkHowReviewWorksPage() {\n  const r = useReviewPageContent();\n  return (\n    <WhenProfile profiles={[\"staff\", \"supervisor\", \"administrator\"]}>\n      <PageHeading title={r.howTitle} description={r.howDescription} />\n      <Policies />\n    </WhenProfile>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/pages/casework-how-review-works.tsx"
    }
  ],
  "type": "registry:block"
}