ui/format_scope.ts

Shared format_scope callback contract for permit-display components.

Permits and offers carry a scope_id that names a consumer-owned resource (e.g. a classroom uuid). The default render is the raw uuid. Consumers wire a FormatScope via context to render a human label without per-page lookup or forking the components.

Declarations
#

4 declarations

view source

default_format_scope
#

ui/format_scope.ts view source

(args: { scope_id: string | null; role: string; }): string | null

Default FormatScope — always returns null so callers fall back to the raw uuid.

args

type { scope_id: string | null; role: string; }

returns

string | null

format_scope_context
#

FormatScope
#

ui/format_scope.ts view source

FormatScope

Render a {scope_id, role} pair as a human label. Return null to fall back to the raw scope uuid (or a caller-chosen global_label when scope_id is null).

Returning null for unknown scope ids (stale cache, revoked resource) is the recommended pattern — components show the raw uuid rather than a misleading blank.

resolve_scope_label
#

ui/format_scope.ts view source

<G extends string | null>(scope_id: string | null, role: string, format_scope: FormatScope, global_label: G): string | G

Resolve a scope label across the context → raw-uuid fallback chain.

global_label is returned for scope_id === null. Callers pass null to render no chip (admin tables — global is the implicit default) or 'global' for explicit labels (offer surfaces). The return type propagates null only when global_label is null.

scope_id

type string | null

role

type string

format_scope

global_label

type G

returns

string | G

Depends on
#

Imported by
#