Registration optionset + speaker auto-promote + welcome check-in
- registrations.type is now a Postgres ENUM (registration_type) - session_speakers trigger auto-promotes attendee -> speaker (never overrides staff/sponsor) - new welcome_checkin RPC: staff marks an attendee present at the event - admin Registrations: QR token is final (no reset); failed sponsor change opens in-place sponsor lookup - Convivo Home: Now/Next cards always render; red pending-material pill + popup for speakers - Convivo Agenda: speakers can delete their material to re-upload - Convivo Scan: staff Session/Welcome check-in toggle (uiverse switch) - seed: staff (Bruno/Rita) get a password so staff QR login works after reset
This commit is contained in:
1 parent
1bffae9777
commit
1cbbd1b529
16 files changed
+730
-142
No files matched your search
@@ -14,6 +14,7 @@ import type {
|
||||
Registration,
|
||||
Session,
|
||||
Slot,
|
||||
WelcomeCheckinResult,
|
||||
} from './types';
|
||||
|
||||
export class ApiError extends Error {}
|
||||
@@ -157,6 +158,12 @@ export async function checkinAttendee(sessionId: string, attendeeQr: string): Pr
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
/** Staff welcome check-in: mark an attendee present at the event (no session). */
|
||||
export async function welcomeCheckin(attendeeQr: string): Promise<WelcomeCheckinResult> {
|
||||
const rows = await rpc<WelcomeCheckinResult[]>('welcome_checkin', { p_attendee_qr: attendeeQr });
|
||||
return rows[0];
|
||||
}
|
||||
|
||||
export async function getMyFeedback(email: string): Promise<Feedback[]> {
|
||||
const { data, error } = await supabase.from('feedback').select('*').eq('contact_email', email);
|
||||
if (error) throw new ApiError(error.message);
|
||||
@@ -212,3 +219,20 @@ export async function uploadSessionMaterial(sessionId: string, file: File): Prom
|
||||
if (dbErr) throw new ApiError(dbErr.message);
|
||||
return path;
|
||||
}
|
||||
|
||||
/** Remove a session's material (storage object + clear material_path). Speakers
|
||||
* can delete their own material to re-upload; the path is cleared via the
|
||||
* `set_session_material` RPC (sessions is admin-write only). */
|
||||
export async function removeSessionMaterial(sessionId: string): Promise<void> {
|
||||
const { data } = await supabase.from('sessions').select('material_path').eq('id', sessionId).maybeSingle();
|
||||
const path = (data as Session | null)?.material_path;
|
||||
if (path) {
|
||||
const { error: rmErr } = await supabase.storage.from('materials').remove([path]);
|
||||
if (rmErr) throw new ApiError(rmErr.message);
|
||||
}
|
||||
const { error: dbErr } = await supabase.rpc('set_session_material', {
|
||||
p_session_id: sessionId,
|
||||
p_material_path: null,
|
||||
});
|
||||
if (dbErr) throw new ApiError(dbErr.message);
|
||||
}
|
||||
@@ -159,6 +159,13 @@ export interface CheckinResult {
|
||||
already: boolean;
|
||||
}
|
||||
|
||||
/** Result of a staff welcome check-in (marks an attendee present at the event). */
|
||||
export interface WelcomeCheckinResult {
|
||||
attendee_email: string;
|
||||
attendee_name: string;
|
||||
already: boolean;
|
||||
}
|
||||
|
||||
export interface FeedbackResult {
|
||||
feedback_id: string;
|
||||
points: number;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
getMyCheckins,
|
||||
getMyPreferences,
|
||||
getMySpeakerSessions,
|
||||
removeSessionMaterial,
|
||||
sessionMaterialUrl,
|
||||
setPreference,
|
||||
uploadSessionMaterial,
|
||||
@@ -114,6 +115,19 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteMaterial() {
|
||||
if (!selected) return;
|
||||
if (!confirm('Remove this material? You can upload a new one.')) return;
|
||||
try {
|
||||
await removeSessionMaterial(selected.id);
|
||||
toast('Material removed', 'ok');
|
||||
setSelected(null);
|
||||
reload();
|
||||
} catch (err) {
|
||||
toast(err instanceof Error ? err.message : 'Could not remove material', 'err');
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="row between">
|
||||
@@ -222,6 +236,12 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
📎 Download material
|
||||
</a>
|
||||
)}
|
||||
{/* Speakers can remove their own material to re-upload. */}
|
||||
{selISpeaker && selected.material_path && (
|
||||
<button className="btn danger" onClick={handleDeleteMaterial}>
|
||||
🗑 Remove material
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { getMyCheckins, getMyPreferences } from '../lib/api';
|
||||
import { getMyCheckins, getMyPreferences, getMySpeakerSessions } from '../lib/api';
|
||||
import { fmtRange, greeting, slotStatus } from '../lib/time';
|
||||
import type { Preference } from '../lib/types';
|
||||
import { Empty, Spinner } from '../components/ui';
|
||||
import type { Preference, Session } from '../lib/types';
|
||||
import { Empty, Sheet, Spinner } from '../components/ui';
|
||||
|
||||
export function Home({ go }: { go: (tab: string) => void }) {
|
||||
const { contact, registration } = useAuth();
|
||||
const { event, slots, sessionById, now, loading } = useEvent();
|
||||
const [prefs, setPrefs] = useState<Preference[]>([]);
|
||||
const [checkins, setCheckins] = useState<string[]>([]);
|
||||
const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]);
|
||||
const [materialSheetOpen, setMaterialSheetOpen] = useState(false);
|
||||
|
||||
const email = contact?.email ?? '';
|
||||
|
||||
@@ -18,10 +20,15 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
let active = true;
|
||||
(async () => {
|
||||
try {
|
||||
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins(email)]);
|
||||
const [p, c, sp] = await Promise.all([
|
||||
getMyPreferences(),
|
||||
getMyCheckins(email),
|
||||
getMySpeakerSessions(email),
|
||||
]);
|
||||
if (!active) return;
|
||||
setPrefs(p);
|
||||
setCheckins(c);
|
||||
setMySpeakerSessions(sp);
|
||||
} catch {
|
||||
/* non-fatal */
|
||||
}
|
||||
@@ -60,6 +67,11 @@ 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;
|
||||
|
||||
// Sessions the signed-in contact speaks in that still have no material uploaded.
|
||||
const pendingMaterial = mySpeakerSessions
|
||||
.map((id) => sessionById.get(id))
|
||||
.filter((s): s is Session => !!s && !s.material_path);
|
||||
|
||||
const firstName = contact.full_name.split(' ')[0];
|
||||
|
||||
return (
|
||||
@@ -69,37 +81,60 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
<div className="h1">{greeting(now)}, {firstName} 👋</div>
|
||||
<div className="muted small">{event.name}</div>
|
||||
</div>
|
||||
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {points}</div>
|
||||
<div className="row" style={{ gap: 8 }}>
|
||||
{pendingMaterial.length > 0 && (
|
||||
<div className="material-pill" onClick={() => setMaterialSheetOpen(true)}>
|
||||
📎 {pendingMaterial.length}
|
||||
</div>
|
||||
)}
|
||||
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {points}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{nowSession && current && (
|
||||
{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>
|
||||
{nowSession ? (
|
||||
<>
|
||||
<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>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className="pill amber" style={{ marginTop: 10 }}>Show your QR to staff to check in</span>
|
||||
<div className="muted small" style={{ marginTop: 10 }}>
|
||||
No pick yet — tap a session in the Agenda to choose.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{nextSession && next && (
|
||||
{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>
|
||||
{nextSession ? (
|
||||
<>
|
||||
<div className="h2" style={{ marginTop: 10 }}>{nextSession.title}</div>
|
||||
<div className="muted small" style={{ marginTop: 3 }}>
|
||||
{nextSession.room} · {nextSession.speakers}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="muted small" style={{ marginTop: 10 }}>
|
||||
No pick yet — tap a session in the Agenda to choose.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -145,6 +180,38 @@ export function Home({ go }: { go: (tab: string) => void }) {
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ height: 8 }} />
|
||||
|
||||
{/* Pending material popup (speakers only, when a session is missing its attachment) */}
|
||||
<Sheet open={materialSheetOpen} onClose={() => setMaterialSheetOpen(false)}>
|
||||
<h3 style={{ marginBottom: 4 }}>📎 Pending material</h3>
|
||||
<div className="muted small" style={{ marginBottom: 14 }}>
|
||||
The following sessions are pending to upload their attachments.
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{pendingMaterial.map((s) => {
|
||||
const slot = slots.find((x) => x.slot.id === s.slot_id)?.slot;
|
||||
return (
|
||||
<button
|
||||
key={s.id}
|
||||
className="pick-chip"
|
||||
onClick={() => {
|
||||
setMaterialSheetOpen(false);
|
||||
go('agenda');
|
||||
}}
|
||||
>
|
||||
<span className="t">{slot ? fmtRange(slot) : ''}</span>
|
||||
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
|
||||
{s.title}
|
||||
</span>
|
||||
<span className="muted small">{s.room}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<button className="btn primary" style={{ marginTop: 16 }} onClick={() => setMaterialSheetOpen(false)}>
|
||||
Got it
|
||||
</button>
|
||||
</Sheet>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { checkinAttendee, createConnectionRequest, lanyardLookup } from '../lib/api';
|
||||
import { checkinAttendee, createConnectionRequest, lanyardLookup, welcomeCheckin } from '../lib/api';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { CheckinResult, PublicContact } from '../lib/types';
|
||||
import type { CheckinResult, PublicContact, WelcomeCheckinResult } from '../lib/types';
|
||||
import { Avatar, Scanner, Sheet, Spinner } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
@@ -13,8 +13,10 @@ export function Scan() {
|
||||
const isStaff = !!contact?.is_admin;
|
||||
const [mode, setMode] = useState<'attendee' | 'staff'>(isStaff ? 'staff' : 'attendee');
|
||||
const [sessionId, setSessionId] = useState<string>('');
|
||||
const [welcomeMode, setWelcomeMode] = useState(false);
|
||||
const [connectTarget, setConnectTarget] = useState<{ contact: PublicContact; qr: string } | null>(null);
|
||||
const [checkin, setCheckin] = useState<CheckinResult | null>(null);
|
||||
const [welcome, setWelcome] = useState<WelcomeCheckinResult | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const { toast } = useToast();
|
||||
|
||||
@@ -42,12 +44,17 @@ export function Scan() {
|
||||
setBusy(true);
|
||||
try {
|
||||
if (activeStaff) {
|
||||
if (!sessionId) {
|
||||
toast('Pick a session first', 'err');
|
||||
return;
|
||||
if (welcomeMode) {
|
||||
const res = await welcomeCheckin(token);
|
||||
setWelcome(res);
|
||||
} else {
|
||||
if (!sessionId) {
|
||||
toast('Pick a session first', 'err');
|
||||
return;
|
||||
}
|
||||
const res = await checkinAttendee(sessionId, token);
|
||||
setCheckin(res);
|
||||
}
|
||||
const res = await checkinAttendee(sessionId, token);
|
||||
setCheckin(res);
|
||||
} else {
|
||||
const found = await lanyardLookup(token);
|
||||
if (!found) {
|
||||
@@ -103,22 +110,40 @@ export function Scan() {
|
||||
|
||||
{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)}>
|
||||
{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>
|
||||
<div className="row between" style={{ marginBottom: 10 }}>
|
||||
<span className="muted small" style={{ fontWeight: 700 }}>Check-in type</span>
|
||||
<label className="uiverse-toggle" title={welcomeMode ? 'Welcome check-in' : 'Session check-in'}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={welcomeMode}
|
||||
onChange={(e) => setWelcomeMode(e.target.checked)}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
{welcomeMode ? (
|
||||
<div className="muted small" style={{ padding: '10px 12px', background: 'var(--surface)', border: '1px solid var(--line)', borderRadius: 12 }}>
|
||||
🏷 <b>Welcome check-in</b> — marks the attendee present at the event.
|
||||
</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>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
</select>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Scanner onResult={handleScan} label={activeStaff ? 'Point at an attendee’s lanyard' : 'Point at a peer’s lanyard'} />
|
||||
{busy && <div className="center"><Spinner /></div>}
|
||||
{activeStaff && selSession && (
|
||||
{activeStaff && !welcomeMode && selSession && (
|
||||
<div className="muted small" style={{ textAlign: 'center', opacity: 0.6 }}>
|
||||
{selSession.room} · {selSession.speakers}
|
||||
</div>
|
||||
@@ -172,6 +197,23 @@ export function Scan() {
|
||||
</div>
|
||||
)}
|
||||
</Sheet>
|
||||
|
||||
{/* Welcome check-in result sheet */}
|
||||
<Sheet open={!!welcome} onClose={() => setWelcome(null)}>
|
||||
{welcome && (
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<div style={{ fontSize: 52 }}>{welcome.already ? '⚠️' : '👋'}</div>
|
||||
<h3 style={{ marginTop: 10 }}>{welcome.attendee_name}</h3>
|
||||
<div className="sub">{welcome.already ? 'Already checked in to the event' : 'Welcome to the event!'}</div>
|
||||
<div style={{ marginTop: 14 }}>
|
||||
<span className="pill green">✓ Checked in</span>
|
||||
</div>
|
||||
<button className="btn primary" style={{ marginTop: 18 }} onClick={() => setWelcome(null)}>
|
||||
Scan next
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</Sheet>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -165,6 +165,11 @@ textarea.input { resize: none; min-height: 96px; }
|
||||
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;
|
||||
}
|
||||
.material-pill {
|
||||
display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px;
|
||||
background: rgba(213,0,0,.1); border: 1px solid rgba(213,0,0,.4);
|
||||
color: #d50000; 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 {
|
||||
@@ -215,6 +220,44 @@ textarea.input { resize: none; min-height: 96px; }
|
||||
.sheet h3 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
|
||||
.sheet .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
|
||||
|
||||
/* ---------- Scan: uiverse check-in type toggle (Shoh2008 / brown-bulldog-12) ---------- */
|
||||
.uiverse-toggle { display: inline-flex; }
|
||||
.uiverse-toggle input[type="checkbox"] {
|
||||
--size: 58px;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: var(--size);
|
||||
height: calc(var(--size) / 2);
|
||||
background-color: var(--surface);
|
||||
border: 3px solid var(--line);
|
||||
border-radius: 30px 100px 100px 100px;
|
||||
box-shadow: 0 6px 14px rgba(66,60,60,.14);
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
transition: all .4s;
|
||||
}
|
||||
.uiverse-toggle input[type="checkbox"]::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: calc(var(--size) / 2 - 8px);
|
||||
height: calc(var(--size) / 2 - 8px);
|
||||
left: 3px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%) scale(1);
|
||||
border-radius: 50%;
|
||||
background-color: var(--muted);
|
||||
transition: all .4s;
|
||||
}
|
||||
.uiverse-toggle input[type="checkbox"]:checked {
|
||||
background-color: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.uiverse-toggle input[type="checkbox"]:checked::before {
|
||||
left: calc(100% - calc(var(--size) / 2 - 8px) - 3px);
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
/* ---------- Connections ---------- */
|
||||
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 4px; }
|
||||
.seg button {
|
||||
|
||||
Reference in new issue
Block a user