From 0b6d1f2b6fe7bfb283614135c926b718e11113bb Mon Sep 17 00:00:00 2001 From: Jose Lago Date: Mon, 21 Sep 2026 22:34:25 +0200 Subject: [PATCH] Post-event reporting + talk networking incentives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 Co-authored-by: Amelia Hernandez Co-authored-by: Markus Franz Co-authored-by: Sabrina Hota Co-authored-by: NilΓΌfer Doğan --- README.md | 1 + apps/admin/src/App.tsx | 105 +- apps/admin/src/context/AuthContext.tsx | 13 +- apps/admin/src/lib/api.ts | 63 +- apps/admin/src/lib/types.ts | 18 +- apps/admin/src/views/Activity.tsx | 89 +- apps/admin/src/views/Events.tsx | 23 + apps/admin/src/views/Reports.tsx | 404 ++++++ apps/admin/src/views/Schedule.tsx | 16 +- apps/convivo/src/App.tsx | 29 +- apps/convivo/src/lib/api.ts | 26 +- apps/convivo/src/lib/types.ts | 34 +- apps/convivo/src/screens/Agenda.tsx | 78 +- apps/convivo/src/screens/Connections.tsx | 19 +- apps/convivo/src/screens/EventFeedback.tsx | 121 ++ apps/convivo/src/screens/Home.tsx | 11 +- apps/convivo/src/screens/Networking.tsx | 219 +++ apps/convivo/src/screens/Profile.tsx | 1 + apps/sidecar/package-lock.json | 1188 +++++++++++++++++ apps/sidecar/package.json | 1 + apps/sidecar/src/server.js | 311 +++++ docs/architecture.md | 7 + docs/backend/rpcs.md | 17 +- docs/backend/schema.md | 3 +- docs/backend/seed.md | 9 + docs/backend/sidecar.md | 25 +- docs/frontend/admin-app.md | 23 +- docs/frontend/screens.md | 36 +- docs/next-steps.md | 52 +- roadmap.md | 8 +- .../20260910000000_admin_default_password.sql | 189 +++ ...0260910010000_bulk_delete_contacts_rpc.sql | 73 + ...0000_session_level_area_event_feedback.sql | 575 ++++++++ .../20260920000000_talk_networking.sql | 123 ++ supabase/tests/rpc_tests.sql | 117 +- 35 files changed, 3973 insertions(+), 54 deletions(-) create mode 100644 apps/admin/src/views/Reports.tsx create mode 100644 apps/convivo/src/screens/EventFeedback.tsx create mode 100644 apps/convivo/src/screens/Networking.tsx create mode 100644 apps/sidecar/package-lock.json create mode 100644 supabase/migrations/20260910000000_admin_default_password.sql create mode 100644 supabase/migrations/20260910010000_bulk_delete_contacts_rpc.sql create mode 100644 supabase/migrations/20260910020000_session_level_area_event_feedback.sql create mode 100644 supabase/migrations/20260920000000_talk_networking.sql diff --git a/README.md b/README.md index 10fd5c6..6e40135 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ Check-in tab. |---|---| | Checked into a session (by staff) | **+10** | | Connection accepted | **+5 each** (both people) | +| Connection accepted **with a shared talk** | **+`talk_networking_bonus` each** (per event, default 2, `0` = off) | | Feedback β€” rating only | **+5** | | Feedback β€” rating + free text | **+10 total** | diff --git a/apps/admin/src/App.tsx b/apps/admin/src/App.tsx index df3973f..b816790 100644 --- a/apps/admin/src/App.tsx +++ b/apps/admin/src/App.tsx @@ -1,6 +1,6 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { AuthProvider, useAuth } from './context/AuthContext'; -import { ToastProvider } from './context/ToastContext'; +import { ToastProvider, useToast } from './context/ToastContext'; import { Login } from './screens/Login'; import { Dashboard } from './views/Dashboard'; import { Contacts } from './views/Contacts'; @@ -10,7 +10,9 @@ import { Schedule } from './views/Schedule'; import { Activity } from './views/Activity'; import { Events } from './views/Events'; import { Interfaces } from './views/Interfaces'; -import { Spinner } from './components/ui'; +import { Reports } from './views/Reports'; +import { Spinner, Modal } from './components/ui'; +import { DEFAULT_ADMIN_PASSWORD } from './lib/api'; export type View = | 'dashboard' @@ -20,7 +22,8 @@ export type View = | 'schedule' | 'activity' | 'events' - | 'interfaces'; + | 'interfaces' + | 'reports'; const NAV: { id: View; label: string; ico: string }[] = [ { id: 'dashboard', label: 'Dashboard', ico: 'πŸ“Š' }, @@ -31,8 +34,100 @@ const NAV: { id: View; label: string; ico: string }[] = [ { id: 'activity', label: 'Activity', ico: '⚑' }, { id: 'events', label: 'Events', ico: 'πŸ“…' }, { id: 'interfaces', label: 'Interfaces', ico: 'πŸ”Œ' }, + { id: 'reports', label: 'Reports', ico: 'πŸ“€' }, ]; +/** + * Shown once per session when an admin signs in with the default password + * (`appe-admin-2026`). Prompts them to set a personal password. Dismissable + * ("Not now"); the prompt re-appears on the next sign-in while the default is + * in use. + */ +function ChangePasswordPrompt() { + const { contact, changePassword } = useAuth(); + const { push } = useToast(); + const [open, setOpen] = useState(false); + const [newPassword, setNewPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + + // Open the prompt when the signed-in admin is using the default password. + useEffect(() => { + if (contact && contact.password === DEFAULT_ADMIN_PASSWORD) setOpen(true); + }, [contact]); + + async function onSubmit() { + if (newPassword.length < 6) { + setError('Password must be at least 6 characters.'); + return; + } + if (newPassword !== confirmPassword) { + setError('Passwords do not match.'); + return; + } + setBusy(true); + setError(null); + try { + await changePassword(newPassword); + push('success', 'Password updated'); + setOpen(false); + setNewPassword(''); + setConfirmPassword(''); + } catch (err) { + setError(err instanceof Error ? err.message : 'Failed to change password'); + } finally { + setBusy(false); + } + } + + return ( + setOpen(false)} + title="Change your password" + footer={ + <> + + + + } + > +

+ You signed in with the default admin password. Set a personal password + so only you can access this account. +

+
+ + setNewPassword(e.target.value)} + autoComplete="new-password" + /> +
+
+ + setConfirmPassword(e.target.value)} + autoComplete="new-password" + /> +
+ {error &&
{error}
} +
+ ); +} + function Shell() { const { contact, loading, signOut } = useAuth(); const [view, setView] = useState('dashboard'); @@ -49,6 +144,7 @@ function Shell() { return (
+
@@ -104,7 +128,10 @@ export function Activity() { Connections + @@ -185,6 +212,23 @@ export function Activity() { {feedback.length === 0 ? ( ) : ( + <> + {/* Per-session aggregate header (the post-event session feedback summary). */} +
+
+ Per-session summary +
+
+ {sessionFeedbackSummary.map((s) => ( + + {s.title} Β· {s.avg.toFixed(1)}β˜… Β· {s.count} + + ))} +
+
+ + )} + {feedback.length > 0 && (
@@ -216,6 +260,41 @@ export function Activity() { )} )} + + {tab === 'event_feedback' && ( +
+ {eventFeedback.length === 0 ? ( + + ) : ( +
+
+ + + + + + + + + + {eventFeedback.map((f) => ( + + + + + + + ))} + +
FromRatingCommentWhen
+ + + {'β˜…'.repeat(f.rating)} + {f.comment || 'β€”'}{fmt(f.created_at)}
+
+ )} + + )} ); } diff --git a/apps/admin/src/views/Events.tsx b/apps/admin/src/views/Events.tsx index f972cca..1075d93 100644 --- a/apps/admin/src/views/Events.tsx +++ b/apps/admin/src/views/Events.tsx @@ -293,6 +293,7 @@ function EventModal({ const [pretixLoading, setPretixLoading] = useState(false); const [pretixError, setPretixError] = useState(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(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({ +
+
+
+ +
+ Points each party earns when two people who were checked into the same talk accept a + connection. 0 disables the bonus (the +5 connection award still applies). +
+
+ setTalkBonus(parseInt(e.target.value, 10) || 0)} + /> +
+
); } diff --git a/apps/admin/src/views/Reports.tsx b/apps/admin/src/views/Reports.tsx new file mode 100644 index 0000000..5a94a7e --- /dev/null +++ b/apps/admin/src/views/Reports.tsx @@ -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 = { + 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([]); + const [selectedId, setSelectedId] = useState(''); + const [loaded, setLoaded] = useState(false); + const [error, setError] = useState(null); + + const [contacts, setContacts] = useState([]); + const [registrations, setRegistrations] = useState([]); + const [checkins, setCheckins] = useState([]); + const [connections, setConnections] = useState([]); + const [feedback, setFeedback] = useState([]); + const [eventFeedback, setEventFeedback] = useState([]); + const [leaderboard, setLeaderboard] = useState([]); + const [pointsLog, setPointsLog] = useState([]); + const [sessions, setSessions] = useState([]); + + const [tables, setTables] = useState>(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 = {}; + 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(); + 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 = {}; + 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 ; + if (!loaded) + return ( +
+ +
+ ); + + const selected = events.find((e) => e.id === selectedId); + + return ( +
+
+
+

Reports

+
Post-event summary + CSV / Excel / PDF export. Works for any event.
+
+ +
+ + {!selected ? ( +
+ +
+ ) : ( + <> + {/* On-screen summary */} +
+

πŸ“Š Summary β€” {selected.name}

+
+ {selected.start_date} – {selected.end_date} + {selected.location ? ` Β· ${selected.location}` : ''} +
+
+ + + + + +
+
+
+
Registrations by type
+
+ {Object.entries(byType).map(([t, n]) => ( + {t}: {n} + ))} +
+
+
+
Points by category
+
+ {Object.entries(pointsByCategory).map(([c, n]) => ( + {CATEGORY_LABEL[c] ?? c}: +{n} + ))} +
+
+
+
+ + {/* Session feedback summary */} +
+

⭐ Session feedback summary

+ {sessionSummary.length === 0 ? ( + + ) : ( +
+ + + + + + + + + + + {sessionSummary.map((s) => ( + + + + + + + ))} + +
SessionRoomAvg ratingResponses
{s.title}{s.room ?? 'β€”'} + + {s.avg != null ? `${s.avg.toFixed(1)}β˜…` : 'β€”'} + + {s.count}
+
+ )} +
+ + {/* Top leaderboard */} +
+

πŸ† Top points

+ {topLeaderboard.length === 0 ? ( + + ) : ( +
+ + + + + + + + + + {topLeaderboard.map((r, i) => ( + + + + + + ))} + +
#AttendeePoints
{i + 1}{nameOf(r.contact_email)} + ⚑ {r.points} +
+
+ )} +
+ + {/* Export */} +
+

πŸ“€ Export

+
+ + + +
+
+ Tables included in CSV / Excel: +
+
+ {TABLES.map((t) => ( + + ))} +
+
+ + )} +
+ ); +} + +function Stat({ label, value, sub }: { label: string; value: number; sub?: string }) { + return ( +
+
{value}
+
+ {label} + {sub ? ` Β· ${sub}` : ''} +
+
+ ); +} diff --git a/apps/admin/src/views/Schedule.tsx b/apps/admin/src/views/Schedule.tsx index be3bfcc..2a38ed8 100644 --- a/apps/admin/src/views/Schedule.tsx +++ b/apps/admin/src/views/Schedule.tsx @@ -193,7 +193,7 @@ export function Schedule() {
{s.title}
- {[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(' Β· ')}
{s.average_feedback != null && ⭐ {s.average_feedback.toFixed(1)}} @@ -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(currentSpeakers); const [material, setMaterial] = useState(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({