- contacts.password now auto-syncs to auth.users.encrypted_password via trg_contact_password_sync, so setting a password on the contact row in the Supabase UI makes it work with signInWithPassword immediately (fixes staff like Bruno not being able to log in with a UI-set password). One-time reconciliation in the migration. - Staff excluded from the leaderboard: _sync_leaderboard skips/removes staff rows, get_leaderboard() filters type='staff', seed no longer inserts staff. Affects the attendee Leaderboard and the admin Dashboard 'Top points'. - Home/Agenda/Profile identical for all roles: Home quick-action always 'Scan & connect' (no 'Check-in' relabel), footer role badge removed, tab label always 'Scan' (staff keep check-in via the Scan screen mode toggle). - Profile: removed the duplicate Staff pill (type pill already shows Staff). - Agenda session sheet: 'Download material' moved to the bottom of the button stack with spacing. - Docs updated (schema, rpcs, seed, screens, architecture, next-steps). Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
151 lines
5.3 KiB
TypeScript
151 lines
5.3 KiB
TypeScript
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 { Empty, 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 email = contact?.email ?? '';
|
|
|
|
useEffect(() => {
|
|
let active = true;
|
|
(async () => {
|
|
try {
|
|
const [p, c] = await Promise.all([getMyPreferences(), getMyCheckins(email)]);
|
|
if (!active) return;
|
|
setPrefs(p);
|
|
setCheckins(c);
|
|
} catch {
|
|
/* non-fatal */
|
|
}
|
|
})();
|
|
return () => {
|
|
active = false;
|
|
};
|
|
}, [email]);
|
|
|
|
if (loading || !contact) {
|
|
return (
|
|
<section className="screen">
|
|
<div className="center" style={{ flex: 1 }}>
|
|
<Spinner />
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
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 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 = 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">{event.name}</div>
|
|
</div>
|
|
<div className="points-pill" onClick={() => go('leaderboard')}>⚡ {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>
|
|
<a className="muted small link" onClick={() => go('agenda')}>tap to change</a>
|
|
</div>
|
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
{[
|
|
{ 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' }}>
|
|
{r.session ? r.session.title : 'No pick yet'}
|
|
</span>
|
|
{r.session && <span className="muted small">{r.session.room}</span>}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="qa-grid">
|
|
<div className="qa" onClick={() => go('scan')}>
|
|
<span className="ico">📷</span>
|
|
<span className="lbl">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 }} />
|
|
</section>
|
|
);
|
|
}
|