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

+84 -5
View File
@@ -3,14 +3,15 @@ import {
getAllCheckins,
getAllConnections,
getAllContacts,
getAllEventFeedback,
getAllFeedback,
getActiveEvent,
getSessions,
} from '../lib/api';
import type { Checkin, Connection, Contact, Event, Feedback, Session } from '../lib/types';
import type { Checkin, Connection, Contact, Event, EventFeedback, Feedback, Session } from '../lib/types';
import { Avatar, Empty, Spinner } from '../components/ui';
type Tab = 'checkins' | 'connections' | 'feedback';
type Tab = 'checkins' | 'connections' | 'feedback' | 'event_feedback';
export function Activity() {
const [event, setEvent] = useState<Event | null>(null);
@@ -21,17 +22,19 @@ export function Activity() {
const [checkins, setCheckins] = useState<Checkin[]>([]);
const [connections, setConnections] = useState<Connection[]>([]);
const [feedback, setFeedback] = useState<Feedback[]>([]);
const [eventFeedback, setEventFeedback] = useState<EventFeedback[]>([]);
const [error, setError] = useState<string | null>(null);
async function load() {
try {
const ev = await getActiveEvent();
setEvent(ev);
const [c, ck, cn, fb] = await Promise.all([
const [c, ck, cn, fb, efb] = await Promise.all([
getAllContacts(),
getAllCheckins(),
getAllConnections(),
getAllFeedback(),
getAllEventFeedback(),
]);
setContacts(c);
if (ev) {
@@ -40,6 +43,7 @@ export function Activity() {
setCheckins(ck.filter((x) => x.event_id === ev.id));
setConnections(cn.filter((x) => x.event_id === ev.id));
setFeedback(fb.filter((x) => x.event_id === ev.id));
setEventFeedback(efb.filter((x) => x.event_id === ev.id));
}
setLoaded(true);
} catch (e) {
@@ -61,6 +65,26 @@ export function Activity() {
return (id: string) => m.get(id) ?? id;
}, [sessions]);
// Per-session feedback aggregate (avg rating + response count), for the
// post-event session feedback summary.
const sessionFeedbackSummary = useMemo(() => {
const bySession = new Map<string, { count: number; sum: number }>();
for (const f of feedback) {
const e = bySession.get(f.session_id) ?? { count: 0, sum: 0 };
e.count += 1;
e.sum += f.rating;
bySession.set(f.session_id, e);
}
return [...bySession.entries()]
.map(([session_id, e]) => ({
session_id,
title: sessionTitle(session_id),
avg: e.sum / e.count,
count: e.count,
}))
.sort((a, b) => b.avg - a.avg);
}, [feedback, sessionTitle]);
if (error) return <Empty icon="⚠️" text={error} />;
if (!loaded)
return (
@@ -91,7 +115,7 @@ export function Activity() {
<div>
<h1>Activity</h1>
<div className="sub">
{event.name} · {checkins.length} check-ins · {connections.length} connections · {feedback.length} feedback.
{event.name} · {checkins.length} check-ins · {connections.length} connections · {feedback.length} session feedback · {eventFeedback.length} event feedback.
</div>
</div>
</div>
@@ -104,7 +128,10 @@ export function Activity() {
Connections
</button>
<button className={tab === 'feedback' ? 'active' : ''} onClick={() => setTab('feedback')}>
Feedback
Session feedback
</button>
<button className={tab === 'event_feedback' ? 'active' : ''} onClick={() => setTab('event_feedback')}>
Event feedback
</button>
</div>
@@ -185,6 +212,23 @@ export function Activity() {
{feedback.length === 0 ? (
<Empty icon="⭐" text="No feedback yet." />
) : (
<>
{/* Per-session aggregate header (the post-event session feedback summary). */}
<div style={{ marginBottom: 12 }}>
<div className="muted small" style={{ fontWeight: 700, marginBottom: 6 }}>
Per-session summary
</div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{sessionFeedbackSummary.map((s) => (
<span key={s.session_id} className="pill amber" title={s.title}>
{s.title} · {s.avg.toFixed(1)}★ · {s.count}
</span>
))}
</div>
</div>
</>
)}
{feedback.length > 0 && (
<div className="table-wrap">
<table className="data">
<thead>
@@ -216,6 +260,41 @@ export function Activity() {
)}
</div>
)}
{tab === 'event_feedback' && (
<div className="card">
{eventFeedback.length === 0 ? (
<Empty icon="⭐" text="No event-level feedback yet." />
) : (
<div className="table-wrap">
<table className="data">
<thead>
<tr>
<th>From</th>
<th>Rating</th>
<th>Comment</th>
<th>When</th>
</tr>
</thead>
<tbody>
{eventFeedback.map((f) => (
<tr key={f.id}>
<td>
<PersonCell name={nameOf(f.contact_email)} email={f.contact_email} />
</td>
<td>
<span className="pill amber">{'★'.repeat(f.rating)}</span>
</td>
<td className="muted">{f.comment || '—'}</td>
<td className="muted">{fmt(f.created_at)}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
)}
</div>
);
}
+23
View File
@@ -293,6 +293,7 @@ function EventModal({
const [pretixLoading, setPretixLoading] = useState(false);
const [pretixError, setPretixError] = useState<string | null>(null);
const [realtimeClock, setRealtimeClock] = useState(event?.use_realtime_clock ?? false);
const [talkBonus, setTalkBonus] = useState(event?.talk_networking_bonus ?? 2);
const [busy, setBusy] = useState(false);
const lastFetchedKey = useRef<string | null>(null);
@@ -339,6 +340,7 @@ function EventModal({
pretix_event_slug: pretixEventSlug.trim() || null,
pretix_api_key: pretixApiKey.trim() || null,
use_realtime_clock: realtimeClock,
talk_networking_bonus: Math.max(0, Math.min(10, Math.round(talkBonus) || 0)),
});
onSaved(event ? 'Event updated' : 'Event created');
} catch (e) {
@@ -491,6 +493,27 @@ function EventModal({
<Toggle checked={realtimeClock} onChange={setRealtimeClock} label={realtimeClock ? 'On' : 'Off'} />
</div>
</div>
<div className="field">
<div className="row between" style={{ alignItems: 'center' }}>
<div>
<label>Talk networking bonus</label>
<div className="muted small" style={{ marginTop: 2, maxWidth: 420 }}>
Points each party earns when two people who were checked into the same talk accept a
connection. <b>0 disables</b> the bonus (the +5 connection award still applies).
</div>
</div>
<input
className="input mono"
type="number"
min={0}
max={10}
step={1}
style={{ width: 84, textAlign: 'center' }}
value={Number.isFinite(talkBonus) ? talkBonus : 0}
onChange={(e) => setTalkBonus(parseInt(e.target.value, 10) || 0)}
/>
</div>
</div>
</Modal>
);
}
+404
View File
@@ -0,0 +1,404 @@
import { useEffect, useMemo, useState } from 'react';
import {
downloadReport,
exportEventReport,
getAllCheckins,
getAllConnections,
getAllContacts,
getAllEventFeedback,
getAllEvents,
getAllFeedback,
getAllPointsLog,
getLeaderboard,
getRegistrations,
getSessions,
} from '../lib/api';
import type {
Checkin,
Connection,
Contact,
Event,
EventFeedback,
Feedback,
LeaderboardRow,
PointsLogRow,
Registration,
Session,
} from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Empty, Spinner } from '../components/ui';
const TABLES = [
'registrations',
'checkins',
'connections',
'session_feedback',
'event_feedback',
'leaderboard',
'points_log',
] as const;
const CATEGORY_LABEL: Record<string, string> = {
checkin: 'Session check-ins',
connection: 'Connections',
feedback: 'Feedback',
talk_networking: 'Talk networking',
admin: 'Other',
};
/**
* Post-event reporting & export. For any event (active or past): an on-screen
* summary (session-feedback summary + aggregates) and CSV / Excel / PDF report
* downloads (served by the sidecar's `POST /export`).
*/
export function Reports() {
const { push } = useToast();
const [events, setEvents] = useState<Event[]>([]);
const [selectedId, setSelectedId] = useState('');
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<string | null>(null);
const [contacts, setContacts] = useState<Contact[]>([]);
const [registrations, setRegistrations] = useState<Registration[]>([]);
const [checkins, setCheckins] = useState<Checkin[]>([]);
const [connections, setConnections] = useState<Connection[]>([]);
const [feedback, setFeedback] = useState<Feedback[]>([]);
const [eventFeedback, setEventFeedback] = useState<EventFeedback[]>([]);
const [leaderboard, setLeaderboard] = useState<LeaderboardRow[]>([]);
const [pointsLog, setPointsLog] = useState<PointsLogRow[]>([]);
const [sessions, setSessions] = useState<Session[]>([]);
const [tables, setTables] = useState<Set<string>>(new Set(TABLES));
const [exporting, setExporting] = useState<'csv' | 'xlsx' | 'pdf' | null>(null);
async function load() {
try {
const evs = await getAllEvents();
setEvents(evs);
const active = evs.find((e) => e.is_active);
const first = active ?? evs[0];
if (first) setSelectedId((cur) => cur || first.id);
setLoaded(true);
} catch (e) {
setError(e instanceof Error ? e.message : 'Failed to load');
}
}
useEffect(() => {
load();
}, []);
// Load the selected event's data (any event, not just the active one).
useEffect(() => {
if (!selectedId) return;
let active = true;
(async () => {
try {
const [c, reg, ck, cn, fb, efb, lb, pl, ss] = await Promise.all([
getAllContacts(),
getRegistrations(selectedId),
getAllCheckins(),
getAllConnections(),
getAllFeedback(),
getAllEventFeedback(),
getLeaderboard(),
getAllPointsLog(),
getSessions(selectedId),
]);
if (!active) return;
setContacts(c);
setRegistrations(reg);
setCheckins(ck.filter((x) => x.event_id === selectedId));
setConnections(cn.filter((x) => x.event_id === selectedId));
setFeedback(fb.filter((x) => x.event_id === selectedId));
setEventFeedback(efb.filter((x) => x.event_id === selectedId));
setLeaderboard(lb.filter((x) => x.event_id === selectedId));
setPointsLog(pl.filter((x) => x.event_id === selectedId));
setSessions(ss);
} catch (e) {
if (active) setError(e instanceof Error ? e.message : 'Failed to load event data');
}
})();
return () => {
active = false;
};
}, [selectedId]);
const nameOf = useMemo(() => {
const m = new Map(contacts.map((c) => [c.email, c.full_name]));
return (email: string) => m.get(email) ?? email;
}, [contacts]);
// ---- Aggregates -----------------------------------------------------------
const byType = useMemo(() => {
const t: Record<string, number> = {};
for (const r of registrations) t[r.type] = (t[r.type] ?? 0) + 1;
return t;
}, [registrations]);
const acceptedConnections = useMemo(
() => connections.filter((c) => c.status === 'accepted').length,
[connections],
);
const sessionFeedbackAvg = useMemo(() => {
if (feedback.length === 0) return null;
return feedback.reduce((s, f) => s + f.rating, 0) / feedback.length;
}, [feedback]);
const eventFeedbackAvg = useMemo(() => {
if (eventFeedback.length === 0) return null;
return eventFeedback.reduce((s, f) => s + f.rating, 0) / eventFeedback.length;
}, [eventFeedback]);
// Per-session feedback summary (the "post-event session feedback summary").
const sessionSummary = useMemo(() => {
const bySession = new Map<string, { count: number; sum: number }>();
for (const f of feedback) {
const e = bySession.get(f.session_id) ?? { count: 0, sum: 0 };
e.count += 1;
e.sum += f.rating;
bySession.set(f.session_id, e);
}
return sessions
.map((s) => {
const e = bySession.get(s.id);
return {
title: s.title,
room: s.room,
avg: e ? e.sum / e.count : null,
count: e ? e.count : 0,
};
})
.filter((s) => s.count > 0)
.sort((a, b) => (b.avg ?? 0) - (a.avg ?? 0));
}, [sessions, feedback]);
const topLeaderboard = useMemo(
() => [...leaderboard].sort((a, b) => b.points - a.points).slice(0, 5),
[leaderboard],
);
const pointsByCategory = useMemo(() => {
const t: Record<string, number> = {};
for (const l of pointsLog) t[l.category] = (t[l.category] ?? 0) + l.delta;
return t;
}, [pointsLog]);
// ---- Export -------------------------------------------------------------
async function doExport(format: 'csv' | 'xlsx' | 'pdf') {
if (!selectedId) return;
setExporting(format);
try {
const res = await exportEventReport(selectedId, format, format === 'pdf' ? undefined : [...tables]);
downloadReport(res);
push('success', `Downloaded ${format.toUpperCase()} report`);
} catch (e) {
push('error', e instanceof Error ? e.message : 'Export failed');
} finally {
setExporting(null);
}
}
function toggleTable(t: string) {
setTables((prev) => {
const next = new Set(prev);
if (next.has(t)) next.delete(t);
else next.add(t);
return next;
});
}
if (error) return <Empty icon="⚠️" text={error} />;
if (!loaded)
return (
<div className="loading-screen">
<Spinner />
</div>
);
const selected = events.find((e) => e.id === selectedId);
return (
<div>
<div className="page-head">
<div>
<h1>Reports</h1>
<div className="sub">Post-event summary + CSV / Excel / PDF export. Works for any event.</div>
</div>
<select
className="input"
style={{ maxWidth: 320 }}
value={selectedId}
onChange={(e) => setSelectedId(e.target.value)}
>
{events.map((e) => (
<option key={e.id} value={e.id}>
{e.name} {e.is_active ? '(active)' : ''}
</option>
))}
</select>
</div>
{!selected ? (
<div className="card">
<Empty icon="📅" text="No events yet. Create one in the Events view first." />
</div>
) : (
<>
{/* On-screen summary */}
<div className="card" style={{ marginBottom: 18 }}>
<h2 className="h2">📊 Summary — {selected.name}</h2>
<div className="muted small" style={{ marginBottom: 12 }}>
{selected.start_date} – {selected.end_date}
{selected.location ? ` · ${selected.location}` : ''}
</div>
<div className="stat-grid">
<Stat label="Registrations" value={registrations.length} />
<Stat label="Check-ins" value={checkins.length} />
<Stat label="Connections" value={connections.length} sub={`${acceptedConnections} accepted`} />
<Stat label="Session feedback" value={feedback.length} sub={sessionFeedbackAvg != null ? `avg ${sessionFeedbackAvg.toFixed(1)}★` : undefined} />
<Stat label="Event feedback" value={eventFeedback.length} sub={eventFeedbackAvg != null ? `avg ${eventFeedbackAvg.toFixed(1)}★` : undefined} />
</div>
<div style={{ display: 'flex', gap: 18, flexWrap: 'wrap', marginTop: 14 }}>
<div>
<div className="muted small" style={{ fontWeight: 700, marginBottom: 6 }}>Registrations by type</div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{Object.entries(byType).map(([t, n]) => (
<span key={t} className="pill">{t}: {n}</span>
))}
</div>
</div>
<div>
<div className="muted small" style={{ fontWeight: 700, marginBottom: 6 }}>Points by category</div>
<div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
{Object.entries(pointsByCategory).map(([c, n]) => (
<span key={c} className="pill">{CATEGORY_LABEL[c] ?? c}: +{n}</span>
))}
</div>
</div>
</div>
</div>
{/* Session feedback summary */}
<div className="card" style={{ marginBottom: 18 }}>
<h2 className="h2">⭐ Session feedback summary</h2>
{sessionSummary.length === 0 ? (
<Empty icon="⭐" text="No session feedback yet." />
) : (
<div className="table-wrap">
<table className="data">
<thead>
<tr>
<th>Session</th>
<th>Room</th>
<th>Avg rating</th>
<th>Responses</th>
</tr>
</thead>
<tbody>
{sessionSummary.map((s) => (
<tr key={s.title}>
<td style={{ fontWeight: 600 }}>{s.title}</td>
<td className="muted">{s.room ?? '—'}</td>
<td>
<span className="pill amber">
{s.avg != null ? `${s.avg.toFixed(1)}★` : '—'}
</span>
</td>
<td className="muted">{s.count}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
{/* Top leaderboard */}
<div className="card" style={{ marginBottom: 18 }}>
<h2 className="h2">🏆 Top points</h2>
{topLeaderboard.length === 0 ? (
<Empty icon="🏆" text="No points yet." />
) : (
<div className="table-wrap">
<table className="data">
<thead>
<tr>
<th>#</th>
<th>Attendee</th>
<th>Points</th>
</tr>
</thead>
<tbody>
{topLeaderboard.map((r, i) => (
<tr key={r.contact_email}>
<td className="muted">{i + 1}</td>
<td style={{ fontWeight: 600 }}>{nameOf(r.contact_email)}</td>
<td>
<span className="pill amber">⚡ {r.points}</span>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
{/* Export */}
<div className="card">
<h2 className="h2">📤 Export</h2>
<div style={{ display: 'flex', gap: 10, flexWrap: 'wrap', marginBottom: 14 }}>
<button
className="btn primary"
disabled={exporting !== null || tables.size === 0}
onClick={() => void doExport('csv')}
>
{exporting === 'csv' ? 'Preparing…' : 'Download CSV'}
</button>
<button
className="btn primary"
disabled={exporting !== null || tables.size === 0}
onClick={() => void doExport('xlsx')}
>
{exporting === 'xlsx' ? 'Preparing…' : 'Download Excel'}
</button>
<button className="btn primary" disabled={exporting !== null} onClick={() => void doExport('pdf')}>
{exporting === 'pdf' ? 'Preparing…' : 'Download PDF report'}
</button>
</div>
<div className="muted small" style={{ marginBottom: 8 }}>
Tables included in CSV / Excel:
</div>
<div style={{ display: 'flex', gap: 14, flexWrap: 'wrap' }}>
{TABLES.map((t) => (
<label key={t} style={{ display: 'inline-flex', alignItems: 'center', gap: 6, cursor: 'pointer' }}>
<input
type="checkbox"
checked={tables.has(t)}
onChange={() => toggleTable(t)}
style={{ width: 16, height: 16, accentColor: 'var(--accent)' }}
/>
<span className="muted small">{t.replace('_', ' ')}</span>
</label>
))}
</div>
</div>
</>
)}
</div>
);
}
function Stat({ label, value, sub }: { label: string; value: number; sub?: string }) {
return (
<div className="stat">
<div className="val">{value}</div>
<div className="lbl">
{label}
{sub ? ` · ${sub}` : ''}
</div>
</div>
);
}
+15 -1
View File
@@ -193,7 +193,7 @@ export function Schedule() {
<div style={{ minWidth: 0 }}>
<div style={{ fontWeight: 700, fontSize: 14 }}>{s.title}</div>
<div className="muted small">
{[s.room, spk || 'no speakers', s.capacity ? `cap ${s.capacity}` : null].filter(Boolean).join(' · ')}
{[s.room, spk || 'no speakers', s.capacity ? `cap ${s.capacity}` : null, s.level ? `📶 ${s.level}` : null, s.area ? `🗂 ${s.area}` : null].filter(Boolean).join(' · ')}
</div>
<div className="muted small" style={{ marginTop: 4 }}>
{s.average_feedback != null && <span>⭐ {s.average_feedback.toFixed(1)}</span>}
@@ -364,6 +364,8 @@ function SessionModal({
const [room, setRoom] = useState(session?.room ?? '');
const [capacity, setCapacity] = useState(session?.capacity?.toString() ?? '');
const [description, setDescription] = useState(session?.description ?? '');
const [level, setLevel] = useState(session?.level ?? '');
const [area, setArea] = useState(session?.area ?? '');
const [speakerEmails, setSpeakerEmails] = useState<string[]>(currentSpeakers);
const [material, setMaterial] = useState<File | null>(null);
const [busy, setBusy] = useState(false);
@@ -377,6 +379,8 @@ function SessionModal({
room: room.trim() || null,
capacity: capacity ? parseInt(capacity, 10) : null,
description: description.trim() || null,
level: level.trim() || null,
area: area.trim() || null,
slot_id: slotId,
event_id: eventId,
};
@@ -445,6 +449,16 @@ function SessionModal({
<label>Description</label>
<textarea className="input" value={description} onChange={(e) => setDescription(e.target.value)} placeholder="—" />
</div>
<div className="grid-2">
<div className="field">
<label>Level</label>
<input className="input" value={level} onChange={(e) => setLevel(e.target.value)} placeholder="e.g. 100 / Beginner" />
</div>
<div className="field">
<label>Area / Topic</label>
<input className="input" value={area} onChange={(e) => setArea(e.target.value)} placeholder="e.g. Power Apps" />
</div>
</div>
<div className="field">
<label>Speakers ({speakerEmails.length})</label>