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

+44 -1
View File
@@ -238,7 +238,9 @@ select pg_temp.assert_bp(
(select count(*) = 1 from pgmq.q_badge_print), 'event without a layout enqueues nothing');
update public.events set is_active = true where id = 'b9d00001-0000-0000-0000-00000000000a';
-- The regular session check-in must not print badges.
-- The regular session check-in must not print badges. It now requires a prior
-- front-desk (welcome) check-in, so mark the attendee checked in first.
update public.registrations set checked_in = true where contact_email = '[email protected]';
select public.checkin_attendee('b9d00003-0000-0000-0000-00000000000a', 'BPQR-ATT-3');
select pg_temp.assert_bp(
(select count(*) = 1 from public.checkins where session_id = 'b9d00003-0000-0000-0000-00000000000a'),
@@ -246,6 +248,18 @@ select pg_temp.assert_bp(
select pg_temp.assert_bp(
(select count(*) = 1 from pgmq.q_badge_print), 'session check-in enqueues nothing');
-- Front-desk gate: an attendee not checked in at the event cannot be scanned
-- into a session (raises a clear message, records nothing).
do $$ begin
begin
perform public.checkin_attendee('b9d00003-0000-0000-0000-00000000000a', 'BPQR-ATT-5');
raise exception 'front-desk gate allowed a session check-in';
exception when raise_exception then
if sqlerrm not like '%front desk%' then raise; end if;
end;
perform pg_temp.assert_bp(true, 'session check-in requires a front-desk check-in');
end; $$;
-- A direct write of checked_in (admin edit) must not print badges either.
update public.registrations set checked_in = true where contact_email = '[email protected]';
select pg_temp.assert_bp(
@@ -262,6 +276,20 @@ select pg_temp.assert_bp(
(select not checked_in from public.registrations where contact_email = '[email protected]'),
'rolled back check-in leaves the attendee unchecked');
-- Badge copies: a welcome check-in prints events.badge_copies labels (default
-- 1 is covered by the first check-in above). Isolated in a savepoint so the
-- queue returns to one for the rest of the run.
savepoint bp_copies;
update public.events set badge_copies = 3 where id = 'b9d00001-0000-0000-0000-00000000000a';
select public.welcome_checkin('BPQR-ATT-5');
select pg_temp.assert_bp(
(select count(*) = 4 from pgmq.q_badge_print),
'welcome check-in enqueues badge_copies (3) labels');
rollback to savepoint bp_copies;
select pg_temp.assert_bp(
(select count(*) = 1 from pgmq.q_badge_print),
'copies test rolled back cleanly');
-- -----------------------------------------------------------------------------
-- 2b. WELCOME CHECK-IN PREVIEW (read-only: resolves the name + will_print)
-- -----------------------------------------------------------------------------
@@ -291,6 +319,21 @@ select pg_temp.assert_bp(
(select already = true and will_print = false from bp_prev2),
'preview of a checked-in attendee reports no print');
-- The preview also states how many labels a confirm would print, so the scanner
-- popup can be truthful about the copy count instead of "this person's label".
select pg_temp.assert_bp(
(select copies = 1 from bp_prev1),
'preview reports copies = 1 by default');
select pg_temp.assert_bp(
(select copies = 0 from bp_prev2),
'preview reports no copies when nothing will print');
savepoint bp_prev_copies;
update public.events set badge_copies = 3 where id = 'b9d00001-0000-0000-0000-00000000000a';
select pg_temp.assert_bp(
(select copies = 3 from public.preview_welcome_checkin('BPQR-ATT-5')),
'preview reports the event badge_copies');
rollback to savepoint bp_prev_copies;
-- An event without a badge layout: check-in would work but nothing prints.
-- (bp-attb was checked in by the section-2 scan; reset it so the preview
-- isolates the "no layout" reason rather than "already checked in".)