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">
+7
View File
@@ -46,6 +46,13 @@ function Shell() {
// Keep the Connect red-dot fresh: poll every 5s while visible.
usePolling(() => void loadPending(), 5000, !!email);
// Recalc immediately when a connection is accepted/declined/sent.
useEffect(() => {
const onChanged = () => void loadPending();
window.addEventListener('connections-changed', onChanged);
return () => window.removeEventListener('connections-changed', onChanged);
}, [loadPending]);
if (loading) {
return (
<div className="app">
+5
View File
@@ -41,3 +41,8 @@ export function greeting(now: Date): string {
if (h < 18) return 'Good afternoon';
return 'Good evening';
}
/** "lunch_break" → "Lunch Break" (capitalize each word). */
export function capWords(s: string): string {
return s.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
}
+4 -2
View File
@@ -10,11 +10,12 @@ export interface Contact {
show_email: boolean;
show_linkedin: boolean;
is_admin: boolean;
qr_token: string | null;
created_at: string;
}
/** The signed-in contact's registration for the active event. */
/** The signed-in contact's registration for the active event.
* The QR token lives here (per event, generated by Pretix) and doubles as
* the login password. */
export interface Registration {
id: string;
event_id: string;
@@ -22,6 +23,7 @@ export interface Registration {
type: RegistrationType;
checked_in: boolean;
points: number;
qr_token: string | null;
created_at: string;
}
+52 -11
View File
@@ -1,9 +1,10 @@
import { useCallback, useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { acceptConnection, getMyConnections, getPublicContacts, rejectConnection } from '../lib/api';
import { acceptConnection, getLeaderboard, getMyConnections, getPublicContacts, rejectConnection } from '../lib/api';
import { usePolling } from '../lib/usePolling';
import { capWords } from '../lib/time';
import type { Connection, PublicContact } from '../lib/types';
import { Avatar, Empty, Spinner } from '../components/ui';
import { Avatar, Empty, Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
export function Connections() {
@@ -11,14 +12,17 @@ export function Connections() {
const [tab, setTab] = useState<'mine' | 'req'>('mine');
const [conns, setConns] = useState<Connection[]>([]);
const [people, setPeople] = useState<Map<string, PublicContact>>(new Map());
const [points, setPoints] = useState<Map<string, number>>(new Map());
const [detail, setDetail] = useState<{ email: string; status: Connection['status'] } | null>(null);
const [loading, setLoading] = useState(true);
const { toast } = useToast();
const load = useCallback(async () => {
try {
const [c, p] = await Promise.all([getMyConnections(), getPublicContacts()]);
const [c, p, lb] = await Promise.all([getMyConnections(), getPublicContacts(), getLeaderboard()]);
setConns(c);
setPeople(new Map(p.map((x) => [x.email, x])));
setPoints(new Map(lb.map((x) => [x.contact_email, x.points])));
} catch {
/* non-fatal */
} finally {
@@ -37,6 +41,7 @@ export function Connections() {
const me = contact.email;
const nameOf = (email: string) => people.get(email)?.full_name ?? '…';
const typeOf = (email: string) => people.get(email)?.registration_type ?? null;
const pointsOf = (email: string) => points.get(email) ?? 0;
const accepted = conns.filter((c) => c.status === 'accepted');
const incoming = conns.filter((c) => c.status === 'pending' && c.to_email === me);
@@ -47,6 +52,7 @@ export function Connections() {
if (accept) await acceptConnection(id);
else await rejectConnection(id);
toast(accept ? 'Connected! +5 pts 🤝' : 'Request declined', accept ? 'ok' : '');
window.dispatchEvent(new Event('connections-changed'));
await load();
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not update request', 'err');
@@ -80,11 +86,13 @@ export function Connections() {
accepted.map((c) => {
const otherEmail = c.from_email === me ? c.to_email : c.from_email;
return (
<div className="conn" key={c.id}>
<div className="conn clickable" key={c.id} onClick={() => setDetail({ email: otherEmail, status: c.status })}>
<Avatar name={nameOf(otherEmail)} id={otherEmail} size={44} />
<div className="grow">
<div className="name">{nameOf(otherEmail)}</div>
{typeOf(otherEmail) && <div className="meta">{typeOf(otherEmail)!.replace('_', ' ')}</div>}
{typeOf(otherEmail) && (
<div className="meta">{capWords(typeOf(otherEmail)!)}</div>
)}
</div>
<span className="pill green">Connected</span>
</div>
@@ -102,10 +110,15 @@ export function Connections() {
<div className="muted small" style={{ marginBottom: 8, fontWeight: 700 }}>Incoming</div>
{incoming.map((c) => (
<div className="conn" key={c.id}>
<Avatar name={nameOf(c.from_email)} id={c.from_email} size={44} />
<div className="grow">
<div className="name">{nameOf(c.from_email)}</div>
{typeOf(c.from_email) && <div className="meta">{typeOf(c.from_email)!.replace('_', ' ')}</div>}
<div className="clickable" style={{ display: 'flex', alignItems: 'center', gap: 10, flex: 1 }}
onClick={() => setDetail({ email: c.from_email, status: c.status })}>
<Avatar name={nameOf(c.from_email)} id={c.from_email} size={44} />
<div className="grow">
<div className="name">{nameOf(c.from_email)}</div>
{typeOf(c.from_email) && (
<div className="meta">{capWords(typeOf(c.from_email)!)}</div>
)}
</div>
</div>
<button className="btn primary small" onClick={() => resolve(c.id, true)}>Accept</button>
<button className="btn small" onClick={() => resolve(c.id, false)}>Decline</button>
@@ -117,11 +130,13 @@ export function Connections() {
<div>
<div className="muted small" style={{ marginBottom: 8, fontWeight: 700 }}>Sent</div>
{outgoing.map((c) => (
<div className="conn" key={c.id}>
<div className="conn clickable" key={c.id} onClick={() => setDetail({ email: c.to_email, status: c.status })}>
<Avatar name={nameOf(c.to_email)} id={c.to_email} size={44} />
<div className="grow">
<div className="name">{nameOf(c.to_email)}</div>
{typeOf(c.to_email) && <div className="meta">{typeOf(c.to_email)!.replace('_', ' ')}</div>}
{typeOf(c.to_email) && (
<div className="meta">{capWords(typeOf(c.to_email)!)}</div>
)}
</div>
<span className="pill amber">Pending</span>
</div>
@@ -130,6 +145,32 @@ export function Connections() {
)}
</div>
)}
{detail && (() => {
const p = people.get(detail.email);
const t = p?.registration_type ?? null;
return (
<Sheet open onClose={() => setDetail(null)}>
<div className="center" style={{ flexDirection: 'column', gap: 10, padding: '8px 0 20px' }}>
<Avatar name={p?.full_name ?? '…'} id={detail.email} size={72} />
<div className="h2" style={{ textAlign: 'center' }}>{p?.full_name ?? '…'}</div>
<div className="row" style={{ justifyContent: 'center', gap: 8 }}>
{t && <span className={`pill reg-${t}`}>{capWords(t)}</span>}
<span className="pill violet">⚡ {pointsOf(detail.email)} pts</span>
</div>
{p?.linkedin_url && (
<a className="link" href={p.linkedin_url} target="_blank" rel="noreferrer">
{p.linkedin_url.replace(/^https?:\/\//, '')}
</a>
)}
{p?.show_email && <div className="muted small">{detail.email}</div>}
<div className="muted small">
{detail.status === 'accepted' ? 'Connected' : detail.status === 'pending' ? 'Request pending' : 'Request declined'}
</div>
</div>
</Sheet>
);
})()}
</section>
);
}
+18 -15
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { getMyCheckins, getMyPreferences } from '../lib/api';
import { fmtRange, greeting, slotStatus } from '../lib/time';
import { capWords, fmtRange, greeting, slotStatus } from '../lib/time';
import type { Preference } from '../lib/types';
import { Avatar, Empty, Spinner } from '../components/ui';
@@ -107,22 +107,23 @@ export function Home({ go }: { go: (tab: string) => void }) {
<div>
<div className="row between" style={{ marginBottom: 9 }}>
<span className="h2">My picks today</span>
<span className="muted small">tap to change</span>
<a className="muted small link" onClick={() => go('agenda')}>tap to change</a>
</div>
<div style={{ display: 'flex', flexDirection: 'column' }}>
{slots.map(({ slot }) => {
const sid = pickFor(slot.id);
const s = sid ? sessionById.get(sid) : undefined;
return (
<button key={slot.id} className="pick-chip" onClick={() => go('agenda')}>
<span className="t">{fmtRange(slot)}</span>
{[
{ label: 'Now', slot: current?.slot, session: nowSession },
{ label: 'Next', slot: next?.slot, session: nextSession },
]
.filter((r) => r.slot)
.map((r) => (
<button key={r.label} className="pick-chip" onClick={() => go('agenda')}>
<span className="t">{fmtRange(r.slot!)}</span>
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
{s ? s.title : 'No pick yet'}
{r.session ? r.session.title : 'No pick yet'}
</span>
{s && <span className="muted small">{s.room}</span>}
{r.session && <span className="muted small">{r.session.room}</span>}
</button>
);
})}
))}
</div>
</div>
@@ -145,9 +146,11 @@ export function Home({ go }: { go: (tab: string) => void }) {
</div>
</div>
<div style={{ height: 8 }} />
<div className="muted small" style={{ textAlign: 'center', opacity: 0.5 }}>
<Avatar name={contact.full_name} id={contact.email} size={22} fs={9} /> {registration?.type.replace('_', ' ') ?? ''}
</div>
{registration && registration.type !== 'attendee' && (
<div className="muted small" style={{ textAlign: 'center', opacity: 0.5 }}>
<Avatar name={contact.full_name} id={contact.email} size={22} fs={9} /> {capWords(registration.type)}
</div>
)}
</section>
);
}
+2 -1
View File
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { supabase } from '../lib/supabase';
import { lanyardLookup } from '../lib/api';
import { capWords } from '../lib/time';
import type { PublicContact } from '../lib/types';
import { Avatar, Scanner } from '../components/ui';
import { useToast } from '../context/ToastContext';
@@ -88,7 +89,7 @@ export function Login() {
<div>
<div className="h2">{found ? found.full_name : 'Lanyard found'}</div>
<div className="muted small">
{found ? (found.registration_type ? found.registration_type.replace('_', ' ') : 'Confirm it’s you') : 'Confirm it’s you'}
{found ? (found.registration_type ? capWords(found.registration_type) : 'Confirm it’s you') : 'Confirm it’s you'}
</div>
</div>
</div>
+4 -3
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { getMyPointsLog } from '../lib/api';
import { capWords } from '../lib/time';
import type { PointsLogRow } from '../lib/types';
import { Avatar, QrImage, Spinner } from '../components/ui';
@@ -49,7 +50,7 @@ export function Profile() {
<div className="h2" style={{ marginTop: 10 }}>{contact.full_name}</div>
<div className="muted small">{contact.email}</div>
<div className="row" style={{ justifyContent: 'center', marginTop: 10, gap: 8 }}>
{registration && <span className={`pill reg-${registration.type}`}>{registration.type.replace('_', ' ')}</span>}
{registration && <span className={`pill reg-${registration.type}`}>{capWords(registration.type)}</span>}
{contact.is_admin && <span className="pill admin">staff</span>}
<span className="pill amber">⚡ {points} pts</span>
</div>
@@ -57,8 +58,8 @@ export function Profile() {
<div className="card qr-wrap">
<div className="h2">My QR code</div>
{contact.qr_token ? (
<QrImage value={contact.qr_token} size={180} />
{registration?.qr_token ? (
<QrImage value={registration.qr_token} size={180} />
) : (
<div className="muted small">No QR token assigned.</div>
)}
+3 -1
View File
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { checkinAttendee, createConnectionRequest, lanyardLookup } from '../lib/api';
import { capWords } from '../lib/time';
import type { CheckinResult, PublicContact } from '../lib/types';
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
@@ -74,6 +75,7 @@ export function Scan() {
if (conn.status === 'accepted') toast('You’re connected! 🤝', 'ok');
else if (conn.status === 'pending') toast('Connection request sent', 'ok');
else toast('Request already resolved');
window.dispatchEvent(new Event('connections-changed'));
setConnectTarget(null);
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not send request', 'err');
@@ -130,7 +132,7 @@ export function Scan() {
<h3 style={{ marginTop: 12 }}>{connectTarget.contact.full_name}</h3>
{connectTarget.contact.registration_type && (
<span className={`pill reg-${connectTarget.contact.registration_type}`} style={{ marginTop: 8 }}>
{connectTarget.contact.registration_type.replace('_', ' ')}
{capWords(connectTarget.contact.registration_type)}
</span>
)}
{connectTarget.contact.linkedin_url && (
+3 -1
View File
@@ -59,7 +59,7 @@ body {
/* registration types */
.pill.reg-attendee { background: rgba(148,163,184,.14); border-color: rgba(148,163,184,.4); color: #64748b; }
.pill.reg-speaker { background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.4); color: #6d28d9; }
.pill.reg-staff { background: rgba(32,178,170,.13); border-color: rgba(32,178,170,.4); color: #0f766e; }
.pill.reg-staff { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.4); color: #b91c1c; }
.pill.reg-sponsor { background: rgba(234,88,12,.13); border-color: rgba(234,88,12,.4); color: #c2410c; }
/* slot types */
.pill.slot-type-session { background: rgba(14,165,233,.12); border-color: rgba(14,165,233,.4); color: #0369a1; }
@@ -279,3 +279,5 @@ textarea.input { resize: none; min-height: 96px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: flex; align-items: center; justify-content: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.clickable { cursor: pointer; }