Redesign Phases 3-6: multi-event model, APPE Admin, Convivo App behaviors, APPE branding
- Phase 3: new migration 20260824000000_redesign.sql (contacts/events/registrations/sponsors, slot types, session speakers + feedback/material), seed rewrite - Phase 4: APPE Admin rebrand + Contacts/Registrations/Sponsors/Schedule/Activity/Events views - Phase 5: Convivo App (24h login, 5s polling, QR type badge, red dot, speaker material) - Phase 6: APPE favicon + PWA icons for both apps - Docs: schema/rpcs/rls/seed/screens/api-client/admin-app/architecture/next-steps/README/roadmap updated
This commit is contained in:
1 parent
5adb5785aa
commit
22f5f1d317
64 files changed
+4593
-1371
No files matched your search
@@ -1,26 +1,45 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { clearPreference, getMyCheckins, getMyPreferences, setPreference } from '../lib/api';
|
||||
import {
|
||||
clearPreference,
|
||||
getMyCheckins,
|
||||
getMyPreferences,
|
||||
getMySpeakerSessions,
|
||||
sessionMaterialUrl,
|
||||
setPreference,
|
||||
uploadSessionMaterial,
|
||||
} 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 { contact } = useAuth();
|
||||
const { event, slots, now, loading, reload } = useEvent();
|
||||
const [prefs, setPrefs] = useState<Preference[]>([]);
|
||||
const [checkins, setCheckins] = useState<string[]>([]);
|
||||
const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]);
|
||||
const [selected, setSelected] = useState<Session | null>(null);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const { toast } = useToast();
|
||||
|
||||
const email = contact?.email ?? '';
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
(async () => {
|
||||
try {
|
||||
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins()]);
|
||||
const [p, c, sp] = await Promise.all([
|
||||
getMyPreferences(),
|
||||
getMyCheckins(email),
|
||||
getMySpeakerSessions(email),
|
||||
]);
|
||||
if (!active) return;
|
||||
setPrefs(p);
|
||||
setCheckins(c);
|
||||
setMySpeakerSessions(sp);
|
||||
} catch {
|
||||
/* non-fatal */
|
||||
}
|
||||
@@ -28,7 +47,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, []);
|
||||
}, [email]);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -40,6 +59,20 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
);
|
||||
}
|
||||
|
||||
if (!event) {
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="h1">Agenda</div>
|
||||
<div className="card" style={{ marginTop: 16 }}>
|
||||
<div className="empty">
|
||||
<div className="big">📅</div>
|
||||
No active event right now.
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const pickFor = (slotId: number) => prefs.find((p) => p.slot_id === slotId)?.session_id;
|
||||
|
||||
async function togglePick(slotId: number, sessionId: string) {
|
||||
@@ -62,15 +95,33 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
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;
|
||||
const selISpeaker = selected ? mySpeakerSessions.includes(selected.id) : false;
|
||||
const selNeedsMaterial = selISpeaker && !selected?.material_path;
|
||||
|
||||
async function handleUpload(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file || !selected) return;
|
||||
try {
|
||||
await uploadSessionMaterial(selected.id, file);
|
||||
toast('Material uploaded ✓', 'ok');
|
||||
setSelected(null);
|
||||
// Refresh agenda so material_path updates.
|
||||
reload();
|
||||
} catch (err) {
|
||||
toast(err instanceof Error ? err.message : 'Upload failed', 'err');
|
||||
} finally {
|
||||
if (fileRef.current) fileRef.current.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
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 className="muted small">{event.name}</div>
|
||||
</div>
|
||||
<span className="pill violet">6 slots · 3 tracks</span>
|
||||
<span className="pill violet">{slots.length} slots</span>
|
||||
</div>
|
||||
<div className="muted small" style={{ marginTop: -4 }}>
|
||||
Pick <b>one session per slot</b> — you can change until the slot starts.
|
||||
@@ -83,7 +134,9 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
<div className="slot-card" key={slot.id}>
|
||||
<div className="slot-head">
|
||||
<div className="grow">
|
||||
<div className="name">{slot.name}</div>
|
||||
<div className="name">
|
||||
{slot.name} <span className={`pill slot-type-${slot.type}`}>{slot.type.replace('_', ' ')}</span>
|
||||
</div>
|
||||
<div className="time">{fmtRange(slot)}</div>
|
||||
</div>
|
||||
{status === 'done' && <span className="pill">Done</span>}
|
||||
@@ -92,16 +145,17 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
</div>
|
||||
{sessions.map((s) => {
|
||||
const picked = pickFor(slot.id) === s.id;
|
||||
const isMySession = mySpeakerSessions.includes(s.id);
|
||||
return (
|
||||
<button
|
||||
key={s.id}
|
||||
className={`sess ${picked ? 'picked' : ''}`}
|
||||
onClick={() => setSelected(s)}
|
||||
>
|
||||
<button key={s.id} className={`sess ${picked ? 'picked' : ''}`} onClick={() => setSelected(s)}>
|
||||
<div className="grow">
|
||||
<div className="title">{s.title}</div>
|
||||
<div className="title">
|
||||
{s.title}
|
||||
{isMySession && <span className="pill speaker-tag" style={{ marginLeft: 6 }}>🎤 you</span>}
|
||||
</div>
|
||||
<div className="meta">
|
||||
{s.room} · {s.speakers}
|
||||
{s.material_path && <span style={{ marginLeft: 6 }}>📎</span>}
|
||||
</div>
|
||||
</div>
|
||||
<span className="check">✓</span>
|
||||
@@ -128,11 +182,30 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
<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 }}>
|
||||
<div className="row" style={{ gap: 8, marginBottom: 14, flexWrap: 'wrap' }}>
|
||||
<span className="pill">🎤 {selected.speakers}</span>
|
||||
{selected.capacity && <span className="pill">👥 {selected.capacity}</span>}
|
||||
{selCheckedIn && <span className="pill green">✓ Checked in</span>}
|
||||
</div>
|
||||
|
||||
{/* Speaker material: non-dismissible notification until uploaded. */}
|
||||
{selNeedsMaterial && (
|
||||
<div className="material-notice">
|
||||
<div className="mn-title">📎 Upload your session material</div>
|
||||
<div className="muted small" style={{ marginBottom: 10 }}>
|
||||
Attendees can download your slides/notes from this session.
|
||||
</div>
|
||||
<input ref={fileRef} type="file" className="input" onChange={handleUpload} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Material download (all attendees). */}
|
||||
{selected.material_path && (
|
||||
<a className="btn primary" href={sessionMaterialUrl(selected.material_path)} target="_blank" rel="noreferrer">
|
||||
📎 Download material
|
||||
</a>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{selStatus === 'done' && selCheckedIn && (
|
||||
<button className="btn primary" onClick={() => openFeedback(selected.id)}>
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
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 { acceptConnection, getMyConnections, getPublicContacts, rejectConnection } from '../lib/api';
|
||||
import { usePolling } from '../lib/usePolling';
|
||||
import type { Connection, PublicContact } from '../lib/types';
|
||||
import { Avatar, Empty, Spinner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
export function Connections() {
|
||||
const { profile } = useAuth();
|
||||
const { contact } = useAuth();
|
||||
const [tab, setTab] = useState<'mine' | 'req'>('mine');
|
||||
const [conns, setConns] = useState<Connection[]>([]);
|
||||
const [people, setPeople] = useState<Map<string, PublicProfile>>(new Map());
|
||||
const [people, setPeople] = useState<Map<string, PublicContact>>(new Map());
|
||||
const [loading, setLoading] = useState(true);
|
||||
const { toast } = useToast();
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const [c, p] = await Promise.all([getMyConnections(), getPublicProfiles()]);
|
||||
const [c, p] = await Promise.all([getMyConnections(), getPublicContacts()]);
|
||||
setConns(c);
|
||||
setPeople(new Map(p.map((x) => [x.id, x])));
|
||||
setPeople(new Map(p.map((x) => [x.email, x])));
|
||||
} catch {
|
||||
/* non-fatal */
|
||||
} finally {
|
||||
@@ -29,14 +30,17 @@ export function Connections() {
|
||||
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 ?? '';
|
||||
// Live-ish updates: poll every 5s while the tab is visible.
|
||||
usePolling(() => void load(), 5000, !loading);
|
||||
|
||||
if (!contact) return null;
|
||||
const me = contact.email;
|
||||
const nameOf = (email: string) => people.get(email)?.full_name ?? '…';
|
||||
const typeOf = (email: string) => people.get(email)?.registration_type ?? null;
|
||||
|
||||
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);
|
||||
const incoming = conns.filter((c) => c.status === 'pending' && c.to_email === me);
|
||||
const outgoing = conns.filter((c) => c.status === 'pending' && c.from_email === me);
|
||||
|
||||
async function resolve(id: string, accept: boolean) {
|
||||
try {
|
||||
@@ -74,13 +78,13 @@ export function Connections() {
|
||||
<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;
|
||||
const otherEmail = c.from_email === me ? c.to_email : c.from_email;
|
||||
return (
|
||||
<div className="conn" key={c.id}>
|
||||
<Avatar name={nameOf(otherId)} id={otherId} size={44} />
|
||||
<Avatar name={nameOf(otherEmail)} id={otherEmail} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(otherId)}</div>
|
||||
<div className="meta">{companyOf(otherId)}</div>
|
||||
<div className="name">{nameOf(otherEmail)}</div>
|
||||
{typeOf(otherEmail) && <div className="meta">{typeOf(otherEmail)!.replace('_', ' ')}</div>}
|
||||
</div>
|
||||
<span className="pill green">Connected</span>
|
||||
</div>
|
||||
@@ -98,10 +102,10 @@ export function Connections() {
|
||||
<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} />
|
||||
<Avatar name={nameOf(c.from_email)} id={c.from_email} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(c.from_id)}</div>
|
||||
<div className="meta">{companyOf(c.from_id)}</div>
|
||||
<div className="name">{nameOf(c.from_email)}</div>
|
||||
{typeOf(c.from_email) && <div className="meta">{typeOf(c.from_email)!.replace('_', ' ')}</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>
|
||||
@@ -114,10 +118,10 @@ export function Connections() {
|
||||
<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} />
|
||||
<Avatar name={nameOf(c.to_email)} id={c.to_email} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(c.to_id)}</div>
|
||||
<div className="meta">{companyOf(c.to_id)}</div>
|
||||
<div className="name">{nameOf(c.to_email)}</div>
|
||||
{typeOf(c.to_email) && <div className="meta">{typeOf(c.to_email)!.replace('_', ' ')}</div>}
|
||||
</div>
|
||||
<span className="pill amber">Pending</span>
|
||||
</div>
|
||||
|
||||
@@ -1,41 +1,21 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { 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 { submitFeedback } from '../lib/api';
|
||||
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 { contact } = useAuth();
|
||||
const { sessionById, 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) {
|
||||
if (loading || !session) {
|
||||
return (
|
||||
<section className="screen no-tab">
|
||||
<div className="center" style={{ flex: 1 }}>
|
||||
@@ -46,12 +26,12 @@ export function Feedback({ sessionId, onDone }: { sessionId: string; onDone: ()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (rating < 1) return;
|
||||
if (rating === 0) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
const res = await submitFeedback(sessionId, rating, comment.trim());
|
||||
await refreshProfile();
|
||||
setDone({ earned: res.earned });
|
||||
toast(`Thanks! +${res.earned} pts ⭐`, 'ok');
|
||||
onDone();
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Could not submit feedback', 'err');
|
||||
} finally {
|
||||
@@ -59,47 +39,48 @@ export function Feedback({ sessionId, onDone }: { sessionId: string; onDone: ()
|
||||
}
|
||||
}
|
||||
|
||||
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 className="row" style={{ marginBottom: 14 }}>
|
||||
<button className="btn ghost small" onClick={onDone}>← Back</button>
|
||||
<div className="grow" style={{ textAlign: 'center' }}>
|
||||
<div className="h2">Rate this session</div>
|
||||
</div>
|
||||
<span style={{ width: 60 }} />
|
||||
</div>
|
||||
<button className="btn primary" disabled={busy || rating < 1} onClick={submit}>
|
||||
{busy ? 'Submitting…' : existing ? 'Update feedback' : 'Submit feedback'}
|
||||
|
||||
<div className="card" style={{ textAlign: 'center' }}>
|
||||
<div className="h2">{session.title}</div>
|
||||
<div className="muted small" style={{ marginTop: 4 }}>{session.room} · {session.speakers}</div>
|
||||
</div>
|
||||
|
||||
<div className="stars" style={{ justifyContent: 'center', margin: '20px 0' }}>
|
||||
{[1, 2, 3, 4, 5].map((n) => (
|
||||
<button
|
||||
key={n}
|
||||
className={`star ${n <= rating ? 'on' : ''}`}
|
||||
onClick={() => setRating(n)}
|
||||
aria-label={`${n} star${n > 1 ? 's' : ''}`}
|
||||
>
|
||||
★
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
className="input"
|
||||
placeholder="Add a comment (optional) — comments earn bonus points"
|
||||
value={comment}
|
||||
onChange={(e) => setComment(e.target.value)}
|
||||
rows={4}
|
||||
/>
|
||||
|
||||
<button className="btn primary" disabled={busy || rating === 0} onClick={submit}>
|
||||
{busy ? 'Submitting…' : 'Submit feedback'}
|
||||
</button>
|
||||
<div className="muted small" style={{ textAlign: 'center', marginTop: 8 }}>
|
||||
{contact ? `Signing in as ${contact.full_name}` : ''}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -4,19 +4,21 @@ 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';
|
||||
import { Avatar, Empty, Spinner } from '../components/ui';
|
||||
|
||||
export function Home({ go }: { go: (tab: string) => void }) {
|
||||
const { profile } = useAuth();
|
||||
const { slots, sessionById, now, loading } = useEvent();
|
||||
const { contact, registration } = useAuth();
|
||||
const { event, slots, sessionById, now, loading } = useEvent();
|
||||
const [prefs, setPrefs] = useState<Preference[]>([]);
|
||||
const [checkins, setCheckins] = useState<string[]>([]);
|
||||
|
||||
const email = contact?.email ?? '';
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
(async () => {
|
||||
try {
|
||||
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins()]);
|
||||
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins(email)]);
|
||||
if (!active) return;
|
||||
setPrefs(p);
|
||||
setCheckins(c);
|
||||
@@ -27,9 +29,9 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, []);
|
||||
}, [email]);
|
||||
|
||||
if (loading || !profile) {
|
||||
if (loading || !contact) {
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="center" style={{ flex: 1 }}>
|
||||
@@ -39,6 +41,19 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!event) {
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="h1">APPE</div>
|
||||
<div className="card" style={{ marginTop: 16 }}>
|
||||
<Empty icon="📅" text="No active event right now. Check back soon!" />
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
const points = registration?.points ?? 0;
|
||||
const isStaff = contact.is_admin;
|
||||
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');
|
||||
@@ -46,16 +61,16 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
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];
|
||||
const firstName = contact.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 className="muted small">{event.name}</div>
|
||||
</div>
|
||||
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {profile.points}</div>
|
||||
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {points}</div>
|
||||
</div>
|
||||
|
||||
{nowSession && current && (
|
||||
@@ -114,7 +129,7 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
<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>
|
||||
<span className="lbl">{isStaff ? 'Check-in' : 'Scan & connect'}</span>
|
||||
</div>
|
||||
<div className="qa" onClick={() => go('agenda')}>
|
||||
<span className="ico">📅</span>
|
||||
@@ -131,7 +146,7 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
</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 ?? ''}
|
||||
<Avatar name={contact.full_name} id={contact.email} size={22} fs={9} /> {registration?.type.replace('_', ' ') ?? ''}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { LeaderboardRow } from '../lib/types';
|
||||
import { Avatar, Spinner } from '../components/ui';
|
||||
|
||||
export function Leaderboard() {
|
||||
const { profile } = useAuth();
|
||||
const { contact } = useAuth();
|
||||
const [rows, setRows] = useState<LeaderboardRow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
@@ -48,10 +48,10 @@ export function Leaderboard() {
|
||||
);
|
||||
}
|
||||
|
||||
const me = profile?.id;
|
||||
const me = contact?.email;
|
||||
const top3 = rows.slice(0, 3);
|
||||
const rest = rows.slice(3);
|
||||
const myRank = rows.findIndex((r) => r.profile_id === me) + 1;
|
||||
const myRank = rows.findIndex((r) => r.contact_email === me) + 1;
|
||||
|
||||
return (
|
||||
<section className="screen">
|
||||
@@ -70,7 +70,7 @@ export function Leaderboard() {
|
||||
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="pod" key={r.contact_email}>
|
||||
<div className={`bar ${cls}`}>{r.points}</div>
|
||||
<div className="pname">{r.full_name.split(' ')[0]}</div>
|
||||
<div className="ppoints">#{idx + 1}</div>
|
||||
@@ -83,14 +83,13 @@ export function Leaderboard() {
|
||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
{rest.map((r, i) => {
|
||||
const rank = i + 4;
|
||||
const isMe = r.profile_id === me;
|
||||
const isMe = r.contact_email === me;
|
||||
return (
|
||||
<div className={`lb-row ${isMe ? 'me' : ''}`} key={r.profile_id}>
|
||||
<div className={`lb-row ${isMe ? 'me' : ''}`} key={r.contact_email}>
|
||||
<span className="rank">{rank}</span>
|
||||
<Avatar name={r.full_name} id={r.profile_id} size={38} fs={13} />
|
||||
<Avatar name={r.full_name} id={r.contact_email} 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>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import { lanyardLookup } from '../lib/api';
|
||||
import type { PublicProfile } from '../lib/types';
|
||||
import type { PublicContact } from '../lib/types';
|
||||
import { Avatar, Scanner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
@@ -10,7 +10,7 @@ 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 [found, setFound] = useState<PublicContact | null>(null);
|
||||
const [email, setEmail] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -22,9 +22,9 @@ export function Login() {
|
||||
setQrToken(token);
|
||||
setError(null);
|
||||
try {
|
||||
const profile = await lanyardLookup(token);
|
||||
setFound(profile);
|
||||
if (!profile) toast('No attendee found for that code', 'err');
|
||||
const contact = await lanyardLookup(token);
|
||||
setFound(contact);
|
||||
if (!contact) toast('No attendee found for that code', 'err');
|
||||
} catch {
|
||||
setFound(null);
|
||||
}
|
||||
@@ -56,8 +56,8 @@ export function Login() {
|
||||
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="logo">A</div>
|
||||
<div className="splash-title">APPE</div>
|
||||
<div className="splash-tag">Break the ice. Earn the points.</div>
|
||||
<div className="tap-hint">Tap anywhere to continue</div>
|
||||
</section>
|
||||
@@ -81,13 +81,15 @@ export function Login() {
|
||||
<section className="screen no-tab">
|
||||
<div className="row" style={{ gap: 14 }}>
|
||||
{found ? (
|
||||
<Avatar name={found.full_name} id={found.id} size={64} fs={22} />
|
||||
<Avatar name={found.full_name} id={found.email} 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 className="muted small">
|
||||
{found ? (found.registration_type ? found.registration_type.replace('_', ' ') : 'Confirm it’s you') : 'Confirm it’s you'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card">
|
||||
|
||||
@@ -12,15 +12,17 @@ const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
|
||||
};
|
||||
|
||||
export function Profile() {
|
||||
const { profile, signOut } = useAuth();
|
||||
const { contact, registration, signOut } = useAuth();
|
||||
const [log, setLog] = useState<PointsLogRow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
const email = contact?.email ?? '';
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
(async () => {
|
||||
try {
|
||||
const data = await getMyPointsLog();
|
||||
const data = await getMyPointsLog(email);
|
||||
if (active) setLog(data);
|
||||
} catch {
|
||||
/* non-fatal */
|
||||
@@ -31,10 +33,11 @@ export function Profile() {
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, []);
|
||||
}, [email]);
|
||||
|
||||
if (!profile) return null;
|
||||
if (!contact) return null;
|
||||
|
||||
const points = registration?.points ?? 0;
|
||||
const totals: Record<string, number> = {};
|
||||
for (const l of log) totals[l.category] = (totals[l.category] ?? 0) + l.delta;
|
||||
|
||||
@@ -42,19 +45,20 @@ export function Profile() {
|
||||
<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>
|
||||
<Avatar name={contact.full_name} id={contact.email} size={72} fs={26} />
|
||||
<div className="h2" style={{ marginTop: 10 }}>{contact.full_name}</div>
|
||||
<div className="muted small">{contact.email}</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>
|
||||
{registration && <span className={`pill reg-${registration.type}`}>{registration.type.replace('_', ' ')}</span>}
|
||||
{contact.is_admin && <span className="pill admin">staff</span>}
|
||||
<span className="pill amber">⚡ {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} />
|
||||
{contact.qr_token ? (
|
||||
<QrImage value={contact.qr_token} size={180} />
|
||||
) : (
|
||||
<div className="muted small">No QR token assigned.</div>
|
||||
)}
|
||||
@@ -79,7 +83,7 @@ export function Profile() {
|
||||
))}
|
||||
<div className="break-row">
|
||||
<span style={{ fontWeight: 700 }}>Total</span>
|
||||
<span className="v">{profile.points}</span>
|
||||
<span className="v">{points}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -2,16 +2,17 @@ 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 type { CheckinResult, PublicContact } from '../lib/types';
|
||||
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
export function Scan() {
|
||||
const { profile } = useAuth();
|
||||
const { contact } = useAuth();
|
||||
const { slots, loading } = useEvent();
|
||||
const [mode, setMode] = useState<'attendee' | 'staff'>(profile?.role === 'staff' || profile?.role === 'admin' ? 'staff' : 'attendee');
|
||||
const isStaff = !!contact?.is_admin;
|
||||
const [mode, setMode] = useState<'attendee' | 'staff'>(isStaff ? 'staff' : 'attendee');
|
||||
const [sessionId, setSessionId] = useState<string>('');
|
||||
const [connectTarget, setConnectTarget] = useState<{ profile: PublicProfile; qr: string } | null>(null);
|
||||
const [connectTarget, setConnectTarget] = useState<{ contact: PublicContact; qr: string } | null>(null);
|
||||
const [checkin, setCheckin] = useState<CheckinResult | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const { toast } = useToast();
|
||||
@@ -23,7 +24,7 @@ export function Scan() {
|
||||
}
|
||||
}, [slots, sessionId]);
|
||||
|
||||
if (loading || !profile) {
|
||||
if (loading || !contact) {
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="center" style={{ flex: 1 }}>
|
||||
@@ -33,13 +34,13 @@ export function Scan() {
|
||||
);
|
||||
}
|
||||
|
||||
const isStaff = mode === 'staff' && (profile.role === 'staff' || profile.role === 'admin');
|
||||
const meId = profile.id;
|
||||
const meEmail = contact.email;
|
||||
const activeStaff = mode === 'staff' && isStaff;
|
||||
|
||||
async function handleScan(token: string) {
|
||||
setBusy(true);
|
||||
try {
|
||||
if (isStaff) {
|
||||
if (activeStaff) {
|
||||
if (!sessionId) {
|
||||
toast('Pick a session first', 'err');
|
||||
return;
|
||||
@@ -52,11 +53,11 @@ export function Scan() {
|
||||
toast('No attendee found for that code', 'err');
|
||||
return;
|
||||
}
|
||||
if (found.id === meId) {
|
||||
if (found.email === meEmail) {
|
||||
toast('That’s your own lanyard 🙂', 'err');
|
||||
return;
|
||||
}
|
||||
setConnectTarget({ profile: found, qr: token });
|
||||
setConnectTarget({ contact: found, qr: token });
|
||||
}
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Something went wrong', 'err');
|
||||
@@ -87,16 +88,18 @@ export function Scan() {
|
||||
<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 className="h1">{activeStaff ? 'Check-in' : 'Scan'}</div>
|
||||
<div className="muted small">{activeStaff ? 'Scan attendees to check them in' : 'Scan a peer’s lanyard to connect'}</div>
|
||||
</div>
|
||||
{isStaff && (
|
||||
<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 && (
|
||||
{activeStaff && (
|
||||
<div>
|
||||
<div className="muted small" style={{ marginBottom: 7 }}>Checking in to session</div>
|
||||
<select className="input" value={sessionId} onChange={(e) => setSessionId(e.target.value)}>
|
||||
@@ -111,9 +114,9 @@ export function Scan() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Scanner onResult={handleScan} label={isStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
|
||||
<Scanner onResult={handleScan} label={activeStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
|
||||
{busy && <div className="center"><Spinner /></div>}
|
||||
{isStaff && selSession && (
|
||||
{activeStaff && selSession && (
|
||||
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
|
||||
{selSession.room} · {selSession.speakers}
|
||||
</div>
|
||||
@@ -123,9 +126,18 @@ export function Scan() {
|
||||
<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>
|
||||
<Avatar name={connectTarget.contact.full_name} id={connectTarget.contact.email} size={72} fs={26} />
|
||||
<h3 style={{ marginTop: 12 }}>{connectTarget.contact.full_name}</h3>
|
||||
{connectTarget.contact.registration_type && (
|
||||
<span className={`pill reg-${connectTarget.contact.registration_type}`} style={{ marginTop: 8 }}>
|
||||
{connectTarget.contact.registration_type.replace('_', ' ')}
|
||||
</span>
|
||||
)}
|
||||
{connectTarget.contact.linkedin_url && (
|
||||
<div className="sub" style={{ marginTop: 6 }}>
|
||||
<a href={connectTarget.contact.linkedin_url} target="_blank" rel="noreferrer">LinkedIn</a>
|
||||
</div>
|
||||
)}
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<button className="btn primary" disabled={busy} onClick={confirmConnect}>
|
||||
{busy ? 'Sending…' : 'Connect 🤝'}
|
||||
|
||||
Reference in new issue
Block a user