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.
This commit is contained in:
1 parent
08ab41898b
commit
3adc0fd58f
35 files changed
+3973
-54
No files matched your search
@@ -4,6 +4,7 @@ import type {
|
||||
Connection,
|
||||
Contact,
|
||||
Event,
|
||||
EventFeedback,
|
||||
ExcelSyncResult,
|
||||
Feedback,
|
||||
LeaderboardRow,
|
||||
@@ -23,6 +24,9 @@ import type {
|
||||
|
||||
export class ApiError extends Error {}
|
||||
|
||||
/** The default admin password for @appe.at contacts (set by the DB trigger). */
|
||||
export const DEFAULT_ADMIN_PASSWORD = 'appe-admin-2026';
|
||||
|
||||
async function rpc<T>(fn: string, args: Record<string, unknown>): Promise<T> {
|
||||
const { data, error } = await supabase.rpc(fn, args);
|
||||
if (error) throw new ApiError(error.message);
|
||||
@@ -61,6 +65,7 @@ export const getAllSessionSpeakers = () => all<SessionSpeaker>('session_speakers
|
||||
export const getAllConnections = () => all<Connection>('connections', { col: 'created_at', asc: false });
|
||||
export const getAllCheckins = () => all<Checkin>('checkins', { col: 'created_at', asc: false });
|
||||
export const getAllFeedback = () => all<Feedback>('feedback', { col: 'created_at', asc: false });
|
||||
export const getAllEventFeedback = () => all<EventFeedback>('event_feedback', { col: 'created_at', asc: false });
|
||||
export const getAllPointsLog = () => all<PointsLogRow>('points_log', { col: 'created_at', asc: false });
|
||||
export const getLeaderboard = () => all<LeaderboardRow>('leaderboard', { col: 'points', asc: false });
|
||||
|
||||
@@ -96,11 +101,34 @@ export async function deleteContact(email: string): Promise<void> {
|
||||
if (error) throw new ApiError(error.message);
|
||||
}
|
||||
|
||||
/** Delete many contacts at once (admin-only RLS). */
|
||||
/**
|
||||
* Delete many contacts at once (admin-only). Uses the `bulk_delete_contacts`
|
||||
* RPC, which bypasses the "a session must have at least one speaker" guard —
|
||||
* a direct PostgREST delete would fail (P0001) if the batch includes a contact
|
||||
* who is the sole speaker of a session.
|
||||
*/
|
||||
export async function deleteContacts(emails: string[]): Promise<void> {
|
||||
if (emails.length === 0) return;
|
||||
const { error } = await supabase.from('contacts').delete().in('email', emails);
|
||||
if (error) throw new ApiError(error.message);
|
||||
await rpc<number>('bulk_delete_contacts', { p_emails: emails });
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the current admin's own login password. Sets `contacts.password`
|
||||
* (the `trg_contact_password_sync` trigger re-hashes it into
|
||||
* `auth.users.encrypted_password`), then re-authenticates with the new
|
||||
* password so the session reflects the change.
|
||||
*/
|
||||
export async function changeMyPassword(email: string, newPassword: string): Promise<void> {
|
||||
const { error: updateError } = await supabase
|
||||
.from('contacts')
|
||||
.update({ password: newPassword })
|
||||
.eq('email', email);
|
||||
if (updateError) throw new ApiError(updateError.message);
|
||||
const { error: signInError } = await supabase.auth.signInWithPassword({
|
||||
email,
|
||||
password: newPassword,
|
||||
});
|
||||
if (signInError) throw new ApiError(signInError.message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,6 +199,7 @@ export async function upsertEvent(
|
||||
pretix_event_slug?: string | null;
|
||||
pretix_api_key?: string | null;
|
||||
use_realtime_clock?: boolean;
|
||||
talk_networking_bonus?: number;
|
||||
},
|
||||
): Promise<void> {
|
||||
if (id) {
|
||||
@@ -240,6 +269,34 @@ export async function importSessionizeExcel(eventId: string, file: File): Promis
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an event report from the sidecar (`POST /export`). Returns the
|
||||
* filename, mime type, and base64 content; the caller decodes and downloads.
|
||||
*/
|
||||
export const exportEventReport = (
|
||||
eventId: string,
|
||||
format: 'csv' | 'xlsx' | 'pdf',
|
||||
tables?: string[],
|
||||
) =>
|
||||
sidecarFetch<{ filename: string; mime: string; content_base64: string }>('/export', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ event_id: eventId, format, tables }),
|
||||
});
|
||||
|
||||
/** Decode a base64 report body and trigger a browser download. */
|
||||
export function downloadReport(res: { filename: string; mime: string; content_base64: string }): void {
|
||||
const bytes = Uint8Array.from(atob(res.content_base64), (c) => c.charCodeAt(0));
|
||||
const blob = new Blob([bytes], { type: res.mime });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = res.filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
}
|
||||
|
||||
/** Recent sync_runs rows for an event (newest first). */
|
||||
export const getSyncRuns = (eventId: string) =>
|
||||
all<SyncRun>('sync_runs', { col: 'started_at', asc: false }).then((rows) =>
|
||||
|
||||
@@ -43,6 +43,8 @@ export interface Event {
|
||||
pretix_api_key?: string | null;
|
||||
/** When the Sessionize sync last ran for this event. */
|
||||
last_synced_at: string | null;
|
||||
/** Bonus points each party earns for a connection when they shared a checked-in talk (0 = off). */
|
||||
talk_networking_bonus: number;
|
||||
avg_feedback: number | null;
|
||||
num_sessions: number;
|
||||
num_speakers: number;
|
||||
@@ -214,6 +216,20 @@ export interface Session {
|
||||
average_feedback: number | null;
|
||||
ai_generated_feedback: string | null;
|
||||
material_path: string | null;
|
||||
/** Free-text level classification (e.g. 100/200/300 or Beginner/Intermediate). */
|
||||
level: string | null;
|
||||
/** Free-text area/topic classification (e.g. Power Apps, Power Automate). */
|
||||
area: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
/** Event-level feedback (distinct from the per-session `feedback` table). */
|
||||
export interface EventFeedback {
|
||||
id: string;
|
||||
event_id: string;
|
||||
contact_email: string;
|
||||
rating: number;
|
||||
comment: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -266,7 +282,7 @@ export interface PointsLogRow {
|
||||
event_id: string;
|
||||
contact_email: string;
|
||||
delta: number;
|
||||
category: 'checkin' | 'connection' | 'feedback' | 'admin';
|
||||
category: 'checkin' | 'connection' | 'feedback' | 'admin' | 'talk_networking';
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user