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,23 +1,23 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
getAllCheckins,
|
||||
getAllConnections,
|
||||
getAllContacts,
|
||||
getAllFeedback,
|
||||
getAllProfiles,
|
||||
getAllSessions,
|
||||
getActiveEvent,
|
||||
getLeaderboard,
|
||||
} from '../lib/api';
|
||||
import type { Checkin, Connection, Feedback, LeaderboardRow, Profile, Session } from '../lib/types';
|
||||
import type { Checkin, Connection, Contact, Event, Feedback, LeaderboardRow } from '../lib/types';
|
||||
import { Avatar, Empty, Spinner } from '../components/ui';
|
||||
|
||||
type View = 'dashboard' | 'attendees' | 'schedule' | 'activity';
|
||||
import type { View } from '../App';
|
||||
|
||||
export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
const [profiles, setProfiles] = useState<Profile[] | null>(null);
|
||||
const [event, setEvent] = useState<Event | null>(null);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [contacts, setContacts] = useState<Contact[]>([]);
|
||||
const [checkins, setCheckins] = useState<Checkin[]>([]);
|
||||
const [connections, setConnections] = useState<Connection[]>([]);
|
||||
const [feedback, setFeedback] = useState<Feedback[]>([]);
|
||||
const [sessions, setSessions] = useState<Session[]>([]);
|
||||
const [lb, setLb] = useState<LeaderboardRow[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
@@ -25,21 +25,27 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
try {
|
||||
const [p, c, conn, f, s, l] = await Promise.all([
|
||||
getAllProfiles(),
|
||||
const ev = await getActiveEvent();
|
||||
if (cancelled) return;
|
||||
setEvent(ev);
|
||||
if (!ev) {
|
||||
setLoaded(true);
|
||||
return;
|
||||
}
|
||||
const [c, ck, conn, f, l] = await Promise.all([
|
||||
getAllContacts(),
|
||||
getAllCheckins(),
|
||||
getAllConnections(),
|
||||
getAllFeedback(),
|
||||
getAllSessions(),
|
||||
getLeaderboard(),
|
||||
]);
|
||||
if (cancelled) return;
|
||||
setProfiles(p);
|
||||
setCheckins(c);
|
||||
setConnections(conn);
|
||||
setFeedback(f);
|
||||
setSessions(s);
|
||||
setLb(l);
|
||||
setContacts(c);
|
||||
setCheckins(ck.filter((x) => x.event_id === ev.id));
|
||||
setConnections(conn.filter((x) => x.event_id === ev.id));
|
||||
setFeedback(f.filter((x) => x.event_id === ev.id));
|
||||
setLb(l.filter((x) => x.event_id === ev.id));
|
||||
setLoaded(true);
|
||||
} catch (e) {
|
||||
if (!cancelled) setError(e instanceof Error ? e.message : 'Failed to load');
|
||||
}
|
||||
@@ -49,19 +55,40 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const nameOf = useMemo(() => {
|
||||
const m = new Map(contacts.map((c) => [c.email, c.full_name]));
|
||||
return (email: string) => m.get(email) ?? email;
|
||||
}, [contacts]);
|
||||
|
||||
if (error) return <Empty icon="⚠️" text={error} />;
|
||||
if (!profiles)
|
||||
if (!loaded)
|
||||
return (
|
||||
<div className="loading-screen">
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
|
||||
const attendees = profiles.filter((p) => p.role === 'attendee');
|
||||
const accepted = connections.filter((c) => c.status === 'accepted').length;
|
||||
const avgRating = feedback.length
|
||||
? (feedback.reduce((s, f) => s + f.rating, 0) / feedback.length).toFixed(1)
|
||||
: '—';
|
||||
if (!event) {
|
||||
return (
|
||||
<div>
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1>Dashboard</h1>
|
||||
<div className="sub">Live overview of the event.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card">
|
||||
<Empty icon="📅" text="No active event. Create one and set it active in the Events view." />
|
||||
<div style={{ textAlign: 'center', marginTop: 12 }}>
|
||||
<button className="btn primary" onClick={() => onNavigate('events')}>
|
||||
Go to Events →
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const top = lb.slice(0, 5);
|
||||
|
||||
return (
|
||||
@@ -69,35 +96,49 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1>Dashboard</h1>
|
||||
<div className="sub">Live overview of the event.</div>
|
||||
<div className="sub">Live overview of the active event.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card event-card">
|
||||
<div className="row between" style={{ flexWrap: 'wrap', gap: 12 }}>
|
||||
<div>
|
||||
<div className="event-name">{event.name}</div>
|
||||
<div className="muted small">
|
||||
{fmtDate(event.start_date)}
|
||||
{event.end_date !== event.start_date ? ` – ${fmtDate(event.end_date)}` : ''}
|
||||
{event.location ? ` · ${event.location}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<span className="pill green">● Active</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="stat-grid">
|
||||
<div className="stat">
|
||||
<span className="ico">👥</span>
|
||||
<span className="val">{attendees.length}</span>
|
||||
<span className="lbl">Attendees</span>
|
||||
<span className="ico">🎟️</span>
|
||||
<span className="val">{event.num_registrations}</span>
|
||||
<span className="lbl">Registrations</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="ico">✅</span>
|
||||
<span className="val">{checkins.length}</span>
|
||||
<span className="lbl">Check-ins</span>
|
||||
<span className="val">{event.num_checked_in_registrations}</span>
|
||||
<span className="lbl">Checked in</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="ico">🤝</span>
|
||||
<span className="val">{accepted}</span>
|
||||
<span className="lbl">Connections accepted</span>
|
||||
<span className="ico">🗓️</span>
|
||||
<span className="val">{event.num_sessions}</span>
|
||||
<span className="lbl">Sessions</span>
|
||||
</div>
|
||||
<div className="stat">
|
||||
<span className="ico">⭐</span>
|
||||
<span className="val">{avgRating}</span>
|
||||
<span className="lbl">Avg. session rating</span>
|
||||
<span className="ico">🎤</span>
|
||||
<span className="val">{event.num_speakers}</span>
|
||||
<span className="lbl">Speakers</span>
|
||||
</div>
|
||||
<div className="stat accent">
|
||||
<span className="ico">🏆</span>
|
||||
<span className="val">{sessions.length}</span>
|
||||
<span className="lbl">Sessions scheduled</span>
|
||||
<span className="ico">⭐</span>
|
||||
<span className="val">{event.avg_feedback != null ? event.avg_feedback.toFixed(1) : '—'}</span>
|
||||
<span className="lbl">Avg. feedback</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -105,7 +146,7 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
<div className="card">
|
||||
<div className="row between" style={{ marginBottom: 14 }}>
|
||||
<h2 className="h2">🏆 Top points</h2>
|
||||
<button className="btn small ghost" onClick={() => onNavigate('attendees')}>
|
||||
<button className="btn small ghost" onClick={() => onNavigate('registrations')}>
|
||||
View all →
|
||||
</button>
|
||||
</div>
|
||||
@@ -114,12 +155,12 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
|
||||
{top.map((r, i) => (
|
||||
<div key={r.profile_id} className="row" style={{ gap: 12 }}>
|
||||
<div key={r.contact_email} className="row" style={{ gap: 12 }}>
|
||||
<span style={{ width: 22, fontWeight: 900, color: 'var(--muted)' }}>{i + 1}</span>
|
||||
<Avatar name={r.full_name} id={r.profile_id} size={36} fs={13} />
|
||||
<Avatar name={r.full_name} id={r.contact_email} size={36} fs={13} />
|
||||
<div className="grow">
|
||||
<div style={{ fontWeight: 700, fontSize: 14 }}>{r.full_name}</div>
|
||||
{r.company && <div className="muted small">{r.company}</div>}
|
||||
<div className="muted small">{r.contact_email}</div>
|
||||
</div>
|
||||
<span className="pts">{r.points}</span>
|
||||
</div>
|
||||
@@ -135,7 +176,7 @@ export function Dashboard({ onNavigate }: { onNavigate: (v: View) => void }) {
|
||||
View all →
|
||||
</button>
|
||||
</div>
|
||||
<ActivityFeed checkins={checkins} connections={connections} feedback={feedback} profiles={profiles} limit={6} />
|
||||
<ActivityFeed checkins={checkins} connections={connections} feedback={feedback} nameOf={nameOf} limit={6} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -146,34 +187,34 @@ function ActivityFeed({
|
||||
checkins,
|
||||
connections,
|
||||
feedback,
|
||||
profiles,
|
||||
nameOf,
|
||||
limit,
|
||||
}: {
|
||||
checkins: Checkin[];
|
||||
connections: Connection[];
|
||||
feedback: Feedback[];
|
||||
profiles: Profile[];
|
||||
nameOf: (email: string) => string;
|
||||
limit: number;
|
||||
}) {
|
||||
const byId = new Map(profiles.map((p) => [p.id, p]));
|
||||
type Item = { at: string; icon: string; text: string };
|
||||
const name = (email: string) => nameOf(email);
|
||||
const items: Item[] = [
|
||||
...checkins.map((c) => ({
|
||||
at: c.created_at,
|
||||
icon: '✅',
|
||||
text: `${byId.get(c.profile_id)?.full_name ?? 'Someone'} checked in`,
|
||||
text: `${name(c.contact_email)} checked in`,
|
||||
})),
|
||||
...connections
|
||||
.filter((c) => c.status === 'accepted')
|
||||
.map((c) => ({
|
||||
at: c.resolved_at ?? c.created_at,
|
||||
icon: '🤝',
|
||||
text: `${byId.get(c.from_id)?.full_name ?? 'Someone'} connected with ${byId.get(c.to_id)?.full_name ?? 'someone'}`,
|
||||
text: `${name(c.from_email)} connected with ${name(c.to_email)}`,
|
||||
})),
|
||||
...feedback.map((f) => ({
|
||||
at: f.created_at,
|
||||
icon: '⭐',
|
||||
text: `${byId.get(f.profile_id)?.full_name ?? 'Someone'} rated a session ${f.rating}★`,
|
||||
text: `${name(f.contact_email)} rated a session ${f.rating}★`,
|
||||
})),
|
||||
]
|
||||
.sort((a, b) => (a.at < b.at ? 1 : -1))
|
||||
@@ -194,3 +235,7 @@ function ActivityFeed({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function fmtDate(d: string): string {
|
||||
return new Date(d + 'T00:00:00').toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
|
||||
}
|
||||
Reference in new issue
Block a user