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:
commit
37684ba116
45 files changed
+6922
No files matched your search
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user