Existing-sponsor link + remove Interfaces (Pretix/Sessionize)

- Sponsor lookup popup can now link an existing sponsor (dropdown + pre-fill)
  or create a new one; save upserts the sponsor linked to the contact and sets
  the registration type to sponsor.
- Remove the Interfaces feature end-to-end: admin nav button + Sync view, sync
  API helpers + SyncRun type, sync-trigger Edge Function, mock-api + its
  docker-compose service, and a migration dropping the sync RPCs, helpers, and
  sync_runs table.
- Update docs (architecture, backend, frontend, README, roadmap, next-steps).

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-24 09:11:25 +02:00
1 parent ffb270c140
commit 24909cf8ab
27 files changed
+147 -1150

No files matched your search

-69
View File
@@ -13,7 +13,6 @@ import type {
SessionSpeaker,
Slot,
Sponsor,
SyncRun,
} from './types';
export class ApiError extends Error {}
@@ -220,71 +219,3 @@ export async function evaluateSessionFeedback(sessionId: string): Promise<Sessio
// evaluate_session_feedback returns a single composite row (a JSON object, not an array).
return await rpc<Session>('evaluate_session_feedback', { p_session_id: sessionId });
}
// ---- Interfaces: Pretix + Sessionize sync (Phase 7 + 8) ---------------------
export interface SyncResult {
ok: boolean;
triggered_by: string;
results: {
pretix?: { created: number; updated: number; skipped: number; errors: string[] };
sessionize?: {
slots_created: number;
sessions_created: number;
sessions_updated: number;
speakers_linked: number;
errors: string[];
};
};
errors: string[];
}
/**
* Trigger a sync from the `sync-trigger` Edge Function. The admin's session
* JWT is passed as the Authorization header; the function verifies it is an
* admin (via the is_admin() RPC) before running.
*/
export async function triggerSync(source: 'pretix' | 'sessionize' | 'both'): Promise<SyncResult> {
const { data } = await supabase.auth.getSession();
const token = data.session?.access_token;
if (!token) throw new ApiError('not signed in');
const res = await fetch('/functions/v1/sync-trigger', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify({ source }),
});
const body = (await res.json()) as SyncResult & { error?: string };
if (!res.ok) throw new ApiError(body.error ?? `sync failed (${res.status})`);
return body;
}
/** Recent sync runs (audit trail), newest first. */
export const getSyncRuns = (limit = 10) =>
all<SyncRun>('sync_runs', { col: 'started_at', asc: false }).then((rows) => rows.slice(0, limit));
/**
* Build a CSV of lanyard QR codes for the active event's registrations
* (name, email, type, QR token) and trigger a browser download.
*/
export async function exportQrCsv(eventId: string): Promise<number> {
const regs = await getRegistrations(eventId);
const contacts = await getAllContacts();
const byEmail = new Map(contacts.map((c) => [c.email, c]));
const esc = (v: string | null | undefined) => `"${(v ?? '').replace(/"/g, '""')}"`;
const lines = ['name,email,type,qr_token'];
let count = 0;
for (const r of regs) {
const c = byEmail.get(r.contact_email);
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' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `lanyard-qr-codes-${eventId.slice(0, 8)}.csv`;
a.click();
URL.revokeObjectURL(url);
return count;
}
-12
View File
@@ -144,15 +144,3 @@ export interface ResetQrResult {
email: string;
qr_token: string;
}
export interface SyncRun {
id: string;
source: 'pretix' | 'sessionize';
started_at: string;
finished_at: string | null;
created: number;
updated: number;
skipped: number;
error: string | null;
triggered_by: string;
}