fix(admin): per-row check-in toggle; feat(db): front-desk gate + badge copies

Registrations table felt buggy because both row actions did
setBusy(true) -> write -> reloadRegistrations() -> setBusy(false):
the list is sorted by points, so a reload made the row you just
touched jump (or vanish under a Checked-in filter), and the single
`busy` flag disabled every control in the table for the whole
request. The fix is per-row in-flight state (busyIds + withRowBusy)
and no reload at all: the toggle patches its own row's checked_in
plus the points delta the RPC returns, the type change patches
`type`; a rejected write rolls both back. Only the touched row is
disabled, shows a "Saving…" pulse, and two rows can save at once.
Toggle hit area is now 40x41 px with a focus-visible ring.

Front-desk gate: checkin_attendee reads registrations.checked_in
and raises "This attendee needs to be checked in at the front desk
first." when it is not true, and no longer sets checked_in as a
side effect. checkins has no INSERT policy, so the RPC is the only
write path and the gate cannot be bypassed. The scanner shows a
dedicated "Not checked in yet" sheet instead of a toast.

Badge copies: events.badge_copies (1..4, default 1). welcome_checkin
sends that many pgmq jobs in one transaction (the Pi prints one
label per job, so N jobs = N labels; no worker change) and clamps
the value again itself. preview_welcome_checkin gained a `copies`
column (drop + recreate) so the popup states the real count. Manual
reprint still prints exactly one. Set from Settings -> Badge
printing (active event) and the Events form, always as a
single-column update; the Settings badge section now renders even
when the LLM settings call fails.

Tests: badge_print 113 (+6), leaderboard 47 (+1), new
registration-checkin-toggle (6), front-desk-gate (3),
welcome-badge-copies (3); the stale registrations-PATCH mock in
registration-ticket-merge now targets set_registration_checked_in,
the ambiguous Save button is "Save copies", and the print-copy
assertion tolerates the typographic apostrophe. Docs updated
(rpcs, schema, printing, tests, admin-app, screens) with a release
record; NOT deployed - see docs/releases/2026-10-19.md.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-19 15:10:20 +02:00
1 parent d3531e1fac
commit 17473916a6
27 files changed
+1378 -73

No files matched your search

+11 -5
View File
@@ -16,15 +16,15 @@ It runs on **port 3001** (Vite dev) or as the `convivo-admin` Docker container
|---|---|
| **Dashboard** | Active event card (name, dates, location, aggregates: avg feedback, #sessions, #speakers, #registrations, #checked-in) + top points + recent activity. |
| **Contacts** | Table of all contacts (email, name, LinkedIn, visibility toggles, `is_admin`). Edit, toggle `is_admin`, set visibility, adjust points. (No QR token here — it lives on the registration.) A general search matches **first name, last name or email address**; the **LinkedIn**, **Visibility** and **Admin** columns each have an Excel-style **multi-select filter** with live counts. |
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. |
| **Registrations** | Per active event: list (contact, type, **QR token**, checked_in, points). Change type (enforces the sponsor rule — a failed sponsor change opens an **in-place sponsor lookup** popup), mark checked-in, **view the QR token** (final — no reset), and **preview the attendee's badge** (renders the event's badge layout with that row's own name / ticket type / QR token / company), plus a **Print** button that queues the badge on the print station ([../backend/printing.md](../backend/printing.md)). When the event has **no badge configured**, the Badge button stays visible but **grayed out**, and hovering it shows a tooltip explaining a badge must be designed first. A general search matches **first name, last name, email address or type**; the **Type**, **QR token** (ticket) and **Checked in** columns each have an Excel-style **multi-select filter** with live counts. The **checked-in toggle is per-row and optimistic**: it patches that one row (and its points) in place — **no list reload**, so rows never jump or vanish mid-edit (the list is sorted by points) — while a small "Saving…" pulse marks the busy row and only that checkbox is disabled; other rows stay live and a second row can be toggled concurrently. A rejected write rolls the row back to the server's values. Changing the type behaves the same way. The toggle is what grants front-desk eligibility from the console (see [../backend/rpcs.md](../backend/rpcs.md)). |
| **Sponsors** | List (paid only visible to attendees; admin sees all). Add/edit (type, name, email, phone, paid, amount, **contact search-and-pick**). |
| **Schedule** | Slots (with a **type optionset** — `Session` / `Service Session`) + sessions (with speakers 1:N via a **multi-select search dropdown**, material upload with a **submitted / not submitted** state and `average_feedback`), plus an admin-only **Delete current schedule** action for the active event. |
| **Activity** | Tables of check-ins, connections, and feedback (per active event), with manual **Generate AI Summary** controls for the event and individual sessions. |
| **Raffle** | Draws eligible attendees one at a time for the active event. Configure the number of picks (default 5), then **Spin** a roulette that decelerates onto a server-chosen winner; repeat until the pick count is reached. Excludes staff/Admin and the leaderboard top 3, and no one can win twice in a run. **New run** clears the current winners. See [../backend/rpcs.md#raffle](../backend/rpcs.md#raffle). |
| **Badges** | A **per-event WYSIWYG badge / PDF layout editor** (modelled on pretix's PDF Editor). Pick the event, then design one or more named **layouts** (a **Default** per event, switchable / creatable / deletable). Add **text boxes**, **QR codes** and **images** to a millimetre canvas; drag to move, use the 8 resize handles + rotation handle, **Shift-click to multi-select**, and **press `Del`** to remove. While dragging, **PowerPoint-style smart guides** appear — dashed alignment lines (edges / centres, page and neighbouring items) plus equal-spacing lines — and the element **snaps** to them. A **Word-style align** toolbar (left / center / right, top / middle / bottom) plus **PowerPoint-style** object alignment — align to the **page** or to the **selection**, and **distribute** horizontally / vertically — with the same controls in the properties panel. Text binds to attendee fields (name, email, ticket type, QR token, event name, **company / organizer**, or static) with font, size, line-height, colour, bold/italic, a labelled **Align text in box** section (horizontal left / center / right and vertical top / middle / bottom, inside the element's own frame) and case transform; QR binds to the token / check-in URL / email / name / static. **Undo/redo** (`Ctrl`+`Z` / `Ctrl`+`Y`, also `Ctrl`+`Shift`+`Z`), a **Preview** mode (no handles), a **JSON** view of the layout, and **Save**. Previewed against a real sample registration. See [../backend/rpcs.md#badge-editor](../backend/rpcs.md#badge-editor). |
| **Printing** | Badge-print control center: printer stations (add / inline **rename** / **revoke**, the `cvp_…` token shown **once** on creation), live station cards with state + staff hints, queue counters (pending / in flight / dead letters / completed), the last completed jobs with **Reprint**, and dead letters with **Requeue** / **Discard**. Backed by `get_print_overview` (polled every 5 s) — see [../backend/printing.md](../backend/printing.md). |
| **Settings** | Global LLM endpoint, model and optional API key for feedback summaries. |
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
| **Settings** | **Badge printing** section first: how many labels a front-desk (welcome) check-in prints for the **active event** — a 1–4 segmented picker (`events.badge_copies`), saving on its own single-column write with a "Copies saved" confirmation; it renders even when the LLM/sidecar call fails. Then the global LLM endpoint, model and optional API key for feedback summaries. See [../backend/printing.md](../backend/printing.md). |
| **Events** | Create event, toggle active/inactive (a switch; only one can be active at a time — activating one deactivates the rest), edit dates/location + the **Sessionize endpoint** + the **Real-time clock** toggle (on = the attendee app uses the real system clock for Live/Next/Done; off = the simulated mid-event clock, the default) + the **badge copies** picker (same 1–4 control as Settings). Each row has a **Sync** button that runs a (blocking) Sessionize sync and shows a result modal. |
| **Interfaces** | Manages the Sessionize sync **sidecar**: status (online / running / last run), a **Run sync** control (event picker + blocking run + result modal), an **Import Excel** control (upload the Sessionize "Sessions and speakers (advanced)" `.xlsx` + a "How to get this file" tooltip), and a **Recent runs** table from `sync_runs`. See [../backend/sidecar.md](../backend/sidecar.md). |
## Sessionize Source Editing
@@ -129,12 +129,18 @@ apps/admin/src/
├─ Sponsors.tsx # sponsor CRUD
├─ Schedule.tsx # slots + sessions + speakers + material
├─ Activity.tsx # check-ins / connections / feedback tables
├─ Events.tsx # event management (+ sessionize_endpoint + per-row Sync + talk networking bonus)
├─ Events.tsx # event management (+ sessionize_endpoint + per-row Sync + talk networking bonus + badge copies)
├─ Interfaces.tsx # sidecar status / run / recent runs
├─ Reports.tsx # post-event summary + CSV / Excel / PDF export (sidecar /export)
└─ Settings.tsx # server-only LLM configuration (redacted key)
└─ Settings.tsx # badge-print copies (active event) + server-only LLM configuration (redacted key)
```
Shared component: `components/BadgeCopiesSetting.tsx` exports the presentational
1–4 segmented picker (`BadgeCopiesPicker`), the clamping helper
(`clampBadgeCopies`) and the self-saving Settings card (`BadgeCopiesSetting`,
which writes `events.badge_copies` through `setBadgeCopies` — one column, so it
can never clobber the rest of the row).
## Data access
The admin app uses the **anon key + the admin's session JWT** — no service-role
+15 -3
View File
@@ -241,10 +241,22 @@ is role-aware — staff (`contact.is_admin`) default to **Staff** mode, attendee
no extra points" (the `already` flag from the RPC). The `checkin_attendee`
RPC also rejects a service session server-side ("service sessions cannot be
checked in").
**Front-desk gate:** if the lanyard belongs to someone the front desk has
not welcomed yet, the RPC refuses and the screen shows its own sheet —
**🛑 "Not checked in yet" / "…needs to be checked in at the front desk before
they can be scanned into a session."** — instead of a generic error toast.
Nothing is recorded and no points move; **OK** dismisses it and re-arms the
camera. The gate is enforced in the database, not here (see
[../backend/rpcs.md](../backend/rpcs.md)).
- **Welcome check-in** — no session dropdown; scanning an attendee's lanyard →
`welcomeCheckin(qr)` marks them present at the **event**
(`registrations.checked_in = true`, no points). Result sheet: "👋 {name} —
Welcome to the event! — ✓ Checked in" (or "Already checked in to the event").
read-only `previewWelcomeCheckin(qr)` → a **confirm sheet** ("You are
checking in {name}. By confirming, you will print their badge {N} times" /
"…this person's label" when `copies` is 1; the print sentence is dropped when
nothing would print) → **Yes** runs `welcomeCheckin(qr)`, which marks them
present at the **event** (`registrations.checked_in = true`, no points) and
queues `events.badge_copies` labels. Result sheet: "👋 {name} — Welcome to
the event! — ✓ Checked in" (or "Already checked in to the event"). This is
the scan that opens the session gate above.
Data: `useEvent()` (for the session list) + the RPCs above.