Fixes & Refinements: QR token on registration, role caps, connection detail + red dot, admin schedule/sponsors

Datamodel:
- Move qr_token from contacts to registrations (per event); new migration
  20260826000000. lanyard_lookup / create_connection_request / checkin_attendee
  resolve via registrations + active event.
- reset_qr_token -> reset_registration_qr_token (fixes ambiguous 'email' col).
- upsert_contact drops the token arg; create_registration generates + syncs it.
- Pretix sync writes the token to the registration (keeps it on re-sync).

Registration types:
- Distinct pill colors; red reserved for Staff (both apps).
- Roles capitalized everywhere (Attendee/Speaker/Sponsor/Staff); 'Attendee'
  hidden only at the Home footer.
- Reset-token button moved from Contacts to Registrations (per registration).

Sessions (APPE Admin):
- Slot types capitalized; material submitted/not-submitted state.
- Speaker selection = multi-select search dropdown.
- Fix 'a session must have a speaker' on edit (diff-based setSessionSpeakers)
  and the file-upload bug (speaker save no longer aborts first).

APPE Admin:
- Sponsors contact lookup = search field (filter + pick).

Convivo App:
- Other people's QR codes hidden; connection detail sheet shows public info +
  points.
- Connect red dot recalculates immediately on accept/decline/send.
- 'My picks today' = 2 rows (current + next); 'tap to change' links to Agenda.

Docs updated across backend + frontend.
This commit is contained in:
Lago committed 2026-08-23 10:39:21 +02:00
1 parent 005f1d404f
commit b52d8ab007
30 files changed
+1083 -232

No files matched your search

+6 -68
View File
@@ -1,8 +1,8 @@
import { useEffect, useMemo, useState } from 'react';
import { adjustPoints, getAllContacts, resetQrToken, updateContact, upsertContact } from '../lib/api';
import { adjustPoints, getAllContacts, updateContact, upsertContact } from '../lib/api';
import type { Contact } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Avatar, Empty, Modal, QrImage, Spinner, Toggle } from '../components/ui';
import { Avatar, Empty, Modal, Spinner, Toggle } from '../components/ui';
export function Contacts() {
const { push } = useToast();
@@ -12,10 +12,7 @@ export function Contacts() {
const [editing, setEditing] = useState<Contact | null>(null);
const [creating, setCreating] = useState(false);
const [qrFor, setQrFor] = useState<Contact | null>(null);
const [newToken, setNewToken] = useState<string | null>(null);
const [pointsFor, setPointsFor] = useState<Contact | null>(null);
const [busy, setBusy] = useState(false);
async function load() {
try {
@@ -37,26 +34,10 @@ export function Contacts() {
(c) =>
c.full_name.toLowerCase().includes(q) ||
c.email.toLowerCase().includes(q) ||
(c.linkedin_url ?? '').toLowerCase().includes(q) ||
(c.qr_token ?? '').toLowerCase().includes(q),
(c.linkedin_url ?? '').toLowerCase().includes(q),
);
}, [contacts, query]);
async function doResetQr(c: Contact) {
setBusy(true);
try {
const res = await resetQrToken(c.email);
setNewToken(res.qr_token);
setQrFor(c);
await load();
push('success', `New QR token issued for ${c.full_name}`);
} catch (e) {
push('error', e instanceof Error ? e.message : 'Reset failed');
} finally {
setBusy(false);
}
}
if (error) return <Empty icon="⚠️" text={error} />;
if (!contacts)
return (
@@ -70,13 +51,13 @@ export function Contacts() {
<div className="page-head">
<div>
<h1>Contacts</h1>
<div className="sub">{contacts.length} people · manage contacts, QR tokens, and points.</div>
<div className="sub">{contacts.length} people · manage contacts and points.</div>
</div>
<div className="row" style={{ gap: 10 }}>
<input
className="input"
style={{ maxWidth: 260 }}
placeholder="Search name, email, token…"
placeholder="Search name, email…"
value={query}
onChange={(e) => setQuery(e.target.value)}
/>
@@ -94,7 +75,6 @@ export function Contacts() {
<th>LinkedIn</th>
<th>Visibility</th>
<th>Admin</th>
<th>QR token</th>
<th style={{ textAlign: 'right' }}>Actions</th>
</tr>
</thead>
@@ -132,17 +112,11 @@ export function Contacts() {
<td>
{c.is_admin ? <span className="pill admin">admin</span> : <span className="muted small">—</span>}
</td>
<td>
<span className="mono small">{c.qr_token ?? '—'}</span>
</td>
<td>
<div className="row-actions">
<button className="btn small" onClick={() => setEditing(c)}>
Edit
</button>
<button className="btn small" onClick={() => { setNewToken(null); setQrFor(c); }}>
QR
</button>
<button className="btn small" onClick={() => setPointsFor(c)}>
Points
</button>
@@ -178,42 +152,6 @@ export function Contacts() {
/>
)}
{qrFor && (
<Modal
open
title={`QR — ${qrFor.full_name}`}
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>
</>
}
>
<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>
</>
)}
</div>
</Modal>
)}
{pointsFor && (
<AdjustPointsModal
contact={pointsFor}
@@ -361,7 +299,7 @@ function CreateContactModal({
<div className="row">
<Toggle checked={isAdmin} onChange={setIsAdmin} label="Admin / staff" />
</div>
<p className="muted small">A QR token is generated automatically and becomes the login password.</p>
<p className="muted small">A QR token is generated when the contact is registered for an event — it becomes the login password.</p>
</Modal>
);
}
+64 -1
View File
@@ -4,12 +4,13 @@ import {
getAllContacts,
getActiveEvent,
getRegistrations,
resetQrToken,
setCheckedIn,
setRegistrationType,
} from '../lib/api';
import type { Contact, Event, Registration, RegistrationType } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Avatar, Empty, Modal, Spinner, Toggle, TypeBadge } from '../components/ui';
import { Avatar, Empty, Modal, QrImage, Spinner, Toggle, TypeBadge } from '../components/ui';
const TYPES: RegistrationType[] = ['attendee', 'speaker', 'staff', 'sponsor'];
@@ -22,6 +23,8 @@ export function Registrations() {
const [error, setError] = useState<string | null>(null);
const [query, setQuery] = useState('');
const [adding, setAdding] = useState(false);
const [qrFor, setQrFor] = useState<Registration | null>(null);
const [newToken, setNewToken] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
async function load() {
@@ -84,6 +87,21 @@ 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 (
@@ -137,6 +155,7 @@ export function Registrations() {
<tr>
<th>Contact</th>
<th>Type</th>
<th>QR token</th>
<th>Checked in</th>
<th style={{ textAlign: 'right' }}>Points</th>
</tr>
@@ -173,6 +192,14 @@ export function Registrations() {
</select>
</div>
</td>
<td>
<div className="row" style={{ gap: 8 }}>
<span className="mono small">{r.qr_token ?? '—'}</span>
<button className="btn small" onClick={() => { setNewToken(null); setQrFor(r); }}>
QR
</button>
</div>
</td>
<td>
<Toggle checked={r.checked_in} onChange={(v) => toggleCheckedIn(r, v)} />
</td>
@@ -199,6 +226,42 @@ export function Registrations() {
}}
/>
)}
{qrFor && (
<Modal
open
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>
</>
}
>
<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>
</>
)}
</div>
</Modal>
)}
</div>
);
}
+70 -14
View File
@@ -197,7 +197,7 @@ export function Schedule() {
</div>
<div className="muted small" style={{ marginTop: 4 }}>
{s.average_feedback != null && <span>⭐ {s.average_feedback.toFixed(1)}</span>}
{s.material_path && <span> · 📎 material</span>}
<span> · {s.material_path ? '📎 material submitted' : '⬜ material not submitted'}</span>
{s.ai_generated_feedback && (
<span className="ai-state"> · 🤖 {s.ai_generated_feedback}</span>
)}
@@ -320,7 +320,7 @@ function SlotModal({
<select className="input" value={type} onChange={(e) => setType(e.target.value as SlotType)}>
{SLOT_TYPES.map((t) => (
<option key={t} value={t}>
{t.replace('_', ' ')}
{t.replace(/_/g, ' ')}
</option>
))}
</select>
@@ -448,18 +448,11 @@ function SessionModal({
<div className="field">
<label>Speakers ({speakerEmails.length})</label>
<div className="speaker-pick">
{contacts.map((c) => (
<label key={c.email} className={`speaker-opt ${speakerEmails.includes(c.email) ? 'on' : ''}`}>
<input
type="checkbox"
checked={speakerEmails.includes(c.email)}
onChange={() => toggleSpeaker(c.email)}
/>
{c.full_name}
</label>
))}
</div>
<SpeakerMultiSelect
contacts={contacts}
selected={speakerEmails}
onToggle={toggleSpeaker}
/>
{speakerEmails.length === 0 && (
<span className="muted small">A session needs at least one speaker.</span>
)}
@@ -510,6 +503,69 @@ function SessionModal({
);
}
/** Multi-select with a search box: type to filter, click to add/remove. */
function SpeakerMultiSelect({
contacts,
selected,
onToggle,
}: {
contacts: Contact[];
selected: string[];
onToggle: (email: string) => void;
}) {
const [query, setQuery] = useState('');
const nameOf = (email: string) => contacts.find((c) => c.email === email)?.full_name ?? email;
const q = query.trim().toLowerCase();
const matches = (q
? contacts.filter(
(c) => c.full_name.toLowerCase().includes(q) || c.email.toLowerCase().includes(q),
)
: contacts
).slice(0, 8);
return (
<div className="msel">
{selected.length > 0 && (
<div className="msel-chips">
{selected.map((email) => (
<span key={email} className="msel-chip">
{nameOf(email)}
<button className="msel-x" onClick={() => onToggle(email)} aria-label={`Remove ${nameOf(email)}`}>
✕
</button>
</span>
))}
</div>
)}
<input
className="input"
placeholder="Search speakers by name or email…"
value={query}
onChange={(e) => setQuery(e.target.value)}
/>
{matches.length > 0 && (
<div className="msel-list">
{matches.map((c) => {
const on = selected.includes(c.email);
return (
<button
key={c.email}
className={`msel-item ${on ? 'on' : ''}`}
onClick={() => onToggle(c.email)}
>
<span className="msel-check">{on ? '✓' : ''}</span>
<span className="n">{c.full_name}</span>
<span className="e">{c.email}</span>
</button>
);
})}
</div>
)}
</div>
);
}
function fmtDate(d: string): string {
return new Date(d + 'T00:00:00').toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
}
+47 -8
View File
@@ -186,8 +186,19 @@ function SponsorModal({
const [paid, setPaid] = useState(sponsor?.paid ?? false);
const [amount, setAmount] = useState(sponsor?.amount_eur != null ? String(sponsor.amount_eur) : '');
const [contactEmail, setContactEmail] = useState(sponsor?.contact_email ?? '');
const [contactQuery, setContactQuery] = useState('');
const [busy, setBusy] = useState(false);
const contactMatches = (() => {
const q = contactQuery.trim().toLowerCase();
const list = q
? contacts.filter(
(c) => c.full_name.toLowerCase().includes(q) || c.email.toLowerCase().includes(q),
)
: contacts;
return list.slice(0, 6);
})();
async function save() {
if (!name.trim()) return;
setBusy(true);
@@ -259,14 +270,42 @@ function SponsorModal({
</div>
<div className="field">
<label>Contact (lookup)</label>
<select className="input" value={contactEmail} onChange={(e) => setContactEmail(e.target.value)}>
<option value="">— none —</option>
{contacts.map((c) => (
<option key={c.email} value={c.email}>
{c.full_name}
</option>
))}
</select>
{contactEmail ? (
<div className="row" style={{ gap: 8 }}>
<span className="input" style={{ flex: 1, display: 'flex', alignItems: 'center' }}>
{contacts.find((c) => c.email === contactEmail)?.full_name ?? contactEmail}
</span>
<button className="btn small" onClick={() => { setContactEmail(''); setContactQuery(''); }}>
Clear
</button>
</div>
) : (
<>
<input
className="input"
placeholder="Search name or email…"
value={contactQuery}
onChange={(e) => setContactQuery(e.target.value)}
/>
{contactMatches.length > 0 && (
<div className="contact-pick">
{contactMatches.map((c) => (
<button
key={c.email}
className="contact-pick-item"
onClick={() => {
setContactEmail(c.email);
setContactQuery('');
}}
>
<span className="n">{c.full_name}</span>
<span className="e">{c.email}</span>
</button>
))}
</div>
)}
</>
)}
</div>
</div>
<div className="row">