Phase 0 + 1: Dockerized Supabase core + attendee PWA

Phase 0 — Supabase core (Docker via CLI):
- Schema: profiles, slots, sessions, preferences, connections, checkins,
  feedback, leaderboard (Realtime mirror), points_log
- RLS on every table; transactional security-definer points RPCs
- Seed: 6 slots, 18 sessions, 13 demo users (QR token as auth password)

Phase 1 — Attendee web PWA (React + Vite + TS):
- Login via QR token + email (GoTrue, no email sent)
- Home, Agenda, Scan/Connect, staff Check-in, Feedback, live Leaderboard, Profile
- Same-origin proxy to Supabase (Vite dev / nginx in Docker)
- Docker: multi-stage build -> nginx sidecar on the Supabase network
This commit is contained in:
Lago committed 2026-08-22 16:10:59 +02:00
commit 37684ba116
45 files changed
+6922

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
import { supabase } from './supabase';
import type {
AgendaRow,
CheckinResult,
Connection,
Feedback,
FeedbackResult,
LeaderboardRow,
PointsLogRow,
Preference,
PublicProfile,
Session,
Slot,
} from './types';
export class ApiError extends Error {}
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);
return data as T;
}
/** Resolve a scanned lanyard QR token to a public profile (pre-login + connect). */
export async function lanyardLookup(qrToken: string): Promise<PublicProfile | null> {
const rows = await rpc<PublicProfile[]>('lanyard_lookup', { p_qr_token: qrToken });
return rows && rows.length > 0 ? rows[0] : null;
}
export async function getPublicProfiles(): Promise<PublicProfile[]> {
return rpc<PublicProfile[]>('get_public_profiles', {});
}
export async function getAgenda(): Promise<AgendaRow[]> {
return rpc<AgendaRow[]>('get_agenda', {});
}
/** Group the flat agenda rows into slots with their sessions. */
export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[] }[] {
const map = new Map<number, { slot: Slot; sessions: Session[] }>();
for (const r of rows) {
let entry = map.get(r.slot_id);
if (!entry) {
entry = {
slot: { id: r.slot_id, name: r.slot_name, slot_date: r.slot_date, start_time: r.start_time, end_time: r.end_time },
sessions: [],
};
map.set(r.slot_id, entry);
}
if (r.session_id && r.title) {
entry.sessions.push({
id: r.session_id,
title: r.title,
description: r.description,
slot_id: r.slot_id,
room: r.room,
capacity: r.capacity,
speakers: r.speakers,
});
}
}
return [...map.values()].sort((a, b) => a.slot.id - b.slot.id);
}
export async function getMyPreferences(): Promise<Preference[]> {
const { data, error } = await supabase.from('preferences').select('*').order('slot_id');
if (error) throw new ApiError(error.message);
return data as Preference[];
}
export async function setPreference(sessionId: string): Promise<void> {
await rpc('set_preference', { p_session_id: sessionId });
}
export async function clearPreference(slotId: number): Promise<void> {
await rpc('clear_preference', { p_slot_id: slotId });
}
export async function getMyConnections(): Promise<Connection[]> {
const { data, error } = await supabase.from('connections').select('*').order('created_at', { ascending: false });
if (error) throw new ApiError(error.message);
return data as Connection[];
}
export async function createConnectionRequest(targetQr: string): Promise<Connection> {
return rpc<Connection>('create_connection_request', { p_target_qr: targetQr });
}
export async function acceptConnection(id: string): Promise<Connection> {
return rpc<Connection>('accept_connection', { p_connection_id: id });
}
export async function rejectConnection(id: string): Promise<Connection> {
return rpc<Connection>('reject_connection', { p_connection_id: id });
}
export async function getMyCheckins(): Promise<string[]> {
const { data, error } = await supabase.from('checkins').select('session_id');
if (error) throw new ApiError(error.message);
return (data as { session_id: string }[]).map((c) => c.session_id);
}
export async function checkinAttendee(sessionId: string, attendeeQr: string): Promise<CheckinResult> {
const rows = await rpc<CheckinResult[]>('checkin_attendee', { p_session_id: sessionId, p_attendee_qr: attendeeQr });
return rows[0];
}
export async function getMyFeedback(): Promise<Feedback[]> {
const { data, error } = await supabase.from('feedback').select('*');
if (error) throw new ApiError(error.message);
return data as Feedback[];
}
export async function submitFeedback(sessionId: string, rating: number, comment: string): Promise<FeedbackResult> {
const rows = await rpc<FeedbackResult[]>('submit_feedback', { p_session_id: sessionId, p_rating: rating, p_comment: comment });
return rows[0];
}
export async function getLeaderboard(): Promise<LeaderboardRow[]> {
const { data, error } = await supabase.from('leaderboard').select('*').order('points', { ascending: false });
if (error) throw new ApiError(error.message);
return data as LeaderboardRow[];
}
export async function getMyPointsLog(): Promise<PointsLogRow[]> {
const { data, error } = await supabase.from('points_log').select('*').order('created_at', { ascending: false });
if (error) throw new ApiError(error.message);
return data as PointsLogRow[];
}