Skip to content

business.session.details.block

A block of your UI on the staff-facing page for one session, where a business manages who is coming and how the session runs.

SurfacebusinessSlotBlockWritesYes
Subject
The Session the page is for.
Viewer
Always a member of the business’s staff — the host refuses an extension API request for this target from anyone else.
API type
BusinessSessionDetailsBlockApi<Query>

Where it renders

At the foot of the staff session page, after the built-in sections.

At the foot of the activity overview for a single-date activity, which stands in for its one session.

Sessions’ default apps render first, then installed apps in install order — each extension in its own card, headed by the app’s icon, the extension’s name and “From <app>”.

The card’s “…” menu opens the app’s page in the business’s settings (/settings/apps/<handle>); for admins it can also hide the extension for the business, or uninstall the app. A hidden extension stops rendering on the next page load.

The api object

What this target’s module receives as its second argument. The target members come first; every target also has the standard members below them.

This target
api.session{readonly id: string}
The session this block renders beside. id is a Session global id — the same session the session root of the extension API resolves to.
api.mutate(operation, options?)<Data>(operation: string, options?: {variables?}) => Promise<{data: Data | null; errors?}>
Runs a mutation on the extension API as the signed-in staff member, attributed to your extension. api.query re-resolves afterwards on its own.
Every target
api.targetUIExtensionTarget
The target this module is rendering into — the literal name, so it narrows the rest of the API.
api.version'2026-09'
The extension API version the host speaks.
api.app{id: string; handle: string; name: string}
The app this extension belongs to.
api.extension{id: string; handle: string; name: string}
This extension.
api.localization.localeReadonlySignal<string>
The viewer’s BCP 47 locale (en, fr-CA). A signal: it changes when the viewer switches language without a reload, so read .value or .subscribe to it.
api.localization.translate(key, replacements?)(key: string, replacements?: Record<string, string | number>) => string
One of your own strings, from the translations/<locale>.json files pushed with the extension, in the viewer’s locale. key is a dot path; {{name}} placeholders are filled from replacements; a plural object is chosen by replacements.count. Falls back to the language, then en, then the key itself.
api.localization.formatNumber / formatDate / formatCurrency(value, options?) => string
Intl formatting in the viewer’s locale: formatNumber(value, options?), formatDate(value, options?) (a Date, an ISO string or epoch milliseconds; pass timeZone for the business’s wall-clock time), and formatCurrency(amount, currency) with amount in major units.
api.queryReadonlySignal<Query>
The result of the target’s live query — the GraphQL query you ship with the target, which Sessions stores, runs for you, and runs again as the data changes (after every api.mutate, and whenever the host page refreshes its own data). A signal: read .value while rendering to re-render with it. {} when the target declares no query.
api.ui.toast(message, options?)(message: string, options?: {tone?: 'critical'}) => void
Shows a toast on the host page, in the host’s own style.

Extension GraphQL API

What this target’s live query and mutations can use.

Query roots
Mutations
deleteMetadata

Guidance

Lead with the state the staff member came to see, then the controls to change it.

Write under your app’s metadata namespace, app.<your handle>.…; a buyer-facing target of the same extension can read it back.

Report the outcome of a mutation with api.ui.toast — the block is not a page and has no room for a success banner.

session-note
import {
  extension,
  useApi,
  useQuery,
  useSignal,
  useTranslate,
  Button,
  Stack,
  TextField,
} from '@sessions/apps/preact';

import saveNote from './SaveNoteMutation.graphql';
import type {SessionNoteQueryData} from './SessionNoteQuery.graphql';

export default extension('business.session.details.block', () => <NoteEditor />);

function NoteEditor() {
  const api = useApi<'business.session.details.block'>();
  const {session} = useQuery<SessionNoteQueryData>();
  const translate = useTranslate();
  // Signals: reading `.value` while rendering re-renders on change.
  const draft = useSignal(session?.note?.value ?? '');
  const saving = useSignal(false);

  async function save() {
    saving.value = true;
    // Typed by the .graphql.d.ts: variables are checked, data is typed.
    const result = await api.mutate(saveNote, {
      variables: {owner: {id: api.session.id}, value: draft.value},
    });
    saving.value = false;
    const failed = result.errors != null || !!result.data?.setMetadata.errors.length;
    api.ui.toast(translate(failed ? 'saveFailed' : 'saved'), {
      tone: failed ? 'critical' : undefined,
    });
  }

  return (
    <Stack gap="small">
      <TextField
        label={translate('label', {activity: session?.activity.name ?? ''})}
        value={draft.value}
        multiline
        onInput={(value) => (draft.value = value)}
      />
      <Button emphasis="strong" loading={saving.value} onClick={save}>
        {translate('save')}
      </Button>
    </Stack>
  );
}