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.

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 10:39:21 +02:00
1 parent 3fd8feca53
commit 2f3952dc71
30 files changed
+1083 -232

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ export function QrImage({ value, size = 180 }: { value: string; size?: number })
/** Small colored badge for a registration / sponsor type. */
export function TypeBadge({ type }: { type: string }) {
return <span className={`pill pill-${type}`}>{type.replace('_', ' ')}</span>;
return <span className={`pill ${type}`}>{type.replace(/_/g, ' ')}</span>;
}
/** A small on/off toggle switch. */
+23 -10
View File
@@ -66,15 +66,14 @@ export async function upsertContact(input: {
full_name: string;
linkedin_url?: string | null;
is_admin?: boolean;
qr_token?: string | null;
}): Promise<Contact> {
// upsert_contact returns a single composite row (a JSON object, not an array).
// Contacts no longer carry a QR token — the token lives on the registration.
return await rpc<Contact>('upsert_contact', {
p_email: input.email,
p_full_name: input.full_name,
p_linkedin_url: input.linkedin_url ?? null,
p_is_admin: input.is_admin ?? false,
p_qr_token: input.qr_token ?? null,
});
}
@@ -86,9 +85,13 @@ export async function updateContact(
if (error) throw new ApiError(error.message);
}
/** Regenerate a contact's QR token (syncs the auth password, forces re-login). */
/**
* Regenerate the QR token of a contact's registration for the active event
* (syncs the auth password, forces re-login). The token lives on the
* registration, not the contact.
*/
export async function resetQrToken(email: string): Promise<ResetQrResult> {
const rows = await rpc<ResetQrResult[]>('reset_qr_token', { p_contact_email: email });
const rows = await rpc<ResetQrResult[]>('reset_registration_qr_token', { p_contact_email: email });
return rows[0];
}
@@ -167,13 +170,23 @@ export async function adjustPoints(contactEmail: string, delta: number, reason:
// ---- Sessions: speakers, material, AI feedback -------------------------------
export async function setSessionSpeakers(sessionId: string, emails: string[]): Promise<void> {
// Replace the speaker set: delete all, then insert the new set.
const { error: delErr } = await supabase.from('session_speakers').delete().eq('session_id', sessionId);
if (delErr) throw new ApiError(delErr.message);
// Replace the speaker set with a diff: insert the new set first, then delete
// only the speakers that are no longer in the set. Deleting first would trip
// the `session_needs_speaker` trigger (it counts the row being deleted, so
// removing the last speaker always fails) and abort the whole save.
if (emails.length > 0) {
const rows = emails.map((contact_email) => ({ session_id: sessionId, contact_email }));
const { error: insErr } = await supabase.from('session_speakers').insert(rows);
// upsert (on conflict do nothing) so re-adding an existing speaker is a no-op.
const { error: insErr } = await supabase
.from('session_speakers')
.upsert(rows, { onConflict: 'session_id,contact_email', ignoreDuplicates: true });
if (insErr) throw new ApiError(insErr.message);
const { error: delErr } = await supabase
.from('session_speakers')
.delete()
.eq('session_id', sessionId)
.not('contact_email', 'in', `(${emails.join(',')})`);
if (delErr) throw new ApiError(delErr.message);
}
}
@@ -262,8 +275,8 @@ export async function exportQrCsv(eventId: string): Promise<number> {
let count = 0;
for (const r of regs) {
const c = byEmail.get(r.contact_email);
if (!c?.qr_token) continue;
lines.push([esc(c.full_name), esc(c.email), esc(r.type), esc(c.qr_token)].join(','));
if (!r.qr_token) continue;
lines.push([esc(c?.full_name ?? r.contact_email), esc(r.contact_email), esc(r.type), esc(r.qr_token)].join(','));
count++;
}
const blob = new Blob([lines.join('\n')], { type: 'text/csv;charset=utf-8' });
+1 -1
View File
@@ -19,7 +19,6 @@ export interface Contact {
show_email: boolean;
show_linkedin: boolean;
is_admin: boolean;
qr_token: string | null;
created_at: string;
}
@@ -45,6 +44,7 @@ export interface Registration {
type: RegistrationType;
checked_in: boolean;
points: number;
qr_token: string | null;
created_at: string;
}
+48 -9
View File
@@ -89,7 +89,7 @@ body {
font-size: 11.5px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); text-transform: capitalize;
}
.pill.attendee { background: rgba(148,163,184,.14); border-color: rgba(148,163,184,.4); color: #64748b; }
.pill.staff { background: rgba(32,178,170,.13); border-color: rgba(32,178,170,.4); color: #0f766e; }
.pill.staff { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.4); color: #b91c1c; }
.pill.admin { background: var(--accent-soft); border-color: rgba(213,0,0,.35); color: var(--accent); }
.pill.amber { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.4); color: #b45309; }
.pill.green { background: rgba(5,150,105,.12); border-color: rgba(5,150,105,.35); color: var(--green); }
@@ -239,15 +239,39 @@ table.data tr:hover td { background: rgba(244,245,249,.6); }
}
.event-name { font-size: 22px; font-weight: 900; letter-spacing: -.5px; }
/* ---------- Speaker picker (schedule) ---------- */
.speaker-pick { display: flex; flex-wrap: wrap; gap: 8px; max-height: 220px; overflow-y: auto; padding: 4px; }
.speaker-opt {
display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 600;
cursor: pointer; transition: all .12s;
/* ---------- Speaker multi-select (schedule) ---------- */
.msel { display: flex; flex-direction: column; gap: 8px; }
.msel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.msel-chip {
display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border-radius: 999px;
background: var(--accent-soft); border: 1px solid rgba(213,0,0,.35); color: var(--accent);
font-size: 12.5px; font-weight: 700;
}
.speaker-opt input { accent-color: var(--accent); }
.speaker-opt.on { background: var(--accent-soft); border-color: rgba(213,0,0,.4); color: var(--accent); }
.msel-x {
display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
border: none; border-radius: 50%; background: rgba(213,0,0,.12); color: var(--accent);
font-size: 10px; cursor: pointer; line-height: 1;
}
.msel-x:hover { background: rgba(213,0,0,.22); }
.msel-list {
border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
background: var(--surface); max-height: 200px; overflow-y: auto;
}
.msel-item {
display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
padding: 8px 12px; background: none; border: none; border-bottom: 1px solid var(--line);
cursor: pointer; font: inherit;
}
.msel-item:last-child { border-bottom: none; }
.msel-item:hover { background: var(--surface-2); }
.msel-item.on { background: var(--accent-soft); }
.msel-check {
width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center;
border: 1.5px solid var(--line); border-radius: 5px; font-size: 11px; color: var(--accent);
}
.msel-item.on .msel-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.msel-item .n { font-weight: 600; font-size: 13px; color: var(--text); }
.msel-item .e { font-size: 12px; color: var(--muted); margin-left: auto; }
/* ---------- AI feedback box (schedule) ---------- */
.ai-box {
@@ -268,6 +292,21 @@ table.data tr:hover td { background: rgba(244,245,249,.6); }
.toast-error { border-color: rgba(213,0,0,.55); }
.toast-info { border-color: rgba(32,178,170,.5); }
/* ---------- Contact search-and-pick (Sponsors) ------------------------------ */
.contact-pick {
margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
background: var(--surface); max-height: 180px; overflow-y: auto;
}
.contact-pick-item {
display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
padding: 8px 12px; background: none; border: none; border-bottom: 1px solid var(--line);
cursor: pointer; font: inherit;
}
.contact-pick-item:last-child { border-bottom: none; }
.contact-pick-item:hover { background: var(--surface-2); }
.contact-pick-item .n { font-weight: 600; font-size: 13px; color: var(--text); }
.contact-pick-item .e { font-size: 12px; color: var(--muted); }
/* ---------- Responsive: collapse sidebar to top bar on narrow screens ---------- */
@media (max-width: 760px) {
.app { flex-direction: column; }
+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">