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

+13
View File
@@ -0,0 +1,13 @@
# Keep the Docker build context small and avoid leaking local state.
# NOTE: nginx.conf.template and docker-entrypoint.sh are COPYed by the
# Dockerfile, so they must NOT be excluded here.
node_modules
dist
.env
.env.*
!.env.example
*.tsbuildinfo
.git
.gitignore
Dockerfile
.dockerignore
+10
View File
@@ -0,0 +1,10 @@
# Supabase local stack.
#
# The app talks to Supabase through SAME-ORIGIN paths (/auth, /rest, /realtime,
# /storage). In dev the Vite server proxies them to the local Supabase stack;
# in Docker the app's nginx does the same. So no URL is needed here — the client
# falls back to window.location.origin. Only the anon key is required.
#
# VITE_SUPABASE_URL is intentionally left unset (same-origin).
# The value below is the standard local Supabase anon key (not a secret).
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
+35
View File
@@ -0,0 +1,35 @@
# Convivo attendee app — multi-stage build.
#
# Stage 1 (build): compile the Vite/React/TS app into static assets.
# Stage 2 (serve): nginx serves the static build and proxies the Supabase
# same-origin paths (/auth, /rest, /realtime, /storage) to the Supabase core.
#
# The Supabase core itself is NOT built here — it runs via the Supabase CLI
# (`supabase start`) or as a separate container. See the root docker-compose.yml.
# ---- Build stage -------------------------------------------------------------
FROM node:20-alpine AS build
WORKDIR /app
# Install deps first for better layer caching (reproducible via lock file).
COPY package.json package-lock.json ./
RUN npm ci
# Copy sources and build. The anon key is baked in at build time (it is not a
# secret — it is the standard local Supabase anon key). Override with
# --build-arg VITE_SUPABASE_ANON_KEY=... if you use a custom key.
ARG VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
COPY . .
RUN npm run build
# ---- Serve stage -------------------------------------------------------------
FROM nginx:1.27-alpine AS serve
# nginx template: serve the SPA + proxy Supabase paths to the core. The proxy
# target is injected at container start (see docker-entrypoint.sh).
COPY nginx.conf.template /etc/nginx/conf.d/default.conf.template
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 3000
ENTRYPOINT ["/docker-entrypoint.sh"]
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# Convivo app — container entrypoint.
#
# Injects the Supabase proxy target into the nginx config template, then starts
# nginx. The target defaults to the Kong container on the shared Supabase
# network (supabase_kong_Convivo:8000 — Kong's internal port; 54321 is the
# host-only mapping). Override with SUPABASE_PROXY_TARGET
# (e.g. host.docker.internal:54321) if the core is not on the shared network.
set -eu
TARGET="${SUPABASE_PROXY_TARGET:-supabase_kong_Convivo:8000}"
TEMPLATE=/etc/nginx/conf.d/default.conf.template
CONF=/etc/nginx/conf.d/default.conf
echo "[convivo] Proxying Supabase paths to: ${TARGET}"
sed "s|__SUPABASE_PROXY_TARGET__|${TARGET}|g" "${TEMPLATE}" > "${CONF}"
# Run nginx in the foreground.
exec nginx -g "daemon off;"
+19
View File
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="theme-color" content="#d50000" />
<meta name="description" content="Convivo — turn a conference into a game. Scan, connect, climb the leaderboard." />
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800;900&display=swap" rel="stylesheet" />
<title>Convivo</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+77
View File
@@ -0,0 +1,77 @@
# Convivo app — nginx server block (template).
#
# Serves the built SPA and proxies the Supabase same-origin paths
# (/auth, /rest, /realtime, /storage) to the Supabase core.
#
# The proxy target is injected at container start by /docker-entrypoint.sh
# from the SUPABASE_PROXY_TARGET env var (default: supabase_kong_Convivo:8000,
# i.e. the Kong container on the shared Supabase network — Kong's internal port).
#
# The placeholder __SUPABASE_PROXY_TARGET__ is replaced before nginx starts.
server {
listen 3000;
server_name _;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_types text/plain text/css application/json application/javascript image/svg+xml;
# SPA fallback: any non-file, non-proxied route serves index.html so the
# client-side router can take over.
location / {
try_files $uri $uri/ /index.html;
}
# Long-cache immutable build assets.
location /assets/ {
expires 30d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# ---- Supabase same-origin proxy -------------------------------------
# No trailing slash on proxy_pass => the original URI is passed through
# unchanged (e.g. /auth/v1/token -> http://<target>/auth/v1/token).
location /auth/ {
proxy_pass http://__SUPABASE_PROXY_TARGET__;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /rest/ {
proxy_pass http://__SUPABASE_PROXY_TARGET__;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Realtime uses WebSockets — enable the upgrade handshake.
location /realtime/ {
proxy_pass http://__SUPABASE_PROXY_TARGET__;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
location /storage/ {
proxy_pass http://__SUPABASE_PROXY_TARGET__;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 50M;
}
}
+1917
View File
File diff suppressed because it is too large. Load diff
+25
View File
@@ -0,0 +1,25 @@
{
"name": "@convivo/app",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
},
"dependencies": {
"@supabase/supabase-js": "^2.45.4",
"html5-qrcode": "^2.3.8",
"qrcode.react": "^4.0.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"typescript": "^5.5.4",
"vite": "^5.4.8"
}
}
+10
View File
@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#d50000"/>
<stop offset="1" stop-color="#ff5a4e"/>
</linearGradient>
</defs>
<rect width="100" height="100" rx="24" fill="url(#g)"/>
<text x="50" y="68" font-family="Poppins, Arial, sans-serif" font-size="52" font-weight="900" fill="#fff" text-anchor="middle">C</text>
</svg>

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

+13
View File
@@ -0,0 +1,13 @@
{
"name": "Convivo",
"short_name": "Convivo",
"description": "Turn a conference into a game. Scan, connect, climb the leaderboard.",
"start_url": "/",
"display": "standalone",
"background_color": "#f0f2f6",
"theme_color": "#d50000",
"icons": [
{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}
+94
View File
@@ -0,0 +1,94 @@
import { useState } from 'react';
import { AuthProvider, useAuth } from './context/AuthContext';
import { ToastProvider } from './context/ToastContext';
import { Login } from './screens/Login';
import { Home } from './screens/Home';
import { Agenda } from './screens/Agenda';
import { Scan } from './screens/Scan';
import { Connections } from './screens/Connections';
import { Leaderboard } from './screens/Leaderboard';
import { Profile } from './screens/Profile';
import { Feedback } from './screens/Feedback';
import { Spinner } from './components/ui';
type Tab = 'home' | 'agenda' | 'scan' | 'connections' | 'profile' | 'leaderboard';
const TABS: { id: Tab; ico: string; label: string }[] = [
{ id: 'home', ico: '🏠', label: 'Home' },
{ id: 'agenda', ico: '📅', label: 'Agenda' },
{ id: 'scan', ico: '📷', label: 'Scan' },
{ id: 'connections', ico: '🤝', label: 'Connect' },
{ id: 'profile', ico: '👤', label: 'Profile' },
];
function Shell() {
const { session, profile, loading } = useAuth();
const [tab, setTab] = useState<Tab>('home');
const [feedbackSession, setFeedbackSession] = useState<string | null>(null);
if (loading) {
return (
<div className="app">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</div>
);
}
if (!session || !profile) {
return (
<div className="app">
<Login />
</div>
);
}
// Feedback is a full-screen takeover (no tab bar).
if (feedbackSession) {
return (
<div className="app">
<Feedback sessionId={feedbackSession} onDone={() => { setFeedbackSession(null); setTab('home'); }} />
</div>
);
}
const scanLabel = profile.role === 'staff' || profile.role === 'admin' ? 'Check-in' : 'Scan';
return (
<div className="app">
{tab === 'home' && <Home go={(t) => setTab(t as Tab)} />}
{tab === 'agenda' && <Agenda openFeedback={(id) => setFeedbackSession(id)} />}
{tab === 'scan' && <Scan />}
{tab === 'connections' && <Connections />}
{tab === 'profile' && <Profile />}
{tab === 'leaderboard' && <Leaderboard />}
<nav className="tabbar">
{TABS.map((t) => (
<button
key={t.id}
className={`tab ${t.id === 'scan' ? 'tab-scan' : ''} ${tab === t.id ? 'active' : ''}`}
onClick={() => setTab(t.id)}
>
{t.id === 'scan' ? (
<span className="scan-btn">📷</span>
) : (
<span className="ico">{t.ico}</span>
)}
<span>{t.id === 'scan' ? scanLabel : t.label}</span>
</button>
))}
</nav>
</div>
);
}
export default function App() {
return (
<ToastProvider>
<AuthProvider>
<Shell />
</AuthProvider>
</ToastProvider>
);
}
+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>
);
}
+71
View File
@@ -0,0 +1,71 @@
import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react';
import type { Session as SbSession, User } from '@supabase/supabase-js';
import { supabase } from '../lib/supabase';
import type { Profile } from '../lib/types';
interface AuthContextValue {
session: SbSession | null;
user: User | null;
profile: Profile | null;
loading: boolean;
refreshProfile: () => Promise<void>;
signOut: () => Promise<void>;
}
const AuthContext = createContext<AuthContextValue | null>(null);
export function AuthProvider({ children }: { children: ReactNode }) {
const [session, setSession] = useState<SbSession | null>(null);
const [profile, setProfile] = useState<Profile | null>(null);
const [loading, setLoading] = useState(true);
const loadProfile = useCallback(async (userId: string) => {
const { data, error } = await supabase.from('profiles').select('*').eq('id', userId).maybeSingle();
if (error) {
console.error('Failed to load profile', error);
return;
}
setProfile((data as Profile) ?? null);
}, []);
useEffect(() => {
let active = true;
supabase.auth.getSession().then(({ data }) => {
if (!active) return;
setSession(data.session);
if (data.session?.user) void loadProfile(data.session.user.id);
setLoading(false);
});
const { data: sub } = supabase.auth.onAuthStateChange((_event, newSession) => {
setSession(newSession);
if (newSession?.user) void loadProfile(newSession.user.id);
else setProfile(null);
});
return () => {
active = false;
sub.subscription.unsubscribe();
};
}, [loadProfile]);
const refreshProfile = useCallback(async () => {
if (session?.user) await loadProfile(session.user.id);
}, [session, loadProfile]);
const signOut = useCallback(async () => {
await supabase.auth.signOut();
setProfile(null);
}, []);
const value = useMemo<AuthContextValue>(
() => ({ session, user: session?.user ?? null, profile, loading, refreshProfile, signOut }),
[session, profile, loading, refreshProfile, signOut],
);
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
}
export function useAuth(): AuthContextValue {
const ctx = useContext(AuthContext);
if (!ctx) throw new Error('useAuth must be used within AuthProvider');
return ctx;
}
+36
View File
@@ -0,0 +1,36 @@
import { createContext, useCallback, useContext, useRef, useState, type ReactNode } from 'react';
type ToastType = '' | 'ok' | 'err';
interface ToastContextValue {
toast: (msg: string, type?: ToastType) => void;
}
const ToastContext = createContext<ToastContextValue | null>(null);
export function ToastProvider({ children }: { children: ReactNode }) {
const [msg, setMsg] = useState('');
const [type, setType] = useState<ToastType>('');
const [show, setShow] = useState(false);
const timer = useRef<number | undefined>(undefined);
const toast = useCallback((text: string, t: ToastType = '') => {
setMsg(text);
setType(t);
setShow(true);
window.clearTimeout(timer.current);
timer.current = window.setTimeout(() => setShow(false), 2600);
}, []);
return (
<ToastContext.Provider value={{ toast }}>
{children}
<div className={`toast ${show ? 'show' : ''} ${type}`}>{msg}</div>
</ToastContext.Provider>
);
}
export function useToast(): ToastContextValue {
const ctx = useContext(ToastContext);
if (!ctx) throw new Error('useToast must be used within ToastProvider');
return ctx;
}
+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[];
}
+23
View File
@@ -0,0 +1,23 @@
import { createClient } from '@supabase/supabase-js';
// The app talks to Supabase through same-origin paths (/auth, /rest, /realtime,
// /storage). In dev the Vite server proxies them to the local Supabase stack;
// in Docker the app's nginx does the same. This avoids CORS entirely.
const url = import.meta.env.VITE_SUPABASE_URL || window.location.origin;
const anonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
if (!anonKey) {
// Fail fast with a clear message if the anon key is missing.
console.warn('[convivo] VITE_SUPABASE_ANON_KEY is not set.');
}
export const supabase = createClient(url, anonKey, {
auth: {
persistSession: true,
autoRefreshToken: true,
detectSessionInUrl: false,
},
realtime: {
params: { eventsPerSecond: 10 },
},
});
+43
View File
@@ -0,0 +1,43 @@
import type { Slot } from './types';
/** The event day (from the seed). All slot times are on this date. */
export const EVENT_DATE = '2026-10-23';
/** Simulated "now" used for the demo (matches the mockup: 10:20 on event day). */
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
export type SlotStatus = 'done' | 'now' | 'next';
function at(dateStr: string, time: string): Date {
return new Date(`${dateStr}T${time}`);
}
export function slotStart(slot: Slot): Date {
return at(slot.slot_date, slot.start_time);
}
export function slotEnd(slot: Slot): Date {
return at(slot.slot_date, slot.end_time);
}
export function slotStatus(slot: Slot, now: Date): SlotStatus {
if (now >= slotEnd(slot)) return 'done';
if (now >= slotStart(slot)) return 'now';
return 'next';
}
/** "09:00" from "09:00:00". */
export function fmtTime(time: string): string {
return time.slice(0, 5);
}
export function fmtRange(slot: Slot): string {
return `${fmtTime(slot.start_time)}–${fmtTime(slot.end_time)}`;
}
export function greeting(now: Date): string {
const h = now.getHours();
if (h < 12) return 'Good morning';
if (h < 18) return 'Good afternoon';
return 'Good evening';
}
+119
View File
@@ -0,0 +1,119 @@
export type Role = 'attendee' | 'staff' | 'admin';
export interface Profile {
id: string;
email: string;
full_name: string;
company: string | null;
role: Role;
qr_token: string | null;
points: number;
created_at: string;
}
/** Public projection of a profile (no email / qr_token). */
export interface PublicProfile {
id: string;
full_name: string;
company: string | null;
role: Role;
points: number;
}
export interface Slot {
id: number;
name: string;
slot_date: string;
start_time: string;
end_time: string;
}
export interface Session {
id: string;
title: string;
description: string | null;
slot_id: number;
room: string | null;
capacity: number | null;
speakers: string | null;
}
/** Row shape returned by the get_agenda() RPC (slots with nested sessions). */
export interface AgendaRow {
slot_id: number;
slot_name: string;
slot_date: string;
start_time: string;
end_time: string;
session_id: string | null;
title: string | null;
description: string | null;
room: string | null;
capacity: number | null;
speakers: string | null;
}
export interface Preference {
id: string;
profile_id: string;
session_id: string;
slot_id: number;
}
export type ConnectionStatus = 'pending' | 'accepted' | 'rejected';
export interface Connection {
id: string;
from_id: string;
to_id: string;
status: ConnectionStatus;
created_at: string;
resolved_at: string | null;
}
export interface Checkin {
id: string;
profile_id: string;
session_id: string;
staff_id: string;
created_at: string;
}
export interface Feedback {
id: string;
profile_id: string;
session_id: string;
rating: number;
comment: string | null;
created_at: string;
}
export interface LeaderboardRow {
profile_id: string;
full_name: string;
company: string | null;
points: number;
updated_at: string;
}
export interface PointsLogRow {
id: string;
profile_id: string;
delta: number;
category: 'checkin' | 'connection' | 'feedback' | 'admin';
created_at: string;
}
export interface CheckinResult {
checkin_id: string;
attendee_id: string;
attendee_name: string;
points: number;
already: boolean;
}
export interface FeedbackResult {
feedback_id: string;
points: number;
earned: number;
}
+47
View File
@@ -0,0 +1,47 @@
import { useEffect, useState } from 'react';
import { getAgenda, groupAgenda } from './api';
import { DEFAULT_NOW } from './time';
import type { Session, Slot } from './types';
export interface EventData {
slots: { slot: Slot; sessions: Session[] }[];
sessionById: Map<string, Session>;
slotById: Map<number, Slot>;
now: Date;
loading: boolean;
error: string | null;
}
/** Loads the agenda once and exposes it grouped by slot, plus the event clock. */
export function useEvent(): EventData {
const [slots, setSlots] = useState<{ slot: Slot; sessions: Session[] }[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
let active = true;
(async () => {
try {
const rows = await getAgenda();
if (!active) return;
setSlots(groupAgenda(rows));
} catch (e) {
if (active) setError(e instanceof Error ? e.message : 'Failed to load agenda');
} finally {
if (active) setLoading(false);
}
})();
return () => {
active = false;
};
}, []);
const sessionById = new Map<string, Session>();
const slotById = new Map<number, Slot>();
for (const { slot, sessions } of slots) {
slotById.set(slot.id, slot);
for (const s of sessions) sessionById.set(s.id, s);
}
return { slots, sessionById, slotById, now: DEFAULT_NOW, loading, error };
}
+10
View File
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './styles.css';
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
);
+159
View File
@@ -0,0 +1,159 @@
import { useEffect, useState } from 'react';
import { useEvent } from '../lib/useEvent';
import { clearPreference, getMyCheckins, getMyPreferences, setPreference } from '../lib/api';
import { fmtRange, slotStatus } from '../lib/time';
import type { Preference, Session } from '../lib/types';
import { Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) => void }) {
const { slots, now, loading } = useEvent();
const [prefs, setPrefs] = useState<Preference[]>([]);
const [checkins, setCheckins] = useState<string[]>([]);
const [selected, setSelected] = useState<Session | null>(null);
const { toast } = useToast();
useEffect(() => {
let active = true;
(async () => {
try {
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins()]);
if (!active) return;
setPrefs(p);
setCheckins(c);
} catch {
/* non-fatal */
}
})();
return () => {
active = false;
};
}, []);
if (loading) {
return (
<section className="screen">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
const pickFor = (slotId: number) => prefs.find((p) => p.slot_id === slotId)?.session_id;
async function togglePick(slotId: number, sessionId: string) {
const current = pickFor(slotId);
try {
if (current === sessionId) {
await clearPreference(slotId);
toast('Pick removed');
} else {
await setPreference(sessionId);
toast('Pick saved ✓', 'ok');
}
const p = await getMyPreferences();
setPrefs(p);
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not update pick', 'err');
}
}
const selSlot = selected ? slots.find((s) => s.slot.id === selected.slot_id)?.slot : undefined;
const selStatus = selSlot ? slotStatus(selSlot, now) : 'next';
const selCheckedIn = selected ? checkins.includes(selected.id) : false;
return (
<section className="screen">
<div className="row between">
<div>
<div className="h1">Agenda</div>
<div className="muted small">Wed 23 Oct · 09:00–17:00</div>
</div>
<span className="pill violet">6 slots · 3 tracks</span>
</div>
<div className="muted small" style={{ marginTop: -4 }}>
Pick <b>one session per slot</b> — you can change until the slot starts.
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{slots.map(({ slot, sessions }) => {
const status = slotStatus(slot, now);
return (
<div className="slot-card" key={slot.id}>
<div className="slot-head">
<div className="grow">
<div className="name">{slot.name}</div>
<div className="time">{fmtRange(slot)}</div>
</div>
{status === 'done' && <span className="pill">Done</span>}
{status === 'now' && <span className="pill violet">● Live</span>}
{status === 'next' && <span className="pill cyan">Up next</span>}
</div>
{sessions.map((s) => {
const picked = pickFor(slot.id) === s.id;
return (
<button
key={s.id}
className={`sess ${picked ? 'picked' : ''}`}
onClick={() => setSelected(s)}
>
<div className="grow">
<div className="title">{s.title}</div>
<div className="meta">
{s.room} · {s.speakers}
</div>
</div>
<span className="check">✓</span>
</button>
);
})}
</div>
);
})}
</div>
<Sheet open={!!selected} onClose={() => setSelected(null)}>
{selected && selSlot && (
<>
<div className="row between">
<div>
<h3>{selected.title}</h3>
<div className="sub">
{selSlot.name} · {fmtRange(selSlot)} · {selected.room}
</div>
</div>
<button className="btn ghost small" onClick={() => setSelected(null)}>✕</button>
</div>
<div className="muted small" id="sd-desc" style={{ margin: '12px 0', lineHeight: 1.55 }}>
{selected.description}
</div>
<div className="row" style={{ gap: 8, marginBottom: 14 }}>
<span className="pill">🎤 {selected.speakers}</span>
{selected.capacity && <span className="pill">👥 {selected.capacity}</span>}
{selCheckedIn && <span className="pill green">✓ Checked in</span>}
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{selStatus === 'done' && selCheckedIn && (
<button className="btn primary" onClick={() => openFeedback(selected.id)}>
Give feedback ⭐
</button>
)}
{selStatus === 'done' && !selCheckedIn && (
<div className="muted small" style={{ textAlign: 'center' }}>
You weren’t checked in to this session.
</div>
)}
<button
className={`btn ${pickFor(selected.slot_id) === selected.id ? 'danger' : 'primary'}`}
onClick={() => togglePick(selected.slot_id, selected.id)}
>
{pickFor(selected.slot_id) === selected.id ? 'Remove my pick' : 'Pick this session'}
</button>
</div>
</>
)}
</Sheet>
</section>
);
}
+131
View File
@@ -0,0 +1,131 @@
import { useCallback, useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { acceptConnection, getMyConnections, getPublicProfiles, rejectConnection } from '../lib/api';
import type { Connection, PublicProfile } from '../lib/types';
import { Avatar, Empty, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
export function Connections() {
const { profile } = useAuth();
const [tab, setTab] = useState<'mine' | 'req'>('mine');
const [conns, setConns] = useState<Connection[]>([]);
const [people, setPeople] = useState<Map<string, PublicProfile>>(new Map());
const [loading, setLoading] = useState(true);
const { toast } = useToast();
const load = useCallback(async () => {
try {
const [c, p] = await Promise.all([getMyConnections(), getPublicProfiles()]);
setConns(c);
setPeople(new Map(p.map((x) => [x.id, x])));
} catch {
/* non-fatal */
} finally {
setLoading(false);
}
}, []);
useEffect(() => {
void load();
}, [load]);
if (!profile) return null;
const me = profile.id;
const nameOf = (id: string) => people.get(id)?.full_name ?? '…';
const companyOf = (id: string) => people.get(id)?.company ?? '';
const accepted = conns.filter((c) => c.status === 'accepted');
const incoming = conns.filter((c) => c.status === 'pending' && c.to_id === me);
const outgoing = conns.filter((c) => c.status === 'pending' && c.from_id === me);
async function resolve(id: string, accept: boolean) {
try {
if (accept) await acceptConnection(id);
else await rejectConnection(id);
toast(accept ? 'Connected! +5 pts 🤝' : 'Request declined', accept ? 'ok' : '');
await load();
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not update request', 'err');
}
}
if (loading) {
return (
<section className="screen">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
return (
<section className="screen">
<div className="h1">Connections</div>
<div className="seg">
<button className={tab === 'mine' ? 'active' : ''} onClick={() => setTab('mine')}>My connections</button>
<button className={tab === 'req' ? 'active' : ''} onClick={() => setTab('req')}>
Requests {incoming.length + outgoing.length > 0 && <span className="pill violet" style={{ marginLeft: 4 }}>{incoming.length + outgoing.length}</span>}
</button>
</div>
{tab === 'mine' &&
(accepted.length === 0 ? (
<Empty icon="🤝" text="No connections yet. Scan a peer’s lanyard to start one." />
) : (
accepted.map((c) => {
const otherId = c.from_id === me ? c.to_id : c.from_id;
return (
<div className="conn" key={c.id}>
<Avatar name={nameOf(otherId)} id={otherId} size={44} />
<div className="grow">
<div className="name">{nameOf(otherId)}</div>
<div className="meta">{companyOf(otherId)}</div>
</div>
<span className="pill green">Connected</span>
</div>
);
})
))}
{tab === 'req' && (
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
{incoming.length === 0 && outgoing.length === 0 && (
<Empty icon="📭" text="No pending requests." />
)}
{incoming.length > 0 && (
<div>
<div className="muted small" style={{ marginBottom: 8, fontWeight: 700 }}>Incoming</div>
{incoming.map((c) => (
<div className="conn" key={c.id}>
<Avatar name={nameOf(c.from_id)} id={c.from_id} size={44} />
<div className="grow">
<div className="name">{nameOf(c.from_id)}</div>
<div className="meta">{companyOf(c.from_id)}</div>
</div>
<button className="btn primary small" onClick={() => resolve(c.id, true)}>Accept</button>
<button className="btn small" onClick={() => resolve(c.id, false)}>Decline</button>
</div>
))}
</div>
)}
{outgoing.length > 0 && (
<div>
<div className="muted small" style={{ marginBottom: 8, fontWeight: 700 }}>Sent</div>
{outgoing.map((c) => (
<div className="conn" key={c.id}>
<Avatar name={nameOf(c.to_id)} id={c.to_id} size={44} />
<div className="grow">
<div className="name">{nameOf(c.to_id)}</div>
<div className="meta">{companyOf(c.to_id)}</div>
</div>
<span className="pill amber">Pending</span>
</div>
))}
</div>
)}
</div>
)}
</section>
);
}
+105
View File
@@ -0,0 +1,105 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { getMyFeedback, submitFeedback } from '../lib/api';
import { fmtRange } from '../lib/time';
import { Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
export function Feedback({ sessionId, onDone }: { sessionId: string; onDone: () => void }) {
const { refreshProfile } = useAuth();
const { sessionById, slotById, loading } = useEvent();
const [rating, setRating] = useState(0);
const [comment, setComment] = useState('');
const [existing, setExisting] = useState<{ rating: number; comment: string | null } | null>(null);
const [busy, setBusy] = useState(false);
const [done, setDone] = useState<{ earned: number } | null>(null);
const { toast } = useToast();
const session = sessionById.get(sessionId);
const slot = session ? slotById.get(session.slot_id) : undefined;
useEffect(() => {
let active = true;
(async () => {
try {
const fb = await getMyFeedback();
const mine = fb.find((f) => f.session_id === sessionId);
if (active && mine) setExisting({ rating: mine.rating, comment: mine.comment });
} catch {
/* non-fatal */
}
})();
return () => {
active = false;
};
}, [sessionId]);
if (loading || !session || !slot) {
return (
<section className="screen no-tab">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
async function submit() {
if (rating < 1) return;
setBusy(true);
try {
const res = await submitFeedback(sessionId, rating, comment.trim());
await refreshProfile();
setDone({ earned: res.earned });
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not submit feedback', 'err');
} finally {
setBusy(false);
}
}
if (done) {
return (
<section className="screen no-tab">
<div className="card success-box">
<div className="emoji">🎉</div>
<h3>{done.earned > 0 ? `+${done.earned} pts earned!` : 'Feedback updated!'}</h3>
<p>Thanks for the feedback — it helps everyone pick better sessions.</p>
<button className="btn primary" style={{ marginTop: 20 }} onClick={onDone}>Back to Home</button>
</div>
</section>
);
}
return (
<section className="screen no-tab">
<button className="btn ghost small" style={{ alignSelf: 'flex-start' }} onClick={onDone}>← Back</button>
<div className="card" style={{ textAlign: 'center' }}>
<div className="muted small">{slot.name} · {fmtRange(slot)} · {session.room}</div>
<div className="h2" style={{ marginTop: 4 }}>{session.title}</div>
<div className="h1" style={{ marginTop: 18, fontSize: 22 }}>How was it? ⭐</div>
<div className="stars">
{[1, 2, 3, 4, 5].map((n) => (
<button key={n} className={`star ${rating >= n ? 'on' : ''}`} onClick={() => setRating(n)}>★</button>
))}
</div>
<div className="muted small" style={{ marginBottom: 10 }}>
{rating > 0 ? `${rating} star${rating > 1 ? 's' : ''}` : 'Tap a star'}
</div>
<textarea
className="input"
placeholder="What did you think? (bonus points for details)"
value={comment}
onChange={(e) => setComment(e.target.value)}
/>
<div className="muted small" style={{ marginTop: 10, textAlign: 'center' }}>
Rating: <b>+5 pts</b> · With comments: <b>+10 pts</b>
</div>
</div>
<button className="btn primary" disabled={busy || rating < 1} onClick={submit}>
{busy ? 'Submitting…' : existing ? 'Update feedback' : 'Submit feedback'}
</button>
</section>
);
}
+138
View File
@@ -0,0 +1,138 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { getMyCheckins, getMyPreferences } from '../lib/api';
import { fmtRange, greeting, slotStatus } from '../lib/time';
import type { Preference } from '../lib/types';
import { Avatar, Spinner } from '../components/ui';
export function Home({ go }: { go: (tab: string) => void }) {
const { profile } = useAuth();
const { slots, sessionById, now, loading } = useEvent();
const [prefs, setPrefs] = useState<Preference[]>([]);
const [checkins, setCheckins] = useState<string[]>([]);
useEffect(() => {
let active = true;
(async () => {
try {
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins()]);
if (!active) return;
setPrefs(p);
setCheckins(c);
} catch {
/* non-fatal */
}
})();
return () => {
active = false;
};
}, []);
if (loading || !profile) {
return (
<section className="screen">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
const pickFor = (slotId: number) => prefs.find((p) => p.slot_id === slotId)?.session_id;
const current = slots.find(({ slot }) => slotStatus(slot, now) === 'now');
const next = slots.find(({ slot }) => slotStatus(slot, now) === 'next');
const nowSession = current ? sessionById.get(pickFor(current.slot.id) ?? '') : undefined;
const nextSession = next ? sessionById.get(pickFor(next.slot.id) ?? '') : undefined;
const firstName = profile.full_name.split(' ')[0];
return (
<section className="screen">
<div className="row between">
<div>
<div className="h1">{greeting(now)}, {firstName} 👋</div>
<div className="muted small">Wed 23 Oct · Convivo Conf</div>
</div>
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {profile.points}</div>
</div>
{nowSession && current && (
<div className="card now-card">
<div className="row between">
<span className="pill violet">● Now</span>
<span className="muted small">{fmtRange(current.slot)}</span>
</div>
<div className="h2" style={{ marginTop: 10 }}>{nowSession.title}</div>
<div className="muted small" style={{ marginTop: 3 }}>
{nowSession.room} · {nowSession.speakers}
</div>
{checkins.includes(nowSession.id) ? (
<span className="pill green" style={{ marginTop: 10 }}>✓ Checked in</span>
) : (
<span className="pill amber" style={{ marginTop: 10 }}>Show your QR to staff to check in</span>
)}
</div>
)}
{nextSession && next && (
<div className="card">
<div className="row between">
<span className="pill cyan">Next</span>
<span className="muted small">{fmtRange(next.slot)}</span>
</div>
<div className="h2" style={{ marginTop: 10 }}>{nextSession.title}</div>
<div className="muted small" style={{ marginTop: 3 }}>
{nextSession.room} · {nextSession.speakers}
</div>
</div>
)}
<div>
<div className="row between" style={{ marginBottom: 9 }}>
<span className="h2">My picks today</span>
<span className="muted small">tap to change</span>
</div>
<div style={{ display: 'flex', flexDirection: 'column' }}>
{slots.map(({ slot }) => {
const sid = pickFor(slot.id);
const s = sid ? sessionById.get(sid) : undefined;
return (
<button key={slot.id} className="pick-chip" onClick={() => go('agenda')}>
<span className="t">{fmtRange(slot)}</span>
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
{s ? s.title : 'No pick yet'}
</span>
{s && <span className="muted small">{s.room}</span>}
</button>
);
})}
</div>
</div>
<div className="qa-grid">
<div className="qa" onClick={() => go('scan')}>
<span className="ico">📷</span>
<span className="lbl">{profile.role === 'staff' ? 'Check-in' : 'Scan & connect'}</span>
</div>
<div className="qa" onClick={() => go('agenda')}>
<span className="ico">📅</span>
<span className="lbl">Agenda</span>
</div>
<div className="qa" onClick={() => go('connections')}>
<span className="ico">🤝</span>
<span className="lbl">Connections</span>
</div>
<div className="qa" onClick={() => go('leaderboard')}>
<span className="ico">🏆</span>
<span className="lbl">Leaderboard</span>
</div>
</div>
<div style={{ height: 8 }} />
<div className="muted small" style={{ textAlign: 'center', opacity: 0.5 }}>
<Avatar name={profile.full_name} id={profile.id} size={22} fs={9} /> {profile.company ?? ''}
</div>
</section>
);
}
+108
View File
@@ -0,0 +1,108 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { supabase } from '../lib/supabase';
import { getLeaderboard } from '../lib/api';
import type { LeaderboardRow } from '../lib/types';
import { Avatar, Spinner } from '../components/ui';
export function Leaderboard() {
const { profile } = useAuth();
const [rows, setRows] = useState<LeaderboardRow[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
let active = true;
(async () => {
try {
const data = await getLeaderboard();
if (active) setRows(data);
} catch {
/* non-fatal */
} finally {
if (active) setLoading(false);
}
})();
// Live updates: re-fetch on any leaderboard change (points are synced
// transactionally by the RPCs, so the table is always consistent).
const channel = supabase
.channel('leaderboard-live')
.on('postgres_changes', { event: '*', schema: 'public', table: 'leaderboard' }, () => {
getLeaderboard().then((d) => active && setRows(d)).catch(() => {});
})
.subscribe();
return () => {
active = false;
supabase.removeChannel(channel);
};
}, []);
if (loading) {
return (
<section className="screen">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
const me = profile?.id;
const top3 = rows.slice(0, 3);
const rest = rows.slice(3);
const myRank = rows.findIndex((r) => r.profile_id === me) + 1;
return (
<section className="screen">
<div className="row between">
<div>
<div className="h1">Leaderboard</div>
<div className="muted small">All attendees · by points</div>
</div>
<span className="pill green">● Live</span>
</div>
{top3.length > 0 && (
<div className="podium">
{[1, 0, 2].map((idx) => {
const r = top3[idx];
if (!r) return <div key={idx} style={{ width: 96 }} />;
const cls = idx === 0 ? 'b1' : idx === 1 ? 'b2' : 'b3';
return (
<div className="pod" key={r.profile_id}>
<div className={`bar ${cls}`}>{r.points}</div>
<div className="pname">{r.full_name.split(' ')[0]}</div>
<div className="ppoints">#{idx + 1}</div>
</div>
);
})}
</div>
)}
<div style={{ display: 'flex', flexDirection: 'column' }}>
{rest.map((r, i) => {
const rank = i + 4;
const isMe = r.profile_id === me;
return (
<div className={`lb-row ${isMe ? 'me' : ''}`} key={r.profile_id}>
<span className="rank">{rank}</span>
<Avatar name={r.full_name} id={r.profile_id} size={38} fs={13} />
<div className="grow">
<div style={{ fontWeight: 700, fontSize: 14 }}>{r.full_name} {isMe && <span className="muted small">(you)</span>}</div>
<div className="muted small">{r.company ?? ''}</div>
</div>
<span className="pts">{r.points}</span>
</div>
);
})}
</div>
{myRank > 0 && (
<div className="muted small" style={{ textAlign: 'center', marginTop: 6 }}>
You’re ranked <b>#{myRank}</b> of {rows.length}
</div>
)}
</section>
);
}
+120
View File
@@ -0,0 +1,120 @@
import { useState } from 'react';
import { supabase } from '../lib/supabase';
import { lanyardLookup } from '../lib/api';
import type { PublicProfile } from '../lib/types';
import { Avatar, Scanner } from '../components/ui';
import { useToast } from '../context/ToastContext';
type Step = 'splash' | 'scan' | 'confirm';
export function Login() {
const [step, setStep] = useState<Step>('splash');
const [qrToken, setQrToken] = useState('');
const [found, setFound] = useState<PublicProfile | null>(null);
const [email, setEmail] = useState('');
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const { toast } = useToast();
async function handleScan(text: string) {
const token = text.trim();
if (!token) return;
setQrToken(token);
setError(null);
try {
const profile = await lanyardLookup(token);
setFound(profile);
if (!profile) toast('No attendee found for that code', 'err');
} catch {
setFound(null);
}
setStep('confirm');
}
async function confirm() {
if (!email.trim() || !qrToken) return;
setBusy(true);
setError(null);
try {
const { data, error: err } = await supabase.auth.signInWithPassword({
email: email.trim(),
password: qrToken,
});
if (err) {
setError('Email and QR code do not match. Please try again.');
toast('Login failed', 'err');
} else if (data.session) {
toast('Welcome back! 🎉', 'ok');
}
} catch (e) {
setError(e instanceof Error ? e.message : 'Login failed');
} finally {
setBusy(false);
}
}
if (step === 'splash') {
return (
<section className="screen no-tab splash" onClick={() => setStep('scan')}>
<div className="logo">C</div>
<div className="splash-title">Convivo</div>
<div className="splash-tag">Break the ice. Earn the points.</div>
<div className="tap-hint">Tap anywhere to continue</div>
</section>
);
}
if (step === 'scan') {
return (
<section className="screen no-tab">
<div className="h1">Welcome back 👋</div>
<div className="muted small">Scan the QR code on your lanyard to log in.</div>
<Scanner onResult={handleScan} label="Point your camera at your lanyard QR" />
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
Demo: type <b>CVV-ANA-4821</b> (Ana) or <b>CVV-BRU-1177</b> (Bruno, staff)
</div>
</section>
);
}
return (
<section className="screen no-tab">
<div className="row" style={{ gap: 14 }}>
{found ? (
<Avatar name={found.full_name} id={found.id} size={64} fs={22} />
) : (
<span className="avatar" style={{ width: 64, height: 64, fontSize: 22, background: '#8a8484' }}>?</span>
)}
<div>
<div className="h2">{found ? found.full_name : 'Lanyard found'}</div>
<div className="muted small">{found ? found.company ?? '' : 'Confirm it’s you'}</div>
</div>
</div>
<div className="card">
<div className="h2" style={{ marginBottom: 6 }}>Confirm it’s you</div>
<div className="muted small" style={{ marginBottom: 12 }}>
Enter the email address you used when you bought your ticket.
</div>
<input
className="input"
type="email"
placeholder="[email protected]"
value={email}
onChange={(e) => setEmail(e.target.value)}
onKeyDown={(e) => e.key === 'Enter' && confirm()}
autoComplete="off"
/>
</div>
{error && <div className="muted small" style={{ color: 'var(--red)' }}>{error}</div>}
<button className="btn primary" disabled={busy || !email.trim()} onClick={confirm}>
{busy ? 'Checking…' : 'Confirm & enter →'}
</button>
<button className="btn ghost small" style={{ alignSelf: 'flex-start' }} onClick={() => setStep('scan')}>
← Different lanyard
</button>
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
Demo: <b>ana.silva@nubank.com</b> · <b>bruno.costa@acme.com</b>
</div>
</section>
);
}
+91
View File
@@ -0,0 +1,91 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { getMyPointsLog } from '../lib/api';
import type { PointsLogRow } from '../lib/types';
import { Avatar, QrImage, Spinner } from '../components/ui';
const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
checkin: 'Session check-ins',
connection: 'Connections',
feedback: 'Feedback',
admin: 'Other',
};
export function Profile() {
const { profile, signOut } = useAuth();
const [log, setLog] = useState<PointsLogRow[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
let active = true;
(async () => {
try {
const data = await getMyPointsLog();
if (active) setLog(data);
} catch {
/* non-fatal */
} finally {
if (active) setLoading(false);
}
})();
return () => {
active = false;
};
}, []);
if (!profile) return null;
const totals: Record<string, number> = {};
for (const l of log) totals[l.category] = (totals[l.category] ?? 0) + l.delta;
return (
<section className="screen">
<div className="h1">Profile</div>
<div className="card" style={{ textAlign: 'center' }}>
<Avatar name={profile.full_name} id={profile.id} size={72} fs={26} />
<div className="h2" style={{ marginTop: 10 }}>{profile.full_name}</div>
<div className="muted small">{profile.company ?? ''}</div>
<div className="row" style={{ justifyContent: 'center', marginTop: 10, gap: 8 }}>
<span className="pill violet">{profile.role}</span>
<span className="pill amber">⚡ {profile.points} pts</span>
</div>
</div>
<div className="card qr-wrap">
<div className="h2">My QR code</div>
{profile.qr_token ? (
<QrImage value={profile.qr_token} size={180} />
) : (
<div className="muted small">No QR token assigned.</div>
)}
<div className="muted small" style={{ textAlign: 'center' }}>
Show this to <b>staff</b> for session check-in<br />and to <b>peers</b> to make a connection.
</div>
</div>
<div className="card">
<div className="h2" style={{ marginBottom: 6 }}>Points breakdown</div>
{loading ? (
<div className="center" style={{ padding: 12 }}>
<Spinner />
</div>
) : (
<>
{Object.entries(totals).map(([cat, val]) => (
<div className="break-row" key={cat}>
<span>{CATEGORY_LABEL[cat as PointsLogRow['category']] ?? cat}</span>
<span className="v">+{val}</span>
</div>
))}
<div className="break-row">
<span style={{ fontWeight: 700 }}>Total</span>
<span className="v">{profile.points}</span>
</div>
</>
)}
</div>
<button className="btn danger" onClick={() => void signOut()}>Log out</button>
</section>
);
}
+163
View File
@@ -0,0 +1,163 @@
import { useEffect, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { checkinAttendee, createConnectionRequest, lanyardLookup } from '../lib/api';
import type { CheckinResult, PublicProfile } from '../lib/types';
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
export function Scan() {
const { profile } = useAuth();
const { slots, loading } = useEvent();
const [mode, setMode] = useState<'attendee' | 'staff'>(profile?.role === 'staff' || profile?.role === 'admin' ? 'staff' : 'attendee');
const [sessionId, setSessionId] = useState<string>('');
const [connectTarget, setConnectTarget] = useState<{ profile: PublicProfile; qr: string } | null>(null);
const [checkin, setCheckin] = useState<CheckinResult | null>(null);
const [busy, setBusy] = useState(false);
const { toast } = useToast();
useEffect(() => {
if (slots.length > 0 && !sessionId) {
const first = slots[0].sessions[0];
if (first) setSessionId(first.id);
}
}, [slots, sessionId]);
if (loading || !profile) {
return (
<section className="screen">
<div className="center" style={{ flex: 1 }}>
<Spinner />
</div>
</section>
);
}
const isStaff = mode === 'staff' && (profile.role === 'staff' || profile.role === 'admin');
const meId = profile.id;
async function handleScan(token: string) {
setBusy(true);
try {
if (isStaff) {
if (!sessionId) {
toast('Pick a session first', 'err');
return;
}
const res = await checkinAttendee(sessionId, token);
setCheckin(res);
} else {
const found = await lanyardLookup(token);
if (!found) {
toast('No attendee found for that code', 'err');
return;
}
if (found.id === meId) {
toast('That’s your own lanyard 🙂', 'err');
return;
}
setConnectTarget({ profile: found, qr: token });
}
} catch (e) {
toast(e instanceof Error ? e.message : 'Something went wrong', 'err');
} finally {
setBusy(false);
}
}
async function confirmConnect() {
if (!connectTarget) return;
setBusy(true);
try {
const conn = await createConnectionRequest(connectTarget.qr);
if (conn.status === 'accepted') toast('You’re connected! 🤝', 'ok');
else if (conn.status === 'pending') toast('Connection request sent', 'ok');
else toast('Request already resolved');
setConnectTarget(null);
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not send request', 'err');
} finally {
setBusy(false);
}
}
const selSession = slots.flatMap((s) => s.sessions).find((s) => s.id === sessionId);
return (
<section className="screen">
<div className="row between">
<div>
<div className="h1">{isStaff ? 'Check-in' : 'Scan'}</div>
<div className="muted small">{isStaff ? 'Scan attendees to check them in' : 'Scan a peer’s lanyard to connect'}</div>
</div>
<div className="seg" style={{ width: 170 }}>
<button className={mode === 'attendee' ? 'active' : ''} onClick={() => setMode('attendee')}>Attendee</button>
<button className={mode === 'staff' ? 'active' : ''} onClick={() => setMode('staff')}>Staff</button>
</div>
</div>
{isStaff && (
<div>
<div className="muted small" style={{ marginBottom: 7 }}>Checking in to session</div>
<select className="input" value={sessionId} onChange={(e) => setSessionId(e.target.value)}>
{slots.map(({ slot, sessions }) => (
<optgroup key={slot.id} label={`${slot.name} · ${slot.start_time.slice(0, 5)}`}>
{sessions.map((s) => (
<option key={s.id} value={s.id}>{s.title}</option>
))}
</optgroup>
))}
</select>
</div>
)}
<Scanner onResult={handleScan} label={isStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
{busy && <div className="center"><Spinner /></div>}
{isStaff && selSession && (
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
{selSession.room} · {selSession.speakers}
</div>
)}
{/* Connect sheet */}
<Sheet open={!!connectTarget} onClose={() => setConnectTarget(null)}>
{connectTarget && (
<div style={{ textAlign: 'center' }}>
<Avatar name={connectTarget.profile.full_name} id={connectTarget.profile.id} size={72} fs={26} />
<h3 style={{ marginTop: 12 }}>{connectTarget.profile.full_name}</h3>
<div className="sub">{connectTarget.profile.company ?? ''}</div>
<div style={{ marginTop: 16 }}>
<button className="btn primary" disabled={busy} onClick={confirmConnect}>
{busy ? 'Sending…' : 'Connect 🤝'}
</button>
<button className="btn ghost" style={{ marginTop: 8 }} onClick={() => setConnectTarget(null)}>
Not now
</button>
</div>
</div>
)}
</Sheet>
{/* Check-in result sheet */}
<Sheet open={!!checkin} onClose={() => setCheckin(null)}>
{checkin && (
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 52 }}>{checkin.already ? '⚠️' : '✅'}</div>
<h3 style={{ marginTop: 10 }}>{checkin.attendee_name}</h3>
<div className="sub">{checkin.already ? 'Already checked in' : 'Checked in'}</div>
<div style={{ marginTop: 14 }}>
{checkin.already ? (
<span className="pill amber">No extra points</span>
) : (
<span className="pill green">+10 pts · now {checkin.points}</span>
)}
</div>
<button className="btn primary" style={{ marginTop: 18 }} onClick={() => setCheckin(null)}>
Scan next
</button>
</div>
)}
</Sheet>
</section>
);
}
+255
View File
@@ -0,0 +1,255 @@
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
--bg: #f0f2f6; --phone-bg: #ffffff; --surface: #ffffff; --surface-2: #f4f5f9;
--line: #e4e6ee; --text: #423c3c; --muted: #8a8484;
--accent: #d50000; --accent-2: #20b2aa; --accent-soft: rgba(213,0,0,.08);
--cyan: #20b2aa; --amber: #f59e0b; --green: #059669; --red: #d50000;
}
html, body, #root { height: 100%; }
body {
background: radial-gradient(1100px 700px at 75% -10%, rgba(213,0,0,.06) 0%, var(--bg) 55%);
font-family: 'Poppins', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
color: var(--text);
}
/* ---------- App shell (phone frame on desktop, full-bleed on mobile) ---------- */
.app {
position: relative; width: 100%; height: 100dvh; max-width: 480px; margin: 0 auto;
background: var(--phone-bg); overflow: hidden; display: flex; flex-direction: column;
}
@media (min-width: 520px) {
.app { height: min(920px, 96dvh); border-radius: 34px; border: 10px solid #1f1b1b;
box-shadow: 0 0 0 2px #3a3333, 0 40px 90px rgba(66,60,60,.28); margin-top: 2vh; }
}
.screen { flex: 1; overflow-y: auto; padding: 22px 20px 100px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: none; }
.screen::-webkit-scrollbar { display: none; }
.screen.no-tab { padding-bottom: 28px; }
/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: 0 8px 24px rgba(66,60,60,.07); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.h1 { font-size: 23px; font-weight: 800; letter-spacing: -.5px; }
.h2 { font-size: 17px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.btn {
display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
padding: 15px 18px; border-radius: 14px; border: 1px solid var(--line);
background: var(--surface-2); color: var(--text); font-size: 15px; font-weight: 700;
cursor: pointer; transition: transform .08s ease, opacity .15s; font-family: inherit;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border: none; color: #fff; box-shadow: 0 8px 20px rgba(213,0,0,.25); }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(213,0,0,.08); border-color: rgba(213,0,0,.35); color: var(--red); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.pill {
display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line);
}
.pill.amber { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.4); color: #b45309; }
.pill.green { background: rgba(5,150,105,.12); border-color: rgba(5,150,105,.35); color: var(--green); }
.pill.violet { background: var(--accent-soft); border-color: rgba(213,0,0,.35); color: var(--accent); }
.pill.cyan { background: rgba(32,178,170,.13); border-color: rgba(32,178,170,.4); color: #0f766e; }
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 800; color: #fff; flex-shrink: 0; }
.input {
width: 100%; padding: 15px 16px; border-radius: 14px; border: 1px solid var(--line);
background: var(--surface-2); color: var(--text); font-size: 15px; outline: none; font-family: inherit;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: none; min-height: 96px; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
/* ---------- Tab bar ---------- */
.tabbar {
position: absolute; left: 0; right: 0; bottom: 0; height: 84px; z-index: 40;
background: rgba(255,255,255,.94); backdrop-filter: blur(14px);
border-top: 1px solid var(--line); display: flex; align-items: flex-start;
justify-content: space-around; padding: 10px 8px 0;
}
.tab {
background: none; border: none; color: var(--muted); font-size: 10.5px; font-weight: 700;
display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
width: 64px; padding-top: 4px; font-family: inherit;
}
.tab .ico { font-size: 21px; line-height: 1; filter: grayscale(.4); }
.tab.active { color: var(--accent); }
.tab.active .ico { filter: none; }
.tab-scan { position: relative; top: -18px; }
.tab-scan .scan-btn {
width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
font-size: 24px; background: linear-gradient(135deg, var(--accent), #ff5a4e);
box-shadow: 0 8px 20px rgba(213,0,0,.4); border: 4px solid var(--phone-bg);
}
.tab-scan.active { color: var(--accent); }
/* ---------- Splash ---------- */
.splash { align-items: center; justify-content: center; text-align: center; gap: 18px; }
.logo {
width: 96px; height: 96px; border-radius: 26px; display: flex; align-items: center; justify-content: center;
font-size: 40px; font-weight: 900; background: linear-gradient(135deg, var(--accent), #ff5a4e);
box-shadow: 0 16px 40px rgba(213,0,0,.35); color: #fff;
}
.splash-title { font-size: 30px; font-weight: 900; letter-spacing: -.5px; }
.splash-tag { color: var(--muted); font-size: 15px; }
.tap-hint { margin-top: 26px; color: var(--muted); font-size: 13px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: .45 } 50% { opacity: 1 } }
/* ---------- Camera / scan ---------- */
.viewfinder {
position: relative; height: 300px; border-radius: 20px; overflow: hidden;
background: radial-gradient(220px 160px at 50% 45%, rgba(213,0,0,.14), transparent 70%), linear-gradient(160deg,#26211f 0%, #171312 100%);
border: 1px solid var(--line);
}
.vf-corner { position: absolute; width: 34px; height: 34px; border: 3px solid #ff6b5e; }
.vf-corner.tl { top: 18px; left: 18px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.vf-corner.tr { top: 18px; right: 18px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.vf-corner.bl { bottom: 18px; left: 18px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.vf-corner.br { bottom: 18px; right: 18px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.vf-line {
position: absolute; left: 26px; right: 26px; height: 2px; border-radius: 2px;
background: linear-gradient(90deg, transparent, var(--cyan), transparent);
animation: scan 2.2s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 34px; } 50% { top: 258px; } }
.vf-qr { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 120px; height: 120px; opacity: .5; }
#qr-reader, #qr-reader video { width: 100% !important; height: 300px !important; object-fit: cover; border-radius: 20px; }
/* ---------- Home ---------- */
.points-pill {
display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.4);
color: #b45309; font-weight: 800; font-size: 14px; cursor: pointer; flex-shrink: 0; white-space: nowrap;
}
.now-card { background: linear-gradient(135deg, rgba(213,0,0,.1), rgba(32,178,170,.08)); border: 1px solid rgba(213,0,0,.35); }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa {
display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 16px; cursor: pointer;
background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(66,60,60,.06); transition: transform .08s;
}
.qa:active { transform: scale(.97); }
.qa .ico { font-size: 22px; }
.qa .lbl { font-weight: 700; font-size: 14px; }
.pick-chip {
display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
padding: 12px 14px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line);
color: var(--text); cursor: pointer; font-size: 13.5px; font-family: inherit;
}
.pick-chip + .pick-chip { margin-top: 8px; }
.pick-chip .t { color: var(--muted); font-weight: 800; font-size: 12px; min-width: 74px; }
/* ---------- Agenda ---------- */
.slot-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 8px 24px rgba(66,60,60,.07); }
.slot-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.slot-head .name { font-weight: 800; font-size: 14.5px; }
.slot-head .time { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sess {
display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
padding: 13px 16px; background: none; border: none; border-bottom: 1px solid var(--line);
color: var(--text); cursor: pointer; font-family: inherit;
}
.sess:last-child { border-bottom: none; }
.sess.picked { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.sess .title { font-weight: 700; font-size: 14px; }
.sess .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sess .check {
margin-left: auto; width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
font-size: 13px; color: transparent;
}
.sess.picked .check { background: var(--accent); border-color: var(--accent); color: #fff; }
/* ---------- Modal (bottom sheet) ---------- */
.backdrop { position: absolute; inset: 0; background: rgba(5,5,10,.66); backdrop-filter: blur(3px); z-index: 70; display: flex; align-items: flex-end; }
.sheet {
width: 100%; background: var(--surface); border-radius: 26px 26px 0 0;
border-top: 1px solid var(--line); padding: 14px 20px 26px; max-height: 82%;
overflow-y: auto; animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4 } to { transform: none; opacity: 1 } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
/* ---------- Connections ---------- */
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 4px; }
.seg button {
flex: 1; padding: 10px; border: none; border-radius: 10px; background: none; color: var(--muted);
font-weight: 700; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.seg button.active { background: var(--accent-soft); color: var(--accent); }
.conn {
display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 14px;
background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(66,60,60,.06);
}
.conn + .conn { margin-top: 9px; }
.conn .name { font-weight: 700; font-size: 14.5px; }
.conn .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty {
text-align: center; padding: 38px 20px; color: var(--muted); font-size: 14px;
border: 1.5px dashed var(--line); border-radius: 16px;
}
.empty .big { font-size: 34px; margin-bottom: 10px; }
/* ---------- Feedback ---------- */
.stars { display: flex; gap: 10px; justify-content: center; padding: 6px 0 2px; }
.star { font-size: 40px; cursor: pointer; color: #d5d8e2; transition: transform .1s, color .1s; user-select: none; background: none; border: none; }
.star.on { color: var(--amber); text-shadow: 0 0 18px rgba(245,158,11,.4); }
.star:active { transform: scale(1.2); }
.success-box { text-align: center; padding: 30px 16px; }
.success-box .emoji { font-size: 56px; }
.success-box h3 { font-size: 22px; margin-top: 12px; }
.success-box p { color: var(--muted); margin-top: 6px; font-size: 14px; }
/* ---------- Leaderboard ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; padding: 18px 6px 6px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 96px; }
.pod .bar {
width: 100%; border-radius: 12px 12px 0 0; display: flex; align-items: flex-start; justify-content: center;
padding-top: 8px; font-weight: 900; font-size: 15px;
}
.pod .bar.b1 { height: 86px; background: linear-gradient(180deg, rgba(245,158,11,.32), rgba(245,158,11,.08)); border: 1px solid rgba(245,158,11,.5); border-bottom: none; color: #b45309; }
.pod .bar.b2 { height: 62px; background: linear-gradient(180deg, rgba(148,163,184,.32), rgba(148,163,184,.08)); border: 1px solid rgba(148,163,184,.5); border-bottom: none; color: #64748b; }
.pod .bar.b3 { height: 48px; background: linear-gradient(180deg, rgba(217,119,6,.3), rgba(217,119,6,.1)); border: 1px solid rgba(217,119,6,.5); border-bottom: none; color: #c2620a; }
.pod .pname { font-size: 12px; font-weight: 700; }
.pod .ppoints { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.lb-row {
display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px;
background: var(--surface); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(66,60,60,.06);
}
.lb-row + .lb-row { margin-top: 8px; }
.lb-row.me { border-color: rgba(213,0,0,.5); background: var(--accent-soft); }
.lb-row .rank { width: 26px; font-weight: 900; color: var(--muted); font-size: 14px; text-align: center; }
.lb-row .pts { margin-left: auto; font-weight: 800; color: #b45309; font-size: 14px; }
/* ---------- Profile ---------- */
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; }
.qr-frame { background: #fff; border-radius: 12px; padding: 10px; border: 1px solid var(--line); }
.break-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.break-row:last-child { border-bottom: none; }
.break-row .v { font-weight: 800; color: var(--amber); }
/* ---------- Toast ---------- */
.toast {
position: absolute; left: 16px; right: 16px; bottom: 104px; z-index: 90;
background: #fff; border: 1px solid var(--line); border-radius: 14px;
padding: 13px 16px; font-size: 13.5px; font-weight: 600; text-align: center;
box-shadow: 0 12px 30px rgba(66,60,60,.22); opacity: 0; transform: translateY(12px);
transition: all .25s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-color: rgba(5,150,105,.5); }
.toast.err { border-color: rgba(213,0,0,.55); }
/* ---------- Misc ---------- */
.spinner {
width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent);
border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: flex; align-items: center; justify-content: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
+10
View File
@@ -0,0 +1,10 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_SUPABASE_URL: string;
readonly VITE_SUPABASE_ANON_KEY: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"noEmit": true
},
"include": ["vite.config.ts"]
}
+20
View File
@@ -0,0 +1,20 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// Dev server proxies /auth, /rest, /realtime, /storage to the local Supabase
// stack so the app can use relative URLs (works in Docker + localhost).
const SUPABASE_TARGET = 'http://127.0.0.1:54321';
export default defineConfig({
plugins: [react()],
server: {
host: true,
port: 3000,
proxy: {
'/auth': { target: SUPABASE_TARGET, changeOrigin: true },
'/rest': { target: SUPABASE_TARGET, changeOrigin: true },
'/realtime': { target: SUPABASE_TARGET, changeOrigin: true, ws: true },
'/storage': { target: SUPABASE_TARGET, changeOrigin: true },
},
},
});