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
@@ -0,0 +1,108 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { setBadgeCopies } from '../lib/api';
|
||||
|
||||
/** Number of labels a welcome check-in can print, per the DB check constraint. */
|
||||
export const BADGE_COPIES_MIN = 1;
|
||||
export const BADGE_COPIES_MAX = 4;
|
||||
|
||||
export function clampBadgeCopies(n: number): number {
|
||||
return Number.isFinite(n) ? Math.max(BADGE_COPIES_MIN, Math.min(BADGE_COPIES_MAX, Math.round(n))) : BADGE_COPIES_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Presentational 1..4 picker. Two consumers on purpose:
|
||||
* - the Events form holds this in its own state, so Cancel still cancels;
|
||||
* - `BadgeCopiesSetting` wraps it for the Settings view, which saves at once.
|
||||
*/
|
||||
export function BadgeCopiesPicker({ value, onChange, disabled = false, labelId }: {
|
||||
value: number;
|
||||
onChange: (v: number) => void;
|
||||
disabled?: boolean;
|
||||
labelId?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="seg seg-num" role="group" aria-labelledby={labelId} data-testid="badge-copies">
|
||||
{[1, 2, 3, 4].map((n) => (
|
||||
<button
|
||||
key={n}
|
||||
type="button"
|
||||
className={value === n ? 'active' : ''}
|
||||
aria-pressed={value === n}
|
||||
disabled={disabled}
|
||||
onClick={() => onChange(n)}
|
||||
>
|
||||
{n}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const HELP = 'How many labels print when an attendee is welcomed in at the front desk';
|
||||
|
||||
/**
|
||||
* Badge copies on welcome check-in (1..4, default 1) for one event.
|
||||
* `events.badge_copies` drives `welcome_checkin`, which enqueues that many
|
||||
* labels; a manual reprint from Registrations always prints one.
|
||||
*
|
||||
* Saves immediately through `setBadgeCopies` — a scoped single-column update,
|
||||
* so it can never overwrite another event field the rest of the UI holds stale.
|
||||
*/
|
||||
export function BadgeCopiesSetting({ eventId, initialCopies, eventName }: {
|
||||
eventId: string;
|
||||
initialCopies: number;
|
||||
eventName?: string;
|
||||
}) {
|
||||
const [copies, setCopies] = useState(clampBadgeCopies(initialCopies));
|
||||
const [saved, setSaved] = useState<number | null>(clampBadgeCopies(initialCopies));
|
||||
const [committed, setCommitted] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Follow the event when the caller switches to a different one.
|
||||
useEffect(() => {
|
||||
const next = clampBadgeCopies(initialCopies);
|
||||
setCopies(next);
|
||||
setSaved(next);
|
||||
setCommitted(false);
|
||||
setError(null);
|
||||
}, [eventId, initialCopies]);
|
||||
|
||||
const dirty = copies !== saved;
|
||||
|
||||
async function save() {
|
||||
if (busy || !dirty) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
await setBadgeCopies(eventId, copies);
|
||||
setSaved(copies);
|
||||
setCommitted(true);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Could not save');
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="field">
|
||||
<div className="row between" style={{ alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
|
||||
<div>
|
||||
<label id="badge-copies-label">Badge copies on welcome check-in</label>
|
||||
<div className="muted small" style={{ marginTop: 2, maxWidth: 460 }}>
|
||||
{HELP}{eventName ? <> for <b>{eventName}</b></> : null}. Manual reprints from the
|
||||
Registrations view always print one.
|
||||
</div>
|
||||
</div>
|
||||
<div className="row" style={{ gap: 10, alignItems: 'center' }}>
|
||||
<BadgeCopiesPicker value={copies} onChange={setCopies} disabled={busy} labelId="badge-copies-label" />
|
||||
<button className="btn" type="button" disabled={busy || !dirty} onClick={save} data-testid="badge-copies-save">
|
||||
{busy ? 'Saving…' : dirty ? 'Save copies' : committed ? 'Copies saved' : 'Save copies'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{error && <p className="feedback-error" role="alert" style={{ marginTop: 8 }}>{error}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -233,6 +233,7 @@ export async function upsertEvent(
|
||||
pretix_api_key?: string | null;
|
||||
use_realtime_clock?: boolean;
|
||||
talk_networking_bonus?: number;
|
||||
badge_copies?: number;
|
||||
},
|
||||
): Promise<void> {
|
||||
if (id) {
|
||||
@@ -244,6 +245,18 @@ export async function upsertEvent(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set how many badge labels a welcome (front-desk) check-in prints for one
|
||||
* event. Scoped update on purpose: it touches only this column, so it can never
|
||||
* overwrite another field the Events form happens to hold stale values for.
|
||||
* Clamped to 1..4 in the database (events.badge_copies check constraint).
|
||||
*/
|
||||
export async function setBadgeCopies(eventId: string, copies: number): Promise<void> {
|
||||
const value = Math.max(1, Math.min(4, Math.round(copies) || 1));
|
||||
const { error } = await supabase.from('events').update({ badge_copies: value }).eq('id', eventId);
|
||||
if (error) throw new ApiError(error.message);
|
||||
}
|
||||
|
||||
// ---- Sessionize sync (sidecar) ---------------------------------------------
|
||||
// The sidecar is a separate Docker service (not Supabase), so these use raw
|
||||
// fetch against the same-origin /sidecar proxy (see nginx.conf.template).
|
||||
|
||||
@@ -65,6 +65,8 @@ export interface Event {
|
||||
last_synced_at: string | null;
|
||||
/** Bonus points each party earns for a connection when they shared a checked-in talk (0 = off). */
|
||||
talk_networking_bonus: number;
|
||||
/** How many badge labels a welcome (front-desk) check-in prints, 1..4. */
|
||||
badge_copies?: number;
|
||||
avg_feedback: number | null;
|
||||
num_sessions: number;
|
||||
num_speakers: number;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
.llm-settings { display: grid; gap: 18px; max-width: 640px; padding: 20px 0; border-top: 1px solid var(--line); }
|
||||
/* Same rhythm as .llm-settings, for standalone (non-form) settings blocks.
|
||||
No top border: it sits above the bordered .llm-settings block. */
|
||||
.settings-section { display: grid; gap: 18px; max-width: 640px; padding: 20px 0; }
|
||||
.feedback-summary { width: 100%; min-width: 0; padding: 16px 0; border-bottom: 1px solid var(--line); }
|
||||
.feedback-summary-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
|
||||
.feedback-summary-head > div { min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
|
||||
@@ -301,6 +304,8 @@ table.data tr:hover td { background: rgba(244,245,249,.6); }
|
||||
font-weight: 700; font-size: 13.5px; cursor: pointer; font-family: inherit; white-space: nowrap;
|
||||
}
|
||||
.seg button.active { background: var(--accent-soft); color: var(--accent); }
|
||||
/* Compact numeric segment (badge copies): fixed-width buttons, comfortable targets. */
|
||||
.seg.seg-num button { flex: 0 0 auto; min-width: 44px; padding: 10px 0; text-align: center; }
|
||||
|
||||
/* ---------- QR ---------- */
|
||||
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
|
||||
@@ -343,7 +348,12 @@ table.data tr:hover td { background: rgba(244,245,249,.6); }
|
||||
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
|
||||
|
||||
/* ---------- Toggle switch ---------- */
|
||||
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
|
||||
/* The vertical padding (cancelled by equal negative margins) grows the clickable
|
||||
area of a 40x23 switch to ~40x41 without changing the row's visual height. */
|
||||
.toggle {
|
||||
display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
|
||||
padding: 9px 0; margin: -9px 0;
|
||||
}
|
||||
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
|
||||
.toggle .track {
|
||||
width: 40px; height: 23px; border-radius: 999px; background: #d5d8e2; position: relative;
|
||||
@@ -355,8 +365,24 @@ table.data tr:hover td { background: rgba(244,245,249,.6); }
|
||||
}
|
||||
.toggle input:checked + .track { background: var(--accent); }
|
||||
.toggle input:checked + .track .knob { transform: translateX(17px); }
|
||||
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
|
||||
.toggle input:disabled + .track { opacity: .45; cursor: default; }
|
||||
.toggle-lbl { font-size: 13px; font-weight: 600; color: var(--text); }
|
||||
|
||||
/* ---------- Per-row write state (Registrations table) ---------- */
|
||||
/* Only the row with a request in flight is marked. Deliberately light so the
|
||||
row stays readable; the point is "this one is saving", not "table frozen". */
|
||||
table.data tr.row-busy td { background: rgba(244,245,249,.85); }
|
||||
.row-saving {
|
||||
font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap;
|
||||
animation: row-saving-pulse 1s ease-in-out infinite;
|
||||
}
|
||||
@keyframes row-saving-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.row-saving { animation: none; opacity: .8; }
|
||||
.toggle .track, .toggle .knob { transition: none; }
|
||||
}
|
||||
|
||||
/* ---------- Event card (dashboard) ---------- */
|
||||
.event-card {
|
||||
background: linear-gradient(135deg, rgba(213,0,0,.1), rgba(32,178,170,.08));
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import type { Event, PretixOptions, PretixSyncResult, SyncResult } from '../lib/types';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { Empty, Modal, Spinner, Toggle } from '../components/ui';
|
||||
import { BadgeCopiesPicker, clampBadgeCopies } from '../components/BadgeCopiesSetting';
|
||||
import { normalizeSessionizeSource } from '../lib/sessionizeSource';
|
||||
|
||||
export function Events() {
|
||||
@@ -297,6 +298,7 @@ function EventModal({
|
||||
const [pretixError, setPretixError] = useState<string | null>(null);
|
||||
const [realtimeClock, setRealtimeClock] = useState(event?.use_realtime_clock ?? false);
|
||||
const [talkBonus, setTalkBonus] = useState(event?.talk_networking_bonus ?? 2);
|
||||
const [badgeCopies, setBadgeCopies] = useState(event?.badge_copies ?? 1);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const lastFetchedKey = useRef<string | null>(null);
|
||||
|
||||
@@ -353,6 +355,7 @@ function EventModal({
|
||||
pretix_api_key: pretixApiKey.trim() || null,
|
||||
use_realtime_clock: realtimeClock,
|
||||
talk_networking_bonus: Math.max(0, Math.min(10, Math.round(talkBonus) || 0)),
|
||||
badge_copies: clampBadgeCopies(badgeCopies),
|
||||
});
|
||||
onSaved(event ? 'Event updated' : 'Event created');
|
||||
} catch (e) {
|
||||
@@ -537,6 +540,24 @@ function EventModal({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<div className="row between" style={{ alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
|
||||
<div>
|
||||
<label id="event-badge-copies-label">Badge copies on welcome check-in</label>
|
||||
<div className="muted small" style={{ marginTop: 2, maxWidth: 420 }}>
|
||||
How many labels print when an attendee is welcomed in at the front desk.
|
||||
Manual reprints from the Registrations view always print one.
|
||||
The same control lives in Settings for the active event.
|
||||
</div>
|
||||
</div>
|
||||
<BadgeCopiesPicker
|
||||
value={clampBadgeCopies(badgeCopies)}
|
||||
onChange={setBadgeCopies}
|
||||
disabled={busy}
|
||||
labelId="event-badge-copies-label"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,12 +41,15 @@ export function Registrations() {
|
||||
const [adding, setAdding] = useState(false);
|
||||
const [qrFor, setQrFor] = useState<Registration | null>(null);
|
||||
const [sponsorFor, setSponsorFor] = useState<Registration | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [deletingAll, setDeletingAll] = useState(false);
|
||||
const [mergeFor, setMergeFor] = useState<Registration | null>(null);
|
||||
const [badgeFor, setBadgeFor] = useState<Registration | null>(null);
|
||||
const [badgeLayouts, setBadgeLayouts] = useState<BadgeLayout[]>([]);
|
||||
const [printingIds, setPrintingIds] = useState<Set<string>>(new Set());
|
||||
// Rows with a write in flight (check-in toggle or pass-type change). Per-row
|
||||
// instead of one global flag: a slow request must never freeze the whole
|
||||
// table, and it must be obvious WHICH row is working.
|
||||
const [busyIds, setBusyIds] = useState<Set<string>>(new Set());
|
||||
const { overview: printOverview } = usePrintStatus();
|
||||
// Aggregated printer state, used only to phrase the enqueue toast honestly.
|
||||
const printerState = aggregateState(activeStations(printOverview));
|
||||
@@ -174,43 +177,66 @@ export function Registrations() {
|
||||
const ticketOptions = ynOptions(searched.filter((r) => passType(r) && passCheckedIn(r)), hasTicket);
|
||||
const checkedInOptions = ynOptions(searched.filter((r) => passType(r) && passTicket(r)), (r) => r.checked_in);
|
||||
|
||||
async function changeType(r: Registration, type: RegistrationType) {
|
||||
setBusy(true);
|
||||
// Run a per-row write: mark that row busy, and clear it when settled. Only
|
||||
// the touched row is disabled — the rest of the table stays usable.
|
||||
async function withRowBusy(id: string, run: () => Promise<void>) {
|
||||
if (busyIds.has(id)) return;
|
||||
setBusyIds((ids) => new Set(ids).add(id));
|
||||
try {
|
||||
await setRegistrationType(r.contact_email, type);
|
||||
await reloadRegistrations(r.event_id);
|
||||
push('success', `${byEmail.get(r.contact_email)?.full_name ?? r.contact_email} → ${type}`);
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : 'Update failed';
|
||||
// A sponsor registration needs a sponsor lookup — open the in-place
|
||||
// sponsor popup instead of just failing.
|
||||
if (type === 'sponsor' && /sponsor lookup/i.test(msg)) {
|
||||
setSponsorFor(r);
|
||||
} else {
|
||||
push('error', msg);
|
||||
}
|
||||
await run();
|
||||
} finally {
|
||||
setBusy(false);
|
||||
setBusyIds((ids) => {
|
||||
const next = new Set(ids);
|
||||
next.delete(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleCheckedIn(r: Registration, v: boolean) {
|
||||
setBusy(true);
|
||||
setRegistrations((rows) => rows.map((row) => row.id === r.id ? { ...row, checked_in: v } : row));
|
||||
try {
|
||||
const removed = await setCheckedIn(r.id, v);
|
||||
if (removed > 0) {
|
||||
push('success', `${byEmail.get(r.contact_email)?.full_name ?? r.contact_email}: un-checked in, −${removed} check-in pts removed`);
|
||||
async function changeType(r: Registration, type: RegistrationType) {
|
||||
await withRowBusy(r.id, async () => {
|
||||
try {
|
||||
await setRegistrationType(r.contact_email, type);
|
||||
// Update the row in place — a full reload would reorder the table and
|
||||
// make the row you just touched jump somewhere else.
|
||||
setRegistrations((rows) => rows.map((row) => (row.id === r.id ? { ...row, type } : row)));
|
||||
push('success', `${byEmail.get(r.contact_email)?.full_name ?? r.contact_email} → ${type}`);
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : 'Update failed';
|
||||
// A sponsor registration needs a sponsor lookup — open the in-place
|
||||
// sponsor popup instead of just failing.
|
||||
if (type === 'sponsor' && /sponsor lookup/i.test(msg)) {
|
||||
setSponsorFor(r);
|
||||
} else {
|
||||
push('error', msg);
|
||||
}
|
||||
}
|
||||
// The RPC may have changed this attendee's points — refresh so the
|
||||
// points column and leaderboard stay truthful.
|
||||
await reloadRegistrations(r.event_id);
|
||||
} catch (e) {
|
||||
setRegistrations((rows) => rows.map((row) => row.id === r.id ? { ...row, checked_in: r.checked_in } : row));
|
||||
push('error', e instanceof Error ? e.message : 'Update failed');
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function toggleCheckedIn(r: Registration, v: boolean) {
|
||||
await withRowBusy(r.id, async () => {
|
||||
// Optimistically flip just this row's checkbox; the row keeps its place.
|
||||
setRegistrations((rows) => rows.map((row) => (row.id === r.id ? { ...row, checked_in: v } : row)));
|
||||
try {
|
||||
const removed = await setCheckedIn(r.id, v);
|
||||
// Patch this row's points from the RPC's own number. We deliberately do
|
||||
// NOT reload the list: it is sorted by points, so a reload moves the row
|
||||
// you just toggled somewhere else on every click.
|
||||
setRegistrations((rows) => rows.map((row) => (row.id === r.id
|
||||
? { ...row, checked_in: v, points: Math.max(0, row.points - removed) }
|
||||
: row)));
|
||||
const name = byEmail.get(r.contact_email)?.full_name ?? r.contact_email;
|
||||
if (removed > 0) push('success', `${name}: un-checked in, −${removed} check-in pts removed`);
|
||||
else push('success', `${name}: ${v ? 'checked in' : 'un-checked in'}`);
|
||||
} catch (e) {
|
||||
// Revert to the committed state — never leave the checkbox lying.
|
||||
setRegistrations((rows) => rows.map((row) => (row.id === r.id
|
||||
? { ...row, checked_in: r.checked_in, points: r.points }
|
||||
: row)));
|
||||
push('error', e instanceof Error ? e.message : 'Update failed');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Queue this attendee's badge. Works while the printer is offline/error —
|
||||
@@ -272,7 +298,7 @@ export function Registrations() {
|
||||
className="input"
|
||||
style={{ maxWidth: 280 }}
|
||||
value={selectedId}
|
||||
disabled={busy || mergeFor !== null}
|
||||
disabled={mergeFor !== null}
|
||||
onChange={(e) => setSelectedId(e.target.value)}
|
||||
>
|
||||
{events.map((e) => (
|
||||
@@ -312,8 +338,9 @@ export function Registrations() {
|
||||
<tbody>
|
||||
{filtered.map((r) => {
|
||||
const c = byEmail.get(r.contact_email);
|
||||
const rowBusy = busyIds.has(r.id);
|
||||
return (
|
||||
<tr key={r.id}>
|
||||
<tr key={r.id} className={rowBusy ? 'row-busy' : undefined}>
|
||||
<td>
|
||||
<div className="cell-person">
|
||||
<Avatar name={c?.full_name ?? r.contact_email} id={r.contact_email} size={38} fs={13} />
|
||||
@@ -330,7 +357,7 @@ export function Registrations() {
|
||||
className="input"
|
||||
style={{ width: 130, padding: '6px 10px', fontSize: 12.5 }}
|
||||
value={r.type}
|
||||
disabled={busy}
|
||||
disabled={rowBusy}
|
||||
onChange={(e) => changeType(r, e.target.value as RegistrationType)}
|
||||
>
|
||||
{TYPES.map((t) => (
|
||||
@@ -370,14 +397,19 @@ export function Registrations() {
|
||||
</Tooltip>
|
||||
)}
|
||||
{!r.qr_token?.trim() && r.import_source === 'sessionize' && (
|
||||
<button className="btn small" disabled={busy} onClick={() => setMergeFor(r)}>
|
||||
<button className="btn small" onClick={() => setMergeFor(r)}>
|
||||
Merge tickets
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<Toggle checked={r.checked_in} disabled={busy} onChange={(v) => toggleCheckedIn(r, v)} />
|
||||
<div className="row" style={{ gap: 8 }}>
|
||||
<Toggle checked={r.checked_in} disabled={rowBusy} onChange={(v) => toggleCheckedIn(r, v)} />
|
||||
{/* Per-row in-flight affordance: the switch is optimistic,
|
||||
so show that the save is still travelling. */}
|
||||
{rowBusy && <span className="row-saving" data-testid={`saving-${r.id}`}>Saving…</span>}
|
||||
</div>
|
||||
</td>
|
||||
<td style={{ textAlign: 'right' }}>
|
||||
<span className="pts">{r.points}</span>
|
||||
@@ -456,9 +488,13 @@ export function Registrations() {
|
||||
contact={byEmail.get(sponsorFor.contact_email)}
|
||||
eventId={event.id}
|
||||
onClose={() => setSponsorFor(null)}
|
||||
onSaved={async (msg) => {
|
||||
onSaved={(msg) => {
|
||||
// The modal sets the registration type to sponsor; mirror it on the
|
||||
// row. (Reloading events here never refreshed the rows, which left
|
||||
// the type badge showing the old value.)
|
||||
const savedId = sponsorFor.id;
|
||||
setRegistrations((rows) => rows.map((row) => (row.id === savedId ? { ...row, type: 'sponsor' } : row)));
|
||||
setSponsorFor(null);
|
||||
await load();
|
||||
push('success', msg);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useEffect, useState, type FormEvent } from 'react';
|
||||
import { Save } from 'lucide-react';
|
||||
import { getLlmSettings, saveLlmSettings } from '../lib/api';
|
||||
import { getActiveEvent, getLlmSettings, saveLlmSettings } from '../lib/api';
|
||||
import type { Event } from '../lib/types';
|
||||
import { Spinner } from '../components/ui';
|
||||
import { BadgeCopiesSetting } from '../components/BadgeCopiesSetting';
|
||||
|
||||
export function Settings() {
|
||||
const [endpoint, setEndpoint] = useState('');
|
||||
@@ -13,6 +15,8 @@ export function Settings() {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [saved, setSaved] = useState(false);
|
||||
// Badge printing is per event, so it follows the active event.
|
||||
const [activeEvent, setActiveEvent] = useState<Event | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
@@ -23,6 +27,11 @@ export function Settings() {
|
||||
setHasKey(settings.has_api_key);
|
||||
setLoaded(true);
|
||||
}).catch(cause => { if (active) setError(cause instanceof Error ? cause.message : 'Failed to load settings'); });
|
||||
// Best-effort: a failure here just hides the badge section, it must not
|
||||
// break the Feedback AI settings below.
|
||||
getActiveEvent()
|
||||
.then(event => { if (active) setActiveEvent(event); })
|
||||
.catch(() => { if (active) setActiveEvent(null); });
|
||||
return () => { active = false; };
|
||||
}, []);
|
||||
|
||||
@@ -47,6 +56,12 @@ export function Settings() {
|
||||
<div className="page-head"><h1>Settings</h1></div>
|
||||
{error && <p className="feedback-error" role="alert">{error}</p>}
|
||||
{!loaded && !error && <Spinner />}
|
||||
{activeEvent && (
|
||||
<section className="settings-section" aria-labelledby="badge-printing-h" data-testid="settings-badge-printing">
|
||||
<h2 className="h2" id="badge-printing-h">Badge printing</h2>
|
||||
<BadgeCopiesSetting eventId={activeEvent.id} initialCopies={activeEvent.badge_copies ?? 1} eventName={activeEvent.name} />
|
||||
</section>
|
||||
)}
|
||||
{loaded && <form className="llm-settings" onSubmit={save} onChange={() => setSaved(false)}>
|
||||
<h2 className="h2">Feedback AI</h2>
|
||||
<div className="field">
|
||||
|
||||
@@ -194,6 +194,8 @@ export interface WelcomeCheckinPreview {
|
||||
already: boolean;
|
||||
/** True when confirming will enqueue a badge print (first check-in + a layout exists). */
|
||||
will_print: boolean;
|
||||
/** How many labels confirming will print (0 when nothing prints). */
|
||||
copies: number;
|
||||
}
|
||||
|
||||
/** Result of accepting a connection (the connection row + the shared-talk flag). */
|
||||
|
||||
@@ -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