Registration optionset + speaker auto-promote + welcome check-in

- registrations.type is now a Postgres ENUM (registration_type)
- session_speakers trigger auto-promotes attendee -> speaker (never overrides staff/sponsor)
- new welcome_checkin RPC: staff marks an attendee present at the event
- admin Registrations: QR token is final (no reset); failed sponsor change opens in-place sponsor lookup
- Convivo Home: Now/Next cards always render; red pending-material pill + popup for speakers
- Convivo Agenda: speakers can delete their material to re-upload
- Convivo Scan: staff Session/Welcome check-in toggle (uiverse switch)
- seed: staff (Bruno/Rita) get a password so staff QR login works after reset
This commit is contained in:
Lago committed 2026-08-23 21:33:44 +02:00
1 parent 1bffae9777
commit 1cbbd1b529
16 files changed
+730 -142

No files matched your search

+20
View File
@@ -6,6 +6,7 @@ import {
getMyCheckins,
getMyPreferences,
getMySpeakerSessions,
removeSessionMaterial,
sessionMaterialUrl,
setPreference,
uploadSessionMaterial,
@@ -114,6 +115,19 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
}
}
async function handleDeleteMaterial() {
if (!selected) return;
if (!confirm('Remove this material? You can upload a new one.')) return;
try {
await removeSessionMaterial(selected.id);
toast('Material removed', 'ok');
setSelected(null);
reload();
} catch (err) {
toast(err instanceof Error ? err.message : 'Could not remove material', 'err');
}
}
return (
<section className="screen">
<div className="row between">
@@ -222,6 +236,12 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
📎 Download material
</a>
)}
{/* Speakers can remove their own material to re-upload. */}
{selISpeaker && selected.material_path && (
<button className="btn danger" onClick={handleDeleteMaterial}>
🗑 Remove material
</button>
)}
</div>
</>
)}
+85 -18
View File
@@ -1,16 +1,18 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { getMyCheckins, getMyPreferences } from '../lib/api';
import { getMyCheckins, getMyPreferences, getMySpeakerSessions } from '../lib/api';
import { fmtRange, greeting, slotStatus } from '../lib/time';
import type { Preference } from '../lib/types';
import { Empty, Spinner } from '../components/ui';
import type { Preference, Session } from '../lib/types';
import { Empty, Sheet, Spinner } from '../components/ui';
export function Home({ go }: { go: (tab: string) => void }) {
const { contact, registration } = useAuth();
const { event, slots, sessionById, now, loading } = useEvent();
const [prefs, setPrefs] = useState<Preference[]>([]);
const [checkins, setCheckins] = useState<string[]>([]);
const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]);
const [materialSheetOpen, setMaterialSheetOpen] = useState(false);
const email = contact?.email ?? '';
@@ -18,10 +20,15 @@ export function Home({ go }: { go: (tab: string) => void }) {
let active = true;
(async () => {
try {
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins(email)]);
const [p, c, sp] = await Promise.all([
getMyPreferences(),
getMyCheckins(email),
getMySpeakerSessions(email),
]);
if (!active) return;
setPrefs(p);
setCheckins(c);
setMySpeakerSessions(sp);
} catch {
/* non-fatal */
}
@@ -60,6 +67,11 @@ export function Home({ go }: { go: (tab: string) => void }) {
const nowSession = current ? sessionById.get(pickFor(current.slot.id) ?? '') : undefined;
const nextSession = next ? sessionById.get(pickFor(next.slot.id) ?? '') : undefined;
// Sessions the signed-in contact speaks in that still have no material uploaded.
const pendingMaterial = mySpeakerSessions
.map((id) => sessionById.get(id))
.filter((s): s is Session => !!s && !s.material_path);
const firstName = contact.full_name.split(' ')[0];
return (
@@ -69,37 +81,60 @@ export function Home({ go }: { go: (tab: string) => void }) {
<div className="h1">{greeting(now)}, {firstName} 👋</div>
<div className="muted small">{event.name}</div>
</div>
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {points}</div>
<div className="row" style={{ gap: 8 }}>
{pendingMaterial.length > 0 && (
<div className="material-pill" onClick={() => setMaterialSheetOpen(true)}>
📎 {pendingMaterial.length}
</div>
)}
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {points}</div>
</div>
</div>
{nowSession && current && (
{current && (
<div className="card now-card">
<div className="row between">
<span className="pill violet">● Now</span>
<span className="muted small">{fmtRange(current.slot)}</span>
</div>
<div className="h2" style={{ marginTop: 10 }}>{nowSession.title}</div>
<div className="muted small" style={{ marginTop: 3 }}>
{nowSession.room} · {nowSession.speakers}
</div>
{checkins.includes(nowSession.id) ? (
<span className="pill green" style={{ marginTop: 10 }}>✓ Checked in</span>
{nowSession ? (
<>
<div className="h2" style={{ marginTop: 10 }}>{nowSession.title}</div>
<div className="muted small" style={{ marginTop: 3 }}>
{nowSession.room} · {nowSession.speakers}
</div>
{checkins.includes(nowSession.id) ? (
<span className="pill green" style={{ marginTop: 10 }}>✓ Checked in</span>
) : (
<span className="pill amber" style={{ marginTop: 10 }}>Show your QR to staff to check in</span>
)}
</>
) : (
<span className="pill amber" style={{ marginTop: 10 }}>Show your QR to staff to check in</span>
<div className="muted small" style={{ marginTop: 10 }}>
No pick yet — tap a session in the Agenda to choose.
</div>
)}
</div>
)}
{nextSession && next && (
{next && (
<div className="card">
<div className="row between">
<span className="pill cyan">Next</span>
<span className="muted small">{fmtRange(next.slot)}</span>
</div>
<div className="h2" style={{ marginTop: 10 }}>{nextSession.title}</div>
<div className="muted small" style={{ marginTop: 3 }}>
{nextSession.room} · {nextSession.speakers}
</div>
{nextSession ? (
<>
<div className="h2" style={{ marginTop: 10 }}>{nextSession.title}</div>
<div className="muted small" style={{ marginTop: 3 }}>
{nextSession.room} · {nextSession.speakers}
</div>
</>
) : (
<div className="muted small" style={{ marginTop: 10 }}>
No pick yet — tap a session in the Agenda to choose.
</div>
)}
</div>
)}
@@ -145,6 +180,38 @@ export function Home({ go }: { go: (tab: string) => void }) {
</div>
</div>
<div style={{ height: 8 }} />
{/* Pending material popup (speakers only, when a session is missing its attachment) */}
<Sheet open={materialSheetOpen} onClose={() => setMaterialSheetOpen(false)}>
<h3 style={{ marginBottom: 4 }}>📎 Pending material</h3>
<div className="muted small" style={{ marginBottom: 14 }}>
The following sessions are pending to upload their attachments.
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{pendingMaterial.map((s) => {
const slot = slots.find((x) => x.slot.id === s.slot_id)?.slot;
return (
<button
key={s.id}
className="pick-chip"
onClick={() => {
setMaterialSheetOpen(false);
go('agenda');
}}
>
<span className="t">{slot ? fmtRange(slot) : ''}</span>
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
{s.title}
</span>
<span className="muted small">{s.room}</span>
</button>
);
})}
</div>
<button className="btn primary" style={{ marginTop: 16 }} onClick={() => setMaterialSheetOpen(false)}>
Got it
</button>
</Sheet>
</section>
);
}
+59 -17
View File
@@ -1,9 +1,9 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { checkinAttendee, createConnectionRequest, lanyardLookup } from '../lib/api';
import { checkinAttendee, createConnectionRequest, lanyardLookup, welcomeCheckin } from '../lib/api';
import { capWords } from '../lib/time';
import type { CheckinResult, PublicContact } from '../lib/types';
import type { CheckinResult, PublicContact, WelcomeCheckinResult } from '../lib/types';
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
@@ -13,8 +13,10 @@ export function Scan() {
const isStaff = !!contact?.is_admin;
const [mode, setMode] = useState<'attendee' | 'staff'>(isStaff ? 'staff' : 'attendee');
const [sessionId, setSessionId] = useState<string>('');
const [welcomeMode, setWelcomeMode] = useState(false);
const [connectTarget, setConnectTarget] = useState<{ contact: PublicContact; qr: string } | null>(null);
const [checkin, setCheckin] = useState<CheckinResult | null>(null);
const [welcome, setWelcome] = useState<WelcomeCheckinResult | null>(null);
const [busy, setBusy] = useState(false);
const { toast } = useToast();
@@ -42,12 +44,17 @@ export function Scan() {
setBusy(true);
try {
if (activeStaff) {
if (!sessionId) {
toast('Pick a session first', 'err');
return;
if (welcomeMode) {
const res = await welcomeCheckin(token);
setWelcome(res);
} else {
if (!sessionId) {
toast('Pick a session first', 'err');
return;
}
const res = await checkinAttendee(sessionId, token);
setCheckin(res);
}
const res = await checkinAttendee(sessionId, token);
setCheckin(res);
} else {
const found = await lanyardLookup(token);
if (!found) {
@@ -103,22 +110,40 @@ export function Scan() {
{activeStaff && (
<div>
<div className="muted small" style={{ marginBottom: 7 }}>Checking in to session</div>
<select className="input" value={sessionId} onChange={(e) => setSessionId(e.target.value)}>
{slots.map(({ slot, sessions }) => (
<optgroup key={slot.id} label={`${slot.name} · ${slot.start_time.slice(0, 5)}`}>
{sessions.map((s) => (
<option key={s.id} value={s.id}>{s.title}</option>
<div className="row between" style={{ marginBottom: 10 }}>
<span className="muted small" style={{ fontWeight: 700 }}>Check-in type</span>
<label className="uiverse-toggle" title={welcomeMode ? 'Welcome check-in' : 'Session check-in'}>
<input
type="checkbox"
checked={welcomeMode}
onChange={(e) => setWelcomeMode(e.target.checked)}
/>
</label>
</div>
{welcomeMode ? (
<div className="muted small" style={{ padding: '10px 12px', background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: 12 }}>
🏷 <b>Welcome check-in</b> — marks the attendee present at the event.
</div>
) : (
<>
<div className="muted small" style={{ marginBottom: 7 }}>Checking in to session</div>
<select className="input" value={sessionId} onChange={(e) => setSessionId(e.target.value)}>
{slots.map(({ slot, sessions }) => (
<optgroup key={slot.id} label={`${slot.name} · ${slot.start_time.slice(0, 5)}`}>
{sessions.map((s) => (
<option key={s.id} value={s.id}>{s.title}</option>
))}
</optgroup>
))}
</optgroup>
))}
</select>
</select>
</>
)}
</div>
)}
<Scanner onResult={handleScan} label={activeStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
{busy && <div className="center"><Spinner /></div>}
{activeStaff && selSession && (
{activeStaff && !welcomeMode && selSession && (
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
{selSession.room} · {selSession.speakers}
</div>
@@ -172,6 +197,23 @@ export function Scan() {
</div>
)}
</Sheet>
{/* Welcome check-in result sheet */}
<Sheet open={!!welcome} onClose={() => setWelcome(null)}>
{welcome && (
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 52 }}>{welcome.already ? '⚠️' : '👋'}</div>
<h3 style={{ marginTop: 10 }}>{welcome.attendee_name}</h3>
<div className="sub">{welcome.already ? 'Already checked in to the event' : 'Welcome to the event!'}</div>
<div style={{ marginTop: 14 }}>
<span className="pill green">✓ Checked in</span>
</div>
<button className="btn primary" style={{ marginTop: 18 }} onClick={() => setWelcome(null)}>
Scan next
</button>
</div>
)}
</Sheet>
</section>
);
}