Check-in gate + fixes, RPC test suite, docs
- Convivo: not-checked-in gate for non-staff (see-a-staff screen with QR code + logout); lifts automatically once staff checks them in - Convivo: fix check-in 'pick a session first' race (synchronous default session fallback) - Add RPC test suite (npm run test:rpc): points idempotency, role guards, service-session guard, speaker auto-promote, leaderboard staff exclusion - Fix db:types script (create packages/shared/src); gitignore generated types - Docs: README/roadmap drift fixes, tests.md, backend README link 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
fcbc19b8fc
commit
b08a439949
11 files changed
+559
-38
No files matched your search
@@ -9,7 +9,7 @@ import { Connections } from './screens/Connections';
|
||||
import { Leaderboard } from './screens/Leaderboard';
|
||||
import { Profile } from './screens/Profile';
|
||||
import { Feedback } from './screens/Feedback';
|
||||
import { Spinner } from './components/ui';
|
||||
import { QrImage, Spinner } from './components/ui';
|
||||
import { getMyConnections } from './lib/api';
|
||||
import { usePolling } from './lib/usePolling';
|
||||
|
||||
@@ -23,7 +23,7 @@ const TABS: { id: Tab; ico: string; label: string }[] = [
|
||||
];
|
||||
|
||||
function Shell() {
|
||||
const { session, contact, loading } = useAuth();
|
||||
const { session, contact, registration, loading, refresh, signOut } = useAuth();
|
||||
const [tab, setTab] = useState<Tab>('home');
|
||||
const [feedbackSession, setFeedbackSession] = useState<string | null>(null);
|
||||
const [pendingIncoming, setPendingIncoming] = useState(0);
|
||||
@@ -46,6 +46,13 @@ function Shell() {
|
||||
// Keep the Connect red-dot fresh: poll every 5s while visible.
|
||||
usePolling(() => void loadPending(), 5000, !!email);
|
||||
|
||||
// Gate: a non-staff member must be checked in by staff before using the app.
|
||||
// (Staff are never gated — they're the ones doing the checking in.)
|
||||
const isGated = !!contact && !contact.is_admin && !registration?.checked_in;
|
||||
|
||||
// While gated, poll so the gate lifts as soon as staff checks them in.
|
||||
usePolling(() => { if (isGated) void refresh(); }, 4000, isGated);
|
||||
|
||||
// Recalc immediately when a connection is accepted/declined/sent.
|
||||
useEffect(() => {
|
||||
const onChanged = () => void loadPending();
|
||||
@@ -71,6 +78,42 @@ function Shell() {
|
||||
);
|
||||
}
|
||||
|
||||
// Not checked in yet: a non-staff member must be checked in by staff before
|
||||
// they can use the app. The gate lifts automatically (4s poll) once staff
|
||||
// checks them in.
|
||||
if (isGated) {
|
||||
return (
|
||||
<div className="app">
|
||||
<div className="center" style={{ flex: 1, flexDirection: 'column', gap: 14, padding: 24, textAlign: 'center' }}>
|
||||
<div style={{ fontSize: 56 }}>🏷️</div>
|
||||
<div className="h1" style={{ textAlign: 'center' }}>Please see a staff member</div>
|
||||
<div className="muted" style={{ textAlign: 'center', maxWidth: 320 }}>
|
||||
You haven’t been checked in yet. Find a staff member and have them
|
||||
scan your lanyard to get checked in — then you can start using the app.
|
||||
</div>
|
||||
{registration?.qr_token && (
|
||||
<div className="card qr-wrap" style={{ marginTop: 4 }}>
|
||||
<div className="h2" style={{ textAlign: 'center' }}>Your QR code</div>
|
||||
<QrImage value={registration.qr_token} size={180} />
|
||||
<div className="muted small" style={{ textAlign: 'center' }}>
|
||||
Show this to <b>staff</b> to get checked in.
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="muted small" style={{ opacity: 0.6 }}>
|
||||
Checking in… this screen updates automatically.
|
||||
</div>
|
||||
<button className="btn ghost" onClick={() => void refresh()}>
|
||||
I’ve been checked in — refresh
|
||||
</button>
|
||||
<button className="btn ghost" onClick={() => void signOut()}>
|
||||
Log out
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Feedback is a full-screen takeover (no tab bar).
|
||||
if (feedbackSession) {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { checkinAttendee, createConnectionRequest, lanyardLookup, welcomeCheckin } from '../lib/api';
|
||||
@@ -20,13 +20,16 @@ export function Scan() {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
// The first checkable (non-service) session, computed synchronously so a fast
|
||||
// scan never races the async default-selection effect below.
|
||||
const defaultSessionId = useMemo(
|
||||
() => slots.flatMap((s) => s.sessions).find((s) => s.slot_type !== 'service_session')?.id ?? '',
|
||||
[slots],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (slots.length > 0 && !sessionId) {
|
||||
// Default to the first checkable (non-service) session.
|
||||
const first = slots.flatMap((s) => s.sessions).find((s) => s.slot_type !== 'service_session');
|
||||
if (first) setSessionId(first.id);
|
||||
}
|
||||
}, [slots, sessionId]);
|
||||
if (defaultSessionId && !sessionId) setSessionId(defaultSessionId);
|
||||
}, [defaultSessionId, sessionId]);
|
||||
|
||||
if (loading || !contact) {
|
||||
return (
|
||||
@@ -49,11 +52,14 @@ export function Scan() {
|
||||
const res = await welcomeCheckin(token);
|
||||
setWelcome(res);
|
||||
} else {
|
||||
if (!sessionId) {
|
||||
// Fall back to the first checkable session so a fast scan (before the
|
||||
// async default-selection effect runs) never fails with "pick a session".
|
||||
const targetSession = sessionId || defaultSessionId;
|
||||
if (!targetSession) {
|
||||
toast('Pick a session first', 'err');
|
||||
return;
|
||||
}
|
||||
const res = await checkinAttendee(sessionId, token);
|
||||
const res = await checkinAttendee(targetSession, token);
|
||||
setCheckin(res);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user