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

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-08-23 21:33:44 +02:00
1 parent adcbb507e9
commit ffb270c140
16 files changed
+730 -142

No files matched your search

+149 -43
View File
@@ -4,11 +4,11 @@ import {
getAllContacts,
getActiveEvent,
getRegistrations,
resetQrToken,
setCheckedIn,
setRegistrationType,
upsertSponsor,
} from '../lib/api';
import type { Contact, Event, Registration, RegistrationType } from '../lib/types';
import type { Contact, Event, Registration, RegistrationType, SponsorType } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Avatar, Empty, Modal, QrImage, Spinner, Toggle, TypeBadge } from '../components/ui';
@@ -24,7 +24,7 @@ export function Registrations() {
const [query, setQuery] = useState('');
const [adding, setAdding] = useState(false);
const [qrFor, setQrFor] = useState<Registration | null>(null);
const [newToken, setNewToken] = useState<string | null>(null);
const [sponsorFor, setSponsorFor] = useState<Registration | null>(null);
const [busy, setBusy] = useState(false);
async function load() {
@@ -69,7 +69,14 @@ export function Registrations() {
await load();
push('success', `${byEmail.get(r.contact_email)?.full_name ?? r.contact_email} → ${type}`);
} catch (e) {
push('error', e instanceof Error ? e.message : 'Update failed');
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);
}
} finally {
setBusy(false);
}
@@ -87,21 +94,6 @@ export function Registrations() {
}
}
async function doResetQr(r: Registration) {
setBusy(true);
try {
const res = await resetQrToken(r.contact_email);
setNewToken(res.qr_token);
setQrFor(r);
await load();
push('success', `New QR token issued for ${byEmail.get(r.contact_email)?.full_name ?? r.contact_email}`);
} catch (e) {
push('error', e instanceof Error ? e.message : 'Reset failed');
} finally {
setBusy(false);
}
}
if (error) return <Empty icon="⚠️" text={error} />;
if (!loaded)
return (
@@ -195,7 +187,7 @@ export function Registrations() {
<td>
<div className="row" style={{ gap: 8 }}>
<span className="mono small">{r.qr_token ?? '—'}</span>
<button className="btn small" onClick={() => { setNewToken(null); setQrFor(r); }}>
<button className="btn small" onClick={() => setQrFor(r)}>
QR
</button>
</div>
@@ -233,35 +225,34 @@ export function Registrations() {
title={`QR — ${byEmail.get(qrFor.contact_email)?.full_name ?? qrFor.contact_email}`}
onClose={() => setQrFor(null)}
footer={
<>
<button className="btn danger" disabled={busy} onClick={() => doResetQr(qrFor)}>
{busy ? 'Resetting…' : 'Reset token'}
</button>
<button className="btn primary" onClick={() => setQrFor(null)}>
Done
</button>
</>
<button className="btn primary" onClick={() => setQrFor(null)}>
Done
</button>
}
>
<div className="qr-wrap">
{newToken ? (
<>
<QrImage value={newToken} size={190} />
<div className="token-big">{newToken}</div>
<p className="muted small">
New token issued. The old token no longer works — the person must re-scan.
</p>
</>
) : (
<>
<QrImage value={qrFor.qr_token ?? ''} size={190} />
<div className="token-big">{qrFor.qr_token ?? '—'}</div>
<p className="muted small">Current token. Reset to issue a new one.</p>
</>
)}
<QrImage value={qrFor.qr_token ?? ''} size={190} />
<div className="token-big">{qrFor.qr_token ?? '—'}</div>
<p className="muted small">
This token is final — it was generated by Pretix and can’t be reset.
</p>
</div>
</Modal>
)}
{sponsorFor && (
<SponsorLookupModal
registration={sponsorFor}
contact={byEmail.get(sponsorFor.contact_email)}
eventId={event.id}
onClose={() => setSponsorFor(null)}
onSaved={async (msg) => {
setSponsorFor(null);
await load();
push('success', msg);
}}
/>
)}
</div>
);
}
@@ -340,3 +331,118 @@ function AddRegistrationModal({
</Modal>
);
}
/**
* In-place sponsor lookup: shown when an admin tries to set a registration to
* 'sponsor' but no sponsor exists for that contact yet. Lets them create the
* sponsor (with a contact search) and then retry the type change.
*/
function SponsorLookupModal({
registration,
contact,
eventId,
onClose,
onSaved,
}: {
registration: Registration;
contact: Contact | undefined;
eventId: string;
onClose: () => void;
onSaved: (msg: string) => void;
}) {
const [type, setType] = useState<SponsorType>('gold');
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [phone, setPhone] = useState('');
const [paid, setPaid] = useState(false);
const [amount, setAmount] = useState('');
const [busy, setBusy] = useState(false);
const contactEmail = registration.contact_email;
async function save() {
if (!name.trim()) return;
setBusy(true);
try {
await upsertSponsor(null, {
event_id: eventId,
type,
name: name.trim(),
email: email.trim() || null,
phone: phone.trim() || null,
paid,
amount_eur: amount ? parseFloat(amount) : null,
contact_email: contactEmail,
});
await setRegistrationType(contactEmail, 'sponsor');
onSaved(`Sponsor "${name.trim()}" created — ${contact?.full_name ?? contactEmail} is now a sponsor`);
} catch (e) {
onSaved(e instanceof Error ? e.message : 'Save failed');
} finally {
setBusy(false);
}
}
return (
<Modal
open
title={`Sponsor lookup — ${contact?.full_name ?? contactEmail}`}
onClose={onClose}
footer={
<>
<button className="btn" onClick={onClose}>
Cancel
</button>
<button className="btn primary" disabled={busy || !name.trim()} onClick={save}>
{busy ? 'Saving…' : 'Create sponsor & set type'}
</button>
</>
}
>
<p className="muted small" style={{ marginBottom: 14 }}>
A sponsor registration needs a sponsor lookup. Create the sponsor below — it will be linked to{' '}
<b>{contact?.full_name ?? contactEmail}</b> and their registration type set to <b>Sponsor</b>.
</p>
<div className="grid-2">
<div className="field">
<label>Sponsor type</label>
<select className="input" value={type} onChange={(e) => setType(e.target.value as SponsorType)}>
{(['headline', 'platinum', 'gold', 'silver', 'community', 'swag', 'catering', 'diversity'] as SponsorType[]).map(
(t) => (
<option key={t} value={t}>
{t}
</option>
),
)}
</select>
</div>
<div className="field">
<label>Sponsor name</label>
<input className="input" value={name} onChange={(e) => setName(e.target.value)} placeholder="e.g. Nubank" />
</div>
</div>
<div className="grid-2">
<div className="field">
<label>Email</label>
<input className="input" type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="—" />
</div>
<div className="field">
<label>Phone</label>
<input className="input" value={phone} onChange={(e) => setPhone(e.target.value)} placeholder="—" />
</div>
</div>
<div className="grid-2">
<div className="field">
<label>Amount (€)</label>
<input className="input" type="number" value={amount} onChange={(e) => setAmount(e.target.value)} placeholder="0" />
</div>
<div className="field">
<label>Paid</label>
<div style={{ paddingTop: 6 }}>
<Toggle checked={paid} onChange={setPaid} />
</div>
</div>
</div>
</Modal>
);
}