Post-event reporting + talk networking incentives

- Talk networking: per-event talk_networking_bonus awarded when two people
  who shared a checked-in talk accept a connection (accept_connection
  re-created, shared_talk flag, get_talk_cohort RPC, points_log category
  check widened); Convivo Networking sub-tab inside the Connect screen
  (Home quick action deep-links in; Connect button reflects existing
  connection state and is disabled for sent/connected/declined); admin
  Events view bonus input (0-10).
- Reports: sidecar POST /export (CSV / multi-sheet XLSX / PDF report via
  new pdfkit dep); APPE Admin Reports view (any event: on-screen summary,
  session feedback summary, top-5, CSV/Excel/PDF downloads); Activity
  session-feedback per-session aggregate header.
- Also carried: @appe.at admin trigger + default password, bulk contact
  delete, session level/area + event-level feedback, agenda level/area
  filters, admin password self-service, schedule level/area fields.
- 18/18 RPC tests; both apps build; exports verified end-to-end.

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-09-21 22:34:25 +02:00
1 parent f74db9dc26
commit 0b6d1f2b6f
35 files changed
+3973 -54

No files matched your search

+76 -2
View File
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import {
@@ -26,8 +26,29 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
const fileRef = useRef<HTMLInputElement>(null);
const { toast } = useToast();
// Agenda filters: level + area (free-text, dynamic — built from the distinct
// values actually present in the agenda, so it works for numeric levels
// (100/200/300) or text levels (Beginner/Intermediate) alike).
const [levelFilter, setLevelFilter] = useState<string>('');
const [areaFilter, setAreaFilter] = useState<string>('');
const email = contact?.email ?? '';
// Distinct level + area values present in the agenda (for the filter dropdowns).
const levelOptions = useMemo(() => {
const set = new Set<string>();
for (const { sessions } of slots) for (const s of sessions) if (s.level) set.add(s.level);
return [...set].sort();
}, [slots]);
const areaOptions = useMemo(() => {
const set = new Set<string>();
for (const { sessions } of slots) for (const s of sessions) if (s.area) set.add(s.area);
return [...set].sort();
}, [slots]);
const matchesFilter = (s: Session) =>
(!levelFilter || s.level === levelFilter) && (!areaFilter || s.area === areaFilter);
useEffect(() => {
let active = true;
(async () => {
@@ -144,9 +165,60 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
Pick <b>one session per slot</b> — you can change until the slot starts.
</div>
{/* Agenda filters: level + area (only shown if there are values to filter by). */}
{(levelOptions.length > 0 || areaOptions.length > 0) && (
<div className="row" style={{ gap: 8, marginTop: 10, flexWrap: 'wrap' }}>
{levelOptions.length > 0 && (
<select
className="input"
style={{ flex: 1, minWidth: 120 }}
value={levelFilter}
onChange={(e) => setLevelFilter(e.target.value)}
aria-label="Filter by level"
>
<option value="">All levels</option>
{levelOptions.map((l) => (
<option key={l} value={l}>{l}</option>
))}
</select>
)}
{areaOptions.length > 0 && (
<select
className="input"
style={{ flex: 1, minWidth: 120 }}
value={areaFilter}
onChange={(e) => setAreaFilter(e.target.value)}
aria-label="Filter by area"
>
<option value="">All areas</option>
{areaOptions.map((a) => (
<option key={a} value={a}>{a}</option>
))}
</select>
)}
{(levelFilter || areaFilter) && (
<button
className="btn ghost small"
onClick={() => { setLevelFilter(''); setAreaFilter(''); }}
aria-label="Clear filters"
>
✕
</button>
)}
</div>
)}
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{slots.map(({ slot, sessions }) => {
const status = slotStatus(slot, now);
const isServiceSlot = slot.type === 'service_session';
// Apply the level/area filter to non-service sessions only (service
// sessions have no level/area and are always shown).
const visibleSessions = isServiceSlot
? sessions
: sessions.filter(matchesFilter);
// Skip the slot if it's a talk slot and all its sessions are filtered out.
if (!isServiceSlot && visibleSessions.length === 0) return null;
return (
<div className="slot-card" key={slot.id}>
<div className="slot-head">
@@ -160,7 +232,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
{status === 'now' && <span className="pill violet">● Live</span>}
{status === 'next' && <span className="pill cyan">Up next</span>}
</div>
{sessions.map((s) => {
{visibleSessions.map((s) => {
const picked = pickFor(slot.id) === s.id;
const isMySession = mySpeakerSessions.includes(s.id);
const isService = slot.type === 'service_session';
@@ -204,6 +276,8 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
</div>
<div className="row" style={{ gap: 8, marginBottom: 14, flexWrap: 'wrap' }}>
<span className="pill">{selIsService ? '' : '🎤 '}{selected.speakers}</span>
{selected.level && <span className="pill violet">📶 {selected.level}</span>}
{selected.area && <span className="pill cyan">🗂 {selected.area}</span>}
{selected.capacity && <span className="pill">👥 {selected.capacity}</span>}
{selCheckedIn && <span className="pill green">✓ Checked in</span>}
</div>
+16 -3
View File
@@ -6,10 +6,20 @@ import { capWords } from '../lib/time';
import type { Connection, PublicContact } from '../lib/types';
import { Avatar, Empty, Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
import { NetworkingPanel } from './Networking';
export function Connections() {
export function Connections({
initialTab = 'mine',
}: {
initialTab?: 'mine' | 'req' | 'networking';
}) {
const { contact } = useAuth();
const [tab, setTab] = useState<'mine' | 'req'>('mine');
const [tab, setTab] = useState<'mine' | 'req' | 'networking'>(initialTab);
// A deep-link (e.g. the Home "Networking" quick action) re-targets the tab.
useEffect(() => {
setTab(initialTab);
}, [initialTab]);
const [conns, setConns] = useState<Connection[]>([]);
const [people, setPeople] = useState<Map<string, PublicContact>>(new Map());
const [points, setPoints] = useState<Map<string, number>>(new Map());
@@ -71,12 +81,13 @@ export function Connections() {
return (
<section className="screen">
<div className="h1">Connections</div>
<div className="h1">{tab === 'networking' ? 'Networking' : 'Connections'}</div>
<div className="seg">
<button className={tab === 'mine' ? 'active' : ''} data-testid="connections-tab-mine" onClick={() => setTab('mine')}>My connections</button>
<button className={tab === 'req' ? 'active' : ''} data-testid="connections-tab-req" onClick={() => setTab('req')}>
Requests {incoming.length + outgoing.length > 0 && <span className="pill violet" style={{ marginLeft: 4 }}>{incoming.length + outgoing.length}</span>}
</button>
<button className={tab === 'networking' ? 'active' : ''} data-testid="connections-tab-networking" onClick={() => setTab('networking')}>🗣 Networking</button>
</div>
{tab === 'mine' &&
@@ -146,6 +157,8 @@ export function Connections() {
</div>
)}
{tab === 'networking' && <NetworkingPanel />}
{detail && (() => {
const p = people.get(detail.email);
const t = p?.registration_type ?? null;
+121
View File
@@ -0,0 +1,121 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { getMyEventFeedback, submitEventFeedback } from '../lib/api';
import { Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
/**
* Event-level feedback (distinct from the per-session Feedback screen).
* Any registered participant can rate the event overall (1–5) + leave a
* comment. Idempotent: one row per (event, contact) — re-submitting updates
* the existing row.
*/
export function EventFeedback({ onDone }: { onDone: () => void }) {
const { contact } = useAuth();
const { event, loading } = useEvent();
const [rating, setRating] = useState(0);
const [comment, setComment] = useState('');
const [busy, setBusy] = useState(false);
const [submitted, setSubmitted] = useState(false);
const { toast } = useToast();
// Pre-fill with the user's existing event feedback (if any).
useEffect(() => {
let active = true;
(async () => {
try {
const existing = await getMyEventFeedback();
if (!active || !existing) return;
setRating(existing.rating);
setComment(existing.comment ?? '');
setSubmitted(true);
} catch {
/* non-fatal */
}
})();
return () => {
active = false;
};
}, []);
if (loading || !event) {
return (
<section className="screen no-tab">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
async function submit() {
if (rating === 0) return;
setBusy(true);
try {
await submitEventFeedback(rating, comment.trim());
toast('Thanks for your feedback! ⭐', 'ok');
setSubmitted(true);
onDone();
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not submit feedback', 'err');
} finally {
setBusy(false);
}
}
return (
<section className="screen no-tab">
<div className="row" style={{ marginBottom: 14 }}>
<button className="btn ghost small" onClick={onDone}>← Back</button>
<div className="grow" style={{ textAlign: 'center' }}>
<div className="h2">Rate this event</div>
</div>
<span style={{ width: 60 }} />
</div>
<div className="card" style={{ textAlign: 'center' }}>
<div className="h2">{event.name}</div>
<div className="muted small" style={{ marginTop: 4 }}>
{event.location ? `${event.location} · ` : ''}
{event.start_date}
</div>
</div>
<div className="stars" style={{ justifyContent: 'center', margin: '20px 0' }}>
{[1, 2, 3, 4, 5].map((n) => (
<button
key={n}
data-testid={`event-feedback-star-${n}`}
className={`star ${n <= rating ? 'on' : ''}`}
onClick={() => setRating(n)}
aria-label={`${n} star${n > 1 ? 's' : ''}`}
>
★
</button>
))}
</div>
<textarea
className="input"
data-testid="event-feedback-comment"
placeholder="Share your thoughts about the event (optional)"
value={comment}
onChange={(e) => setComment(e.target.value)}
rows={4}
/>
<button
className="btn primary"
data-testid="event-feedback-submit"
disabled={busy || rating === 0}
onClick={submit}
>
{busy ? 'Submitting…' : submitted ? 'Update feedback' : 'Submit feedback'}
</button>
<div className="muted small" style={{ textAlign: 'center', marginTop: 8 }}>
{contact ? `Signing in as ${contact.full_name}` : ''}
</div>
</section>
);
}
+10 -1
View File
@@ -42,7 +42,7 @@ function ConcurrentList({ sessions }: { sessions: Session[] }) {
);
}
export function Home({ go }: { go: (tab: string) => void }) {
export function Home({ go, onEventFeedback }: { go: (tab: string) => void; onEventFeedback?: () => void }) {
const { contact, registration } = useAuth();
const { event, slots, sessionById, slotById, now, clockMode, loading } = useEvent();
const [prefs, setPrefs] = useState<Preference[]>([]);
@@ -236,11 +236,20 @@ export function Home({ go }: { go: (tab: string) => void }) {
<span className="ico">🤝</span>
<span className="lbl">Connections</span>
</div>
<div className="qa" onClick={() => go('networking')}>
<span className="ico">🗣</span>
<span className="lbl">Networking</span>
</div>
<div className="qa" onClick={() => go('leaderboard')}>
<span className="ico">🏆</span>
<span className="lbl">Leaderboard</span>
</div>
</div>
{onEventFeedback && (
<button className="btn ghost" style={{ width: '100%', marginTop: 10 }} onClick={onEventFeedback}>
⭐ Rate this event
</button>
)}
<div style={{ height: 8 }} />
{/* Pending material popup (speakers only, when a session is missing its attachment) */}
+219
View File
@@ -0,0 +1,219 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import {
createConnectionRequest,
getMyCheckins,
getMyConnections,
getTalkCohort,
} from '../lib/api';
import { capWords } from '../lib/time';
import type { Connection, TalkCohortMember } from '../lib/types';
import { Avatar, Empty, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
/**
* Networking around talks (an embeddable panel, shown as a tab inside the
* Connect screen). For every talk the user was checked into, list the other
* attendees who were also in that talk (the "talk cohort") so the user can
* make a connection. Accepting a connection with a shared talk earns the
* per-event talk networking bonus (see `events.talk_networking_bonus`).
*/
export function NetworkingPanel() {
const { contact } = useAuth();
const { event, sessionById, loading } = useEvent();
const [myCheckins, setMyCheckins] = useState<string[]>([]);
const [cohorts, setCohorts] = useState<Record<string, TalkCohortMember[]>>({});
const [loadingCohorts, setLoadingCohorts] = useState(false);
const [connecting, setConnecting] = useState<string | null>(null);
// The user's existing connections, so a Connect button can show the current
// state ("Sent" / "Connected" / …) instead of allowing duplicate requests.
const [conns, setConns] = useState<Connection[]>([]);
const { toast } = useToast();
const email = contact?.email ?? '';
const loadConns = useCallback(async () => {
try {
setConns(await getMyConnections());
} catch {
/* non-fatal */
}
}, []);
useEffect(() => {
if (email) void loadConns();
}, [email, loadConns]);
// Keep the connection states fresh (a peer may accept while the panel is open).
useEffect(() => {
window.addEventListener('connections-changed', loadConns);
return () => window.removeEventListener('connections-changed', loadConns);
}, [loadConns]);
/** The existing connection to a given person (any status), or null. */
const connWith = (theirEmail: string) =>
conns.find((c) => (c.from_email === email && c.to_email === theirEmail) ||
(c.from_email === theirEmail && c.to_email === email)) ?? null;
// Load the sessions the user is checked into, then each talk's cohort.
useEffect(() => {
if (!email) return;
let active = true;
(async () => {
try {
const ids = await getMyCheckins(email);
if (!active) return;
setMyCheckins(ids);
if (ids.length === 0) return;
setLoadingCohorts(true);
const results = await Promise.all(
ids.map(async (sid): Promise<[string, TalkCohortMember[]]> => {
try {
return [sid, await getTalkCohort(sid)];
} catch {
return [sid, []];
}
}),
);
if (!active) return;
const map: Record<string, TalkCohortMember[]> = {};
for (const [sid, list] of results) map[sid] = list;
setCohorts(map);
} catch {
/* non-fatal */
} finally {
if (active) setLoadingCohorts(false);
}
})();
return () => {
active = false;
};
}, [email]);
// Only show talks that actually exist in the agenda (check-ins for a
// service session or a removed session are skipped).
const myTalks = useMemo(
() => myCheckins.filter((sid) => sessionById.has(sid)).map((sid) => sessionById.get(sid)!),
[myCheckins, sessionById],
);
if (loading || !contact) {
return (
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
);
}
async function connect(member: TalkCohortMember) {
if (!member.qr_token) {
toast('No QR token for this attendee', 'err');
return;
}
// Never allow a duplicate request: if a connection already exists (any
// status), the button is disabled — this is the backstop.
if (connWith(member.email)) return;
setConnecting(member.email);
try {
const conn = await createConnectionRequest(member.qr_token);
if (conn.status === 'accepted') toast(`Connected with ${member.full_name}! 🤝`, 'ok');
else if (conn.status === 'pending') toast(`Request sent to ${member.full_name}`, 'ok');
else toast('Request already resolved');
window.dispatchEvent(new Event('connections-changed'));
await loadConns();
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not send request', 'err');
} finally {
setConnecting(null);
}
}
/** The Connect button state for a person: 'connect' | 'sent' | 'connected' | 'requested' | 'declined'. */
function connState(theirEmail: string): { label: string; kind: string } {
const c = connWith(theirEmail);
if (!c) return { label: 'Connect', kind: 'connect' };
if (c.status === 'accepted') return { label: 'Connected', kind: 'connected' };
if (c.status === 'pending') {
return c.from_email === email
? { label: 'Sent', kind: 'sent' }
: { label: 'Requested', kind: 'requested' };
}
return { label: 'Declined', kind: 'declined' };
}
const bonus = event?.talk_networking_bonus ?? 0;
return (
<div data-testid="networking-panel">
<div className="muted small" style={{ marginBottom: 14 }}>
People who were in the same talk as you.
{bonus > 0 ? (
<> Connect with them to earn <b>+{bonus} pts</b> (shared talk).</>
) : (
<> Connect with people you met at a talk.</>
)}
</div>
{myTalks.length === 0 ? (
<Empty icon="🗣" text="You haven’t been checked into a talk yet. Get checked in by staff to see who else was there." />
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{myTalks.map((talk) => {
const members = (cohorts[talk.id] ?? []).filter((m) => m.email !== email);
return (
<div className="card" key={talk.id} data-testid={`networking-talk-${talk.id}`}>
<div className="h2" style={{ marginBottom: 2 }}>{talk.title}</div>
<div className="muted small" style={{ marginBottom: 10 }}>
{talk.room ? `${talk.room} · ` : ''}
{talk.speakers ? `🎤 ${talk.speakers}` : ''}
</div>
{loadingCohorts && (
<div className="center" style={{ padding: 8 }}>
<Spinner />
</div>
)}
{!loadingCohorts && members.length === 0 && (
<div className="muted small">No one else was checked in here yet.</div>
)}
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{members.map((m) => (
<div className="conn" key={m.email} data-testid={`networking-member-${m.email}`}>
<Avatar name={m.full_name} id={m.email} size={40} />
<div className="grow">
<div className="name">{m.full_name}</div>
{m.registration_type && (
<div className="meta">{capWords(m.registration_type)}</div>
)}
</div>
{(() => {
const s = connState(m.email);
const disabled = s.kind !== 'connect' || connecting === m.email;
return (
<button
className={
s.kind === 'connected'
? 'btn small'
: s.kind === 'connect'
? 'btn primary small'
: 'btn ghost small'
}
data-testid={`networking-connect-${m.email}`}
disabled={disabled}
onClick={() => void connect(m)}
>
{connecting === m.email ? '…' : s.label}
</button>
);
})()}
</div>
))}
</div>
</div>
);
})}
</div>
)}
</div>
);
}
+1
View File
@@ -10,6 +10,7 @@ const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
checkin: 'Session check-ins',
connection: 'Connections',
feedback: 'Feedback',
talk_networking: 'Talk networking',
admin: 'Other',
};