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:
1 parent
d3531e1fac
commit
17473916a6
27 files changed
+1378
-73
No files matched your search
@@ -7,6 +7,11 @@ import type { CheckinResult, PublicContact, WelcomeCheckinPreview, WelcomeChecki
|
||||
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
/** How the scanner describes the number of labels a welcome check-in prints. */
|
||||
function printPhrase(copies: number): string {
|
||||
return copies > 1 ? `their badge ${copies} times` : 'this person’s label';
|
||||
}
|
||||
|
||||
export function Scan() {
|
||||
const { contact } = useAuth();
|
||||
const { slots, loading } = useEvent();
|
||||
@@ -20,6 +25,9 @@ export function Scan() {
|
||||
// A welcome scan is previewed first and only committed after the staff
|
||||
// confirms that they want to check the person in (and print their badge).
|
||||
const [pendingWelcome, setPendingWelcome] = useState<{ token: string; preview: WelcomeCheckinPreview } | null>(null);
|
||||
// A session scan for an attendee who has not been through the front desk
|
||||
// (welcome) check-in is blocked; we surface a dedicated sheet for it.
|
||||
const [frontDesk, setFrontDesk] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
@@ -80,7 +88,11 @@ export function Scan() {
|
||||
setConnectTarget({ contact: found, qr: token });
|
||||
}
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Something went wrong', 'err');
|
||||
const m = e instanceof Error ? e.message : 'Something went wrong';
|
||||
// The front-desk gate is a blocking state, not a transient error: show a
|
||||
// persistent sheet instead of a quick toast so staff can relay it.
|
||||
if (/front desk/i.test(m)) setFrontDesk(true);
|
||||
else toast(m, 'err');
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
@@ -169,7 +181,7 @@ export function Scan() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Scanner onResult={handleScan} paused={busy || !!connectTarget || !!checkin || !!pendingWelcome || !!welcome} label={activeStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
|
||||
<Scanner onResult={handleScan} paused={busy || !!connectTarget || !!checkin || !!pendingWelcome || !!welcome || frontDesk} label={activeStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
|
||||
{busy && <div className="center"><Spinner /></div>}
|
||||
{activeStaff && !welcomeMode && selSession && (
|
||||
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
|
||||
@@ -226,6 +238,21 @@ export function Scan() {
|
||||
)}
|
||||
</Sheet>
|
||||
|
||||
{/* Front-desk gate: session check-in blocked until a welcome check-in. */}
|
||||
<Sheet open={frontDesk} onClose={() => setFrontDesk(false)}>
|
||||
<div style={{ textAlign: 'center' }} data-testid="front-desk-required">
|
||||
<div style={{ fontSize: 52 }}>🛑</div>
|
||||
<h3 style={{ marginTop: 10 }}>Not checked in yet</h3>
|
||||
<p className="sub" style={{ marginTop: 8 }}>
|
||||
This attendee needs to be checked in at the front desk before they can be
|
||||
scanned into a session.
|
||||
</p>
|
||||
<button className="btn primary" style={{ marginTop: 18 }} data-testid="front-desk-ok" onClick={() => setFrontDesk(false)}>
|
||||
OK
|
||||
</button>
|
||||
</div>
|
||||
</Sheet>
|
||||
|
||||
{/* Welcome check-in confirmation (shown before checking in / printing) */}
|
||||
<Sheet open={!!pendingWelcome} onClose={() => !busy && setPendingWelcome(null)}>
|
||||
{pendingWelcome && (
|
||||
@@ -236,7 +263,7 @@ export function Scan() {
|
||||
{pendingWelcome.preview.already
|
||||
? 'Already checked in to the event.'
|
||||
: pendingWelcome.preview.will_print
|
||||
? `You are checking in ${pendingWelcome.preview.attendee_name}. By confirming, you will print this person's label.`
|
||||
? `You are checking in ${pendingWelcome.preview.attendee_name}. By confirming, you will print ${printPhrase(pendingWelcome.preview.copies)}.`
|
||||
: `You are checking in ${pendingWelcome.preview.attendee_name}.`}
|
||||
</p>
|
||||
{!pendingWelcome.preview.will_print && !pendingWelcome.preview.already && (
|
||||
|
||||
Reference in new issue
Block a user