Fixes & Refinements: QR token on registration, role caps, connection detail + red dot, admin schedule/sponsors
Datamodel: - Move qr_token from contacts to registrations (per event); new migration 20260826000000. lanyard_lookup / create_connection_request / checkin_attendee resolve via registrations + active event. - reset_qr_token -> reset_registration_qr_token (fixes ambiguous 'email' col). - upsert_contact drops the token arg; create_registration generates + syncs it. - Pretix sync writes the token to the registration (keeps it on re-sync). Registration types: - Distinct pill colors; red reserved for Staff (both apps). - Roles capitalized everywhere (Attendee/Speaker/Sponsor/Staff); 'Attendee' hidden only at the Home footer. - Reset-token button moved from Contacts to Registrations (per registration). Sessions (APPE Admin): - Slot types capitalized; material submitted/not-submitted state. - Speaker selection = multi-select search dropdown. - Fix 'a session must have a speaker' on edit (diff-based setSessionSpeakers) and the file-upload bug (speaker save no longer aborts first). APPE Admin: - Sponsors contact lookup = search field (filter + pick). Convivo App: - Other people's QR codes hidden; connection detail sheet shows public info + points. - Connect red dot recalculates immediately on accept/decline/send. - 'My picks today' = 2 rows (current + next); 'tap to change' links to Agenda. Docs updated across backend + frontend.
This commit is contained in:
1 parent
005f1d404f
commit
b52d8ab007
30 files changed
+1083
-232
No files matched your search
@@ -46,6 +46,13 @@ function Shell() {
|
||||
// Keep the Connect red-dot fresh: poll every 5s while visible.
|
||||
usePolling(() => void loadPending(), 5000, !!email);
|
||||
|
||||
// Recalc immediately when a connection is accepted/declined/sent.
|
||||
useEffect(() => {
|
||||
const onChanged = () => void loadPending();
|
||||
window.addEventListener('connections-changed', onChanged);
|
||||
return () => window.removeEventListener('connections-changed', onChanged);
|
||||
}, [loadPending]);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="app">
|
||||
|
||||
@@ -41,3 +41,8 @@ export function greeting(now: Date): string {
|
||||
if (h < 18) return 'Good afternoon';
|
||||
return 'Good evening';
|
||||
}
|
||||
|
||||
/** "lunch_break" → "Lunch Break" (capitalize each word). */
|
||||
export function capWords(s: string): string {
|
||||
return s.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
@@ -10,11 +10,12 @@ export interface Contact {
|
||||
show_email: boolean;
|
||||
show_linkedin: boolean;
|
||||
is_admin: boolean;
|
||||
qr_token: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
/** The signed-in contact's registration for the active event. */
|
||||
/** The signed-in contact's registration for the active event.
|
||||
* The QR token lives here (per event, generated by Pretix) and doubles as
|
||||
* the login password. */
|
||||
export interface Registration {
|
||||
id: string;
|
||||
event_id: string;
|
||||
@@ -22,6 +23,7 @@ export interface Registration {
|
||||
type: RegistrationType;
|
||||
checked_in: boolean;
|
||||
points: number;
|
||||
qr_token: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { acceptConnection, getMyConnections, getPublicContacts, rejectConnection } from '../lib/api';
|
||||
import { acceptConnection, getLeaderboard, getMyConnections, getPublicContacts, rejectConnection } from '../lib/api';
|
||||
import { usePolling } from '../lib/usePolling';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { Connection, PublicContact } from '../lib/types';
|
||||
import { Avatar, Empty, Spinner } from '../components/ui';
|
||||
import { Avatar, Empty, Sheet, Spinner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
export function Connections() {
|
||||
@@ -11,14 +12,17 @@ export function Connections() {
|
||||
const [tab, setTab] = useState<'mine' | 'req'>('mine');
|
||||
const [conns, setConns] = useState<Connection[]>([]);
|
||||
const [people, setPeople] = useState<Map<string, PublicContact>>(new Map());
|
||||
const [points, setPoints] = useState<Map<string, number>>(new Map());
|
||||
const [detail, setDetail] = useState<{ email: string; status: Connection['status'] } | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const { toast } = useToast();
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const [c, p] = await Promise.all([getMyConnections(), getPublicContacts()]);
|
||||
const [c, p, lb] = await Promise.all([getMyConnections(), getPublicContacts(), getLeaderboard()]);
|
||||
setConns(c);
|
||||
setPeople(new Map(p.map((x) => [x.email, x])));
|
||||
setPoints(new Map(lb.map((x) => [x.contact_email, x.points])));
|
||||
} catch {
|
||||
/* non-fatal */
|
||||
} finally {
|
||||
@@ -37,6 +41,7 @@ export function Connections() {
|
||||
const me = contact.email;
|
||||
const nameOf = (email: string) => people.get(email)?.full_name ?? '…';
|
||||
const typeOf = (email: string) => people.get(email)?.registration_type ?? null;
|
||||
const pointsOf = (email: string) => points.get(email) ?? 0;
|
||||
|
||||
const accepted = conns.filter((c) => c.status === 'accepted');
|
||||
const incoming = conns.filter((c) => c.status === 'pending' && c.to_email === me);
|
||||
@@ -47,6 +52,7 @@ export function Connections() {
|
||||
if (accept) await acceptConnection(id);
|
||||
else await rejectConnection(id);
|
||||
toast(accept ? 'Connected! +5 pts 🤝' : 'Request declined', accept ? 'ok' : '');
|
||||
window.dispatchEvent(new Event('connections-changed'));
|
||||
await load();
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Could not update request', 'err');
|
||||
@@ -80,11 +86,13 @@ export function Connections() {
|
||||
accepted.map((c) => {
|
||||
const otherEmail = c.from_email === me ? c.to_email : c.from_email;
|
||||
return (
|
||||
<div className="conn" key={c.id}>
|
||||
<div className="conn clickable" key={c.id} onClick={() => setDetail({ email: otherEmail, status: c.status })}>
|
||||
<Avatar name={nameOf(otherEmail)} id={otherEmail} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(otherEmail)}</div>
|
||||
{typeOf(otherEmail) && <div className="meta">{typeOf(otherEmail)!.replace('_', ' ')}</div>}
|
||||
{typeOf(otherEmail) && (
|
||||
<div className="meta">{capWords(typeOf(otherEmail)!)}</div>
|
||||
)}
|
||||
</div>
|
||||
<span className="pill green">Connected</span>
|
||||
</div>
|
||||
@@ -102,10 +110,15 @@ 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_email)} id={c.from_email} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(c.from_email)}</div>
|
||||
{typeOf(c.from_email) && <div className="meta">{typeOf(c.from_email)!.replace('_', ' ')}</div>}
|
||||
<div className="clickable" style={{ display: 'flex', alignItems: 'center', gap: 10, flex: 1 }}
|
||||
onClick={() => setDetail({ email: c.from_email, status: c.status })}>
|
||||
<Avatar name={nameOf(c.from_email)} id={c.from_email} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(c.from_email)}</div>
|
||||
{typeOf(c.from_email) && (
|
||||
<div className="meta">{capWords(typeOf(c.from_email)!)}</div>
|
||||
)}
|
||||
</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>
|
||||
@@ -117,11 +130,13 @@ export function Connections() {
|
||||
<div>
|
||||
<div className="muted small" style={{ marginBottom: 8, fontWeight: 700 }}>Sent</div>
|
||||
{outgoing.map((c) => (
|
||||
<div className="conn" key={c.id}>
|
||||
<div className="conn clickable" key={c.id} onClick={() => setDetail({ email: c.to_email, status: c.status })}>
|
||||
<Avatar name={nameOf(c.to_email)} id={c.to_email} size={44} />
|
||||
<div className="grow">
|
||||
<div className="name">{nameOf(c.to_email)}</div>
|
||||
{typeOf(c.to_email) && <div className="meta">{typeOf(c.to_email)!.replace('_', ' ')}</div>}
|
||||
{typeOf(c.to_email) && (
|
||||
<div className="meta">{capWords(typeOf(c.to_email)!)}</div>
|
||||
)}
|
||||
</div>
|
||||
<span className="pill amber">Pending</span>
|
||||
</div>
|
||||
@@ -130,6 +145,32 @@ export function Connections() {
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{detail && (() => {
|
||||
const p = people.get(detail.email);
|
||||
const t = p?.registration_type ?? null;
|
||||
return (
|
||||
<Sheet open onClose={() => setDetail(null)}>
|
||||
<div className="center" style={{ flexDirection: 'column', gap: 10, padding: '8px 0 20px' }}>
|
||||
<Avatar name={p?.full_name ?? '…'} id={detail.email} size={72} />
|
||||
<div className="h2" style={{ textAlign: 'center' }}>{p?.full_name ?? '…'}</div>
|
||||
<div className="row" style={{ justifyContent: 'center', gap: 8 }}>
|
||||
{t && <span className={`pill reg-${t}`}>{capWords(t)}</span>}
|
||||
<span className="pill violet">⚡ {pointsOf(detail.email)} pts</span>
|
||||
</div>
|
||||
{p?.linkedin_url && (
|
||||
<a className="link" href={p.linkedin_url} target="_blank" rel="noreferrer">
|
||||
{p.linkedin_url.replace(/^https?:\/\//, '')}
|
||||
</a>
|
||||
)}
|
||||
{p?.show_email && <div className="muted small">{detail.email}</div>}
|
||||
<div className="muted small">
|
||||
{detail.status === 'accepted' ? 'Connected' : detail.status === 'pending' ? 'Request pending' : 'Request declined'}
|
||||
</div>
|
||||
</div>
|
||||
</Sheet>
|
||||
);
|
||||
})()}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ 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 { capWords, fmtRange, greeting, slotStatus } from '../lib/time';
|
||||
import type { Preference } from '../lib/types';
|
||||
import { Avatar, Empty, Spinner } from '../components/ui';
|
||||
|
||||
@@ -107,22 +107,23 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
<div>
|
||||
<div className="row between" style={{ marginBottom: 9 }}>
|
||||
<span className="h2">My picks today</span>
|
||||
<span className="muted small">tap to change</span>
|
||||
<a className="muted small link" onClick={() => go('agenda')}>tap to change</a>
|
||||
</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>
|
||||
{[
|
||||
{ label: 'Now', slot: current?.slot, session: nowSession },
|
||||
{ label: 'Next', slot: next?.slot, session: nextSession },
|
||||
]
|
||||
.filter((r) => r.slot)
|
||||
.map((r) => (
|
||||
<button key={r.label} className="pick-chip" onClick={() => go('agenda')}>
|
||||
<span className="t">{fmtRange(r.slot!)}</span>
|
||||
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
|
||||
{s ? s.title : 'No pick yet'}
|
||||
{r.session ? r.session.title : 'No pick yet'}
|
||||
</span>
|
||||
{s && <span className="muted small">{s.room}</span>}
|
||||
{r.session && <span className="muted small">{r.session.room}</span>}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -145,9 +146,11 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ height: 8 }} />
|
||||
<div className="muted small" style={{ textAlign: 'center', opacity: 0.5 }}>
|
||||
<Avatar name={contact.full_name} id={contact.email} size={22} fs={9} /> {registration?.type.replace('_', ' ') ?? ''}
|
||||
</div>
|
||||
{registration && registration.type !== 'attendee' && (
|
||||
<div className="muted small" style={{ textAlign: 'center', opacity: 0.5 }}>
|
||||
<Avatar name={contact.full_name} id={contact.email} size={22} fs={9} /> {capWords(registration.type)}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import { lanyardLookup } from '../lib/api';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { PublicContact } from '../lib/types';
|
||||
import { Avatar, Scanner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
@@ -88,7 +89,7 @@ export function Login() {
|
||||
<div>
|
||||
<div className="h2">{found ? found.full_name : 'Lanyard found'}</div>
|
||||
<div className="muted small">
|
||||
{found ? (found.registration_type ? found.registration_type.replace('_', ' ') : 'Confirm it’s you') : 'Confirm it’s you'}
|
||||
{found ? (found.registration_type ? capWords(found.registration_type) : 'Confirm it’s you') : 'Confirm it’s you'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { getMyPointsLog } from '../lib/api';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { PointsLogRow } from '../lib/types';
|
||||
import { Avatar, QrImage, Spinner } from '../components/ui';
|
||||
|
||||
@@ -49,7 +50,7 @@ export function Profile() {
|
||||
<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 }}>
|
||||
{registration && <span className={`pill reg-${registration.type}`}>{registration.type.replace('_', ' ')}</span>}
|
||||
{registration && <span className={`pill reg-${registration.type}`}>{capWords(registration.type)}</span>}
|
||||
{contact.is_admin && <span className="pill admin">staff</span>}
|
||||
<span className="pill amber">⚡ {points} pts</span>
|
||||
</div>
|
||||
@@ -57,8 +58,8 @@ export function Profile() {
|
||||
|
||||
<div className="card qr-wrap">
|
||||
<div className="h2">My QR code</div>
|
||||
{contact.qr_token ? (
|
||||
<QrImage value={contact.qr_token} size={180} />
|
||||
{registration?.qr_token ? (
|
||||
<QrImage value={registration.qr_token} size={180} />
|
||||
) : (
|
||||
<div className="muted small">No QR token assigned.</div>
|
||||
)}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { checkinAttendee, createConnectionRequest, lanyardLookup } from '../lib/api';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { CheckinResult, PublicContact } from '../lib/types';
|
||||
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
@@ -74,6 +75,7 @@ export function Scan() {
|
||||
if (conn.status === 'accepted') toast('You’re connected! 🤝', 'ok');
|
||||
else if (conn.status === 'pending') toast('Connection request sent', 'ok');
|
||||
else toast('Request already resolved');
|
||||
window.dispatchEvent(new Event('connections-changed'));
|
||||
setConnectTarget(null);
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Could not send request', 'err');
|
||||
@@ -130,7 +132,7 @@ export function Scan() {
|
||||
<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('_', ' ')}
|
||||
{capWords(connectTarget.contact.registration_type)}
|
||||
</span>
|
||||
)}
|
||||
{connectTarget.contact.linkedin_url && (
|
||||
|
||||
@@ -59,7 +59,7 @@ body {
|
||||
/* registration types */
|
||||
.pill.reg-attendee { background: rgba(148,163,184,.14); border-color: rgba(148,163,184,.4); color: #64748b; }
|
||||
.pill.reg-speaker { background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.4); color: #6d28d9; }
|
||||
.pill.reg-staff { background: rgba(32,178,170,.13); border-color: rgba(32,178,170,.4); color: #0f766e; }
|
||||
.pill.reg-staff { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.4); color: #b91c1c; }
|
||||
.pill.reg-sponsor { background: rgba(234,88,12,.13); border-color: rgba(234,88,12,.4); color: #c2410c; }
|
||||
/* slot types */
|
||||
.pill.slot-type-session { background: rgba(14,165,233,.12); border-color: rgba(14,165,233,.4); color: #0369a1; }
|
||||
@@ -279,3 +279,5 @@ textarea.input { resize: none; min-height: 96px; }
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.center { display: flex; align-items: center; justify-content: center; }
|
||||
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
||||
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
|
||||
.clickable { cursor: pointer; }
|
||||
Reference in new issue
Block a user