- 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 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]>
154 lines
5.5 KiB
TypeScript
154 lines
5.5 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 { Avatar, 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 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');
|
|
|
|
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>
|
|
<span className="muted small">tap to change</span>
|
|
</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>
|
|
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
|
|
{s ? s.title : 'No pick yet'}
|
|
</span>
|
|
{s && <span className="muted small">{s.room}</span>}
|
|
</button>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="qa-grid">
|
|
<div className="qa" onClick={() => go('scan')}>
|
|
<span className="ico">📷</span>
|
|
<span className="lbl">{isStaff ? 'Check-in' : '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 }} />
|
|
<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>
|
|
</section>
|
|
);
|
|
}
|