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

+152
View File
@@ -0,0 +1,152 @@
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { QRCodeSVG } from 'qrcode.react';
import { Html5Qrcode } from 'html5-qrcode';
const AV_COLORS = ['#d50000', '#20b2aa', '#e11d48', '#0d9488', '#f59e0b', '#0ea5e9', '#dc2626', '#7c3aed', '#16a34a', '#ea580c', '#0891b2', '#db2777'];
export function initials(name: string): string {
return name.split(' ').map((w) => w[0]).slice(0, 2).join('').toUpperCase();
}
export function avColor(seed: string): string {
let h = 0;
for (const c of seed) h = (h * 31 + c.charCodeAt(0)) >>> 0;
return AV_COLORS[h % AV_COLORS.length];
}
export function Avatar({ name, id, size = 44, fs = 15 }: { name: string; id: string; size?: number; fs?: number }) {
return (
<span className="avatar" style={{ width: size, height: size, fontSize: fs, background: avColor(id) }}>
{initials(name)}
</span>
);
}
export function Spinner() {
return <span className="spinner" />;
}
export function Empty({ icon, text }: { icon: string; text: string }) {
return (
<div className="empty">
<div className="big">{icon}</div>
{text}
</div>
);
}
/** Bottom-sheet modal. */
export function Sheet({ open, onClose, children }: { open: boolean; onClose: () => void; children: ReactNode }) {
if (!open) return null;
return (
<div className="backdrop" onClick={(e) => e.target === e.currentTarget && onClose()}>
<div className="sheet">
<div className="grab" />
{children}
</div>
</div>
);
}
/** Render a string (e.g. a QR token) as a scannable QR code. */
export function QrImage({ value, size = 180 }: { value: string; size?: number }) {
return (
<div className="qr-frame">
<QRCodeSVG value={value} size={size} level="M" marginSize={0} />
</div>
);
}
/**
* Camera QR scanner with a manual-entry fallback. Calls onResult with the
* decoded text. The camera only works on a secure context (https or localhost);
* the manual field always works.
*/
export function Scanner({ onResult, label = 'Scan a lanyard QR' }: { onResult: (text: string) => void; label?: string }) {
const [manual, setManual] = useState('');
const [camError, setCamError] = useState<string | null>(null);
const scannerRef = useRef<Html5Qrcode | null>(null);
const [camOn, setCamOn] = useState(false);
useEffect(() => {
let cancelled = false;
const el = document.getElementById('qr-reader');
if (!el) return;
// Camera requires a secure context + a real device. Fall back to manual
// entry (always available) when it's not usable.
const hasCamera =
typeof navigator !== 'undefined' &&
!!navigator.mediaDevices &&
typeof navigator.mediaDevices.getUserMedia === 'function';
if (!hasCamera) {
setCamError('Camera unavailable — type the code below');
return;
}
let scanner: Html5Qrcode | null = null;
try {
scanner = new Html5Qrcode('qr-reader');
scannerRef.current = scanner;
scanner
.start(
{ facingMode: 'environment' },
{ fps: 10, qrbox: { width: 220, height: 220 } },
(text) => {
if (cancelled) return;
setCamOn(false);
scanner?.stop().catch(() => {});
onResult(text);
},
() => {},
)
.then(() => {
if (!cancelled) setCamOn(true);
})
.catch((err) => {
if (!cancelled) setCamError(typeof err === 'string' ? err : 'Camera unavailable');
});
} catch {
if (!cancelled) setCamError('Camera unavailable — type the code below');
}
return () => {
cancelled = true;
try {
scanner?.stop().catch(() => {});
} catch {
/* ignore */
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<div className="viewfinder">
<span className="vf-corner tl" />
<span className="vf-corner tr" />
<span className="vf-corner bl" />
<span className="vf-corner br" />
<div id="qr-reader" style={{ position: 'absolute', inset: 0 }} />
{!camOn && !camError && <div className="vf-line" />}
{camError && (
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#cbb', fontSize: 13, padding: 20, textAlign: 'center' }}>
{label}
</div>
)}
</div>
<div className="row" style={{ gap: 8 }}>
<input
className="input mono"
placeholder="…or type the code (e.g. CVV-ANA-4821)"
value={manual}
onChange={(e) => setManual(e.target.value)}
/>
<button className="btn primary small" disabled={!manual.trim()} onClick={() => onResult(manual.trim())}>
Go
</button>
</div>
</div>
);
}