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 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]>
This commit is contained in:
1 parent
2f53d47578
commit
7605c9bbf4
64 files changed
+4593
-1371
No files matched your search
@@ -1,14 +1,31 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { supabase } from '../lib/supabase';
|
||||
import { getAllSessions, getAllSlots } from '../lib/api';
|
||||
import type { Session, Slot } from '../lib/types';
|
||||
import {
|
||||
evaluateSessionFeedback,
|
||||
getAllContacts,
|
||||
getAllSessionSpeakers,
|
||||
getActiveEvent,
|
||||
getSessions,
|
||||
getSlots,
|
||||
removeSessionMaterial,
|
||||
sessionMaterialUrl,
|
||||
setSessionSpeakers,
|
||||
uploadSessionMaterial,
|
||||
} from '../lib/api';
|
||||
import type { Contact, Event, Session, SessionSpeaker, Slot, SlotType } from '../lib/types';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { Empty, Modal, Spinner } from '../components/ui';
|
||||
import { Empty, Modal, Spinner, TypeBadge } from '../components/ui';
|
||||
|
||||
const SLOT_TYPES: SlotType[] = ['session', 'lunch_break', 'coffee_break', 'keynote', 'close_up'];
|
||||
|
||||
export function Schedule() {
|
||||
const { push } = useToast();
|
||||
const [slots, setSlots] = useState<Slot[] | null>(null);
|
||||
const [event, setEvent] = useState<Event | null>(null);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [slots, setSlots] = useState<Slot[]>([]);
|
||||
const [sessions, setSessions] = useState<Session[]>([]);
|
||||
const [speakers, setSpeakers] = useState<SessionSpeaker[]>([]);
|
||||
const [contacts, setContacts] = useState<Contact[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const [slotModal, setSlotModal] = useState<{ slot: Slot | null } | null>(null);
|
||||
@@ -17,9 +34,22 @@ export function Schedule() {
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const [s, ss] = await Promise.all([getAllSlots(), getAllSessions()]);
|
||||
setSlots(s);
|
||||
setSessions(ss);
|
||||
const ev = await getActiveEvent();
|
||||
setEvent(ev);
|
||||
if (ev) {
|
||||
const [s, ss, sp, c] = await Promise.all([
|
||||
getSlots(ev.id),
|
||||
getSessions(ev.id),
|
||||
getAllSessionSpeakers(),
|
||||
getAllContacts(),
|
||||
]);
|
||||
setSlots(s);
|
||||
setSessions(ss);
|
||||
const ids = new Set(ss.map((x) => x.id));
|
||||
setSpeakers(sp.filter((x) => ids.has(x.session_id)));
|
||||
setContacts(c);
|
||||
}
|
||||
setLoaded(true);
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : 'Failed to load');
|
||||
}
|
||||
@@ -29,6 +59,18 @@ export function Schedule() {
|
||||
load();
|
||||
}, []);
|
||||
|
||||
const speakersFor = useMemo(() => {
|
||||
const m = new Map<string, string[]>();
|
||||
for (const sp of speakers) {
|
||||
const arr = m.get(sp.session_id) ?? [];
|
||||
arr.push(sp.contact_email);
|
||||
m.set(sp.session_id, arr);
|
||||
}
|
||||
return m;
|
||||
}, [speakers]);
|
||||
|
||||
const nameOf = (email: string) => contacts.find((c) => c.email === email)?.full_name ?? email;
|
||||
|
||||
async function deleteSlot(slot: Slot) {
|
||||
if (!confirm(`Delete "${slot.name}" and all its sessions?`)) return;
|
||||
setBusy(true);
|
||||
@@ -59,20 +101,51 @@ export function Schedule() {
|
||||
}
|
||||
}
|
||||
|
||||
async function doEvaluate(sess: Session) {
|
||||
setBusy(true);
|
||||
try {
|
||||
await evaluateSessionFeedback(sess.id);
|
||||
await load();
|
||||
push('success', `AI feedback evaluated for ${sess.title}`);
|
||||
} catch (e) {
|
||||
push('error', e instanceof Error ? e.message : 'Evaluation failed');
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (error) return <Empty icon="⚠️" text={error} />;
|
||||
if (!slots)
|
||||
if (!loaded)
|
||||
return (
|
||||
<div className="loading-screen">
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
|
||||
if (!event) {
|
||||
return (
|
||||
<div>
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1>Schedule</h1>
|
||||
<div className="sub">Slots, sessions, speakers, and materials.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card">
|
||||
<Empty icon="📅" text="No active event. Set an event active in the Events view first." />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="page-head">
|
||||
<div>
|
||||
<h1>Schedule</h1>
|
||||
<div className="sub">{slots.length} slots · {sessions.length} sessions.</div>
|
||||
<div className="sub">
|
||||
{event.name} · {slots.length} slots · {sessions.length} sessions.
|
||||
</div>
|
||||
</div>
|
||||
<button className="btn primary" onClick={() => setSlotModal({ slot: null })}>
|
||||
+ New slot
|
||||
@@ -86,6 +159,7 @@ export function Schedule() {
|
||||
<div key={slot.id} className="card">
|
||||
<div className="row between" style={{ marginBottom: 12 }}>
|
||||
<div className="row" style={{ gap: 12 }}>
|
||||
<TypeBadge type={slot.type} />
|
||||
<div>
|
||||
<div style={{ fontWeight: 800, fontSize: 16 }}>{slot.name}</div>
|
||||
<div className="muted small">
|
||||
@@ -112,24 +186,39 @@ export function Schedule() {
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{slotSessions.map((s) => (
|
||||
<div key={s.id} className="row between" style={{ padding: '10px 12px', background: 'var(--surface-2)', borderRadius: 12 }}>
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<div style={{ fontWeight: 700, fontSize: 14 }}>{s.title}</div>
|
||||
<div className="muted small">
|
||||
{[s.room, s.speakers, s.capacity ? `cap ${s.capacity}` : null].filter(Boolean).join(' · ') || '—'}
|
||||
{slotSessions.map((s) => {
|
||||
const spk = (speakersFor.get(s.id) ?? []).map(nameOf).join(', ');
|
||||
return (
|
||||
<div key={s.id} className="row between" style={{ padding: '10px 12px', background: 'var(--surface-2)', borderRadius: 12 }}>
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<div style={{ fontWeight: 700, fontSize: 14 }}>{s.title}</div>
|
||||
<div className="muted small">
|
||||
{[s.room, spk || 'no speakers', s.capacity ? `cap ${s.capacity}` : null].filter(Boolean).join(' · ')}
|
||||
</div>
|
||||
<div className="muted small" style={{ marginTop: 4 }}>
|
||||
{s.average_feedback != null && <span>⭐ {s.average_feedback.toFixed(1)}</span>}
|
||||
{s.material_path && <span> · 📎 material</span>}
|
||||
{s.ai_generated_feedback && (
|
||||
<span className="ai-state"> · 🤖 {s.ai_generated_feedback}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-actions">
|
||||
{s.ai_generated_feedback === 'Pending AI Evaluation' && (
|
||||
<button className="btn small" disabled={busy} onClick={() => doEvaluate(s)}>
|
||||
Evaluate
|
||||
</button>
|
||||
)}
|
||||
<button className="btn small" onClick={() => setSessModal({ session: s, slotId: slot.id })}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="btn small danger" disabled={busy} onClick={() => deleteSession(s)}>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row-actions">
|
||||
<button className="btn small" onClick={() => setSessModal({ session: s, slotId: slot.id })}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="btn small danger" disabled={busy} onClick={() => deleteSession(s)}>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -140,6 +229,7 @@ export function Schedule() {
|
||||
{slotModal && (
|
||||
<SlotModal
|
||||
slot={slotModal.slot}
|
||||
eventId={event.id}
|
||||
onClose={() => setSlotModal(null)}
|
||||
onSaved={async (msg) => {
|
||||
setSlotModal(null);
|
||||
@@ -152,6 +242,9 @@ export function Schedule() {
|
||||
<SessionModal
|
||||
session={sessModal.session}
|
||||
slotId={sessModal.slotId}
|
||||
eventId={event.id}
|
||||
contacts={contacts}
|
||||
currentSpeakers={speakersFor.get(sessModal.session?.id ?? '') ?? []}
|
||||
onClose={() => setSessModal(null)}
|
||||
onSaved={async (msg) => {
|
||||
setSessModal(null);
|
||||
@@ -166,14 +259,17 @@ export function Schedule() {
|
||||
|
||||
function SlotModal({
|
||||
slot,
|
||||
eventId,
|
||||
onClose,
|
||||
onSaved,
|
||||
}: {
|
||||
slot: Slot | null;
|
||||
eventId: string;
|
||||
onClose: () => void;
|
||||
onSaved: (msg: string) => void;
|
||||
}) {
|
||||
const [name, setName] = useState(slot?.name ?? '');
|
||||
const [type, setType] = useState<SlotType>(slot?.type ?? 'session');
|
||||
const [date, setDate] = useState(slot ? slot.slot_date.slice(0, 10) : '');
|
||||
const [start, setStart] = useState(slot ? slot.start_time.slice(0, 5) : '09:00');
|
||||
const [end, setEnd] = useState(slot ? slot.end_time.slice(0, 5) : '10:00');
|
||||
@@ -183,7 +279,7 @@ function SlotModal({
|
||||
if (!name.trim() || !date) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
const payload = { name: name.trim(), slot_date: date, start_time: start, end_time: end };
|
||||
const payload = { name: name.trim(), type, slot_date: date, start_time: start, end_time: end, event_id: eventId };
|
||||
if (slot) {
|
||||
const { error: err } = await supabase.from('slots').update(payload).eq('id', slot.id);
|
||||
if (err) throw err;
|
||||
@@ -219,6 +315,16 @@ function SlotModal({
|
||||
<label>Name</label>
|
||||
<input className="input" value={name} onChange={(e) => setName(e.target.value)} placeholder="e.g. Morning keynote" />
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Type</label>
|
||||
<select className="input" value={type} onChange={(e) => setType(e.target.value as SlotType)}>
|
||||
{SLOT_TYPES.map((t) => (
|
||||
<option key={t} value={t}>
|
||||
{t.replace('_', ' ')}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Date</label>
|
||||
<input className="input" type="date" value={date} onChange={(e) => setDate(e.target.value)} />
|
||||
@@ -240,19 +346,26 @@ function SlotModal({
|
||||
function SessionModal({
|
||||
session,
|
||||
slotId,
|
||||
eventId,
|
||||
contacts,
|
||||
currentSpeakers,
|
||||
onClose,
|
||||
onSaved,
|
||||
}: {
|
||||
session: Session | null;
|
||||
slotId: number;
|
||||
eventId: string;
|
||||
contacts: Contact[];
|
||||
currentSpeakers: string[];
|
||||
onClose: () => void;
|
||||
onSaved: (msg: string) => void;
|
||||
}) {
|
||||
const [title, setTitle] = useState(session?.title ?? '');
|
||||
const [room, setRoom] = useState(session?.room ?? '');
|
||||
const [speakers, setSpeakers] = useState(session?.speakers ?? '');
|
||||
const [capacity, setCapacity] = useState(session?.capacity?.toString() ?? '');
|
||||
const [description, setDescription] = useState(session?.description ?? '');
|
||||
const [speakerEmails, setSpeakerEmails] = useState<string[]>(currentSpeakers);
|
||||
const [material, setMaterial] = useState<File | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
async function save() {
|
||||
@@ -262,17 +375,27 @@ function SessionModal({
|
||||
const payload = {
|
||||
title: title.trim(),
|
||||
room: room.trim() || null,
|
||||
speakers: speakers.trim() || null,
|
||||
capacity: capacity ? parseInt(capacity, 10) : null,
|
||||
description: description.trim() || null,
|
||||
slot_id: slotId,
|
||||
event_id: eventId,
|
||||
};
|
||||
let sessionId = session?.id;
|
||||
if (session) {
|
||||
const { error: err } = await supabase.from('sessions').update(payload).eq('id', session.id);
|
||||
if (err) throw err;
|
||||
} else {
|
||||
const { error: err } = await supabase.from('sessions').insert(payload);
|
||||
const { data: ins, error: err } = await supabase.from('sessions').insert(payload).select().single();
|
||||
if (err) throw err;
|
||||
sessionId = (ins as Session).id;
|
||||
}
|
||||
// Speakers (a session must keep >= 1 speaker).
|
||||
if (sessionId && speakerEmails.length > 0) {
|
||||
await setSessionSpeakers(sessionId, speakerEmails);
|
||||
}
|
||||
// Material upload (if a new file was chosen).
|
||||
if (sessionId && material) {
|
||||
await uploadSessionMaterial(sessionId, material);
|
||||
}
|
||||
onSaved(session ? 'Session updated' : 'Session created');
|
||||
} catch (e) {
|
||||
@@ -282,6 +405,12 @@ function SessionModal({
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSpeaker(email: string) {
|
||||
setSpeakerEmails((prev) =>
|
||||
prev.includes(email) ? prev.filter((x) => x !== email) : [...prev, email],
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open
|
||||
@@ -292,7 +421,7 @@ function SessionModal({
|
||||
<button className="btn" onClick={onClose}>
|
||||
Cancel
|
||||
</button>
|
||||
<button className="btn primary" disabled={busy || !title.trim()} onClick={save}>
|
||||
<button className="btn primary" disabled={busy || !title.trim() || speakerEmails.length === 0} onClick={save}>
|
||||
{busy ? 'Saving…' : 'Save'}
|
||||
</button>
|
||||
</>
|
||||
@@ -312,14 +441,71 @@ function SessionModal({
|
||||
<input className="input" type="number" value={capacity} onChange={(e) => setCapacity(e.target.value)} placeholder="—" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Speakers</label>
|
||||
<input className="input" value={speakers} onChange={(e) => setSpeakers(e.target.value)} placeholder="—" />
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Description</label>
|
||||
<textarea className="input" value={description} onChange={(e) => setDescription(e.target.value)} placeholder="—" />
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
<label>Speakers ({speakerEmails.length})</label>
|
||||
<div className="speaker-pick">
|
||||
{contacts.map((c) => (
|
||||
<label key={c.email} className={`speaker-opt ${speakerEmails.includes(c.email) ? 'on' : ''}`}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={speakerEmails.includes(c.email)}
|
||||
onChange={() => toggleSpeaker(c.email)}
|
||||
/>
|
||||
{c.full_name}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
{speakerEmails.length === 0 && (
|
||||
<span className="muted small">A session needs at least one speaker.</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{session && (
|
||||
<div className="field">
|
||||
<label>Material</label>
|
||||
{session.material_path ? (
|
||||
<div className="row" style={{ gap: 10 }}>
|
||||
<a className="btn small" href={sessionMaterialUrl(session.material_path)} target="_blank" rel="noreferrer">
|
||||
📎 View current
|
||||
</a>
|
||||
<button
|
||||
className="btn small danger"
|
||||
disabled={busy}
|
||||
onClick={async () => {
|
||||
try {
|
||||
await removeSessionMaterial(session.id);
|
||||
onSaved('Material removed');
|
||||
} catch (e) {
|
||||
onSaved(e instanceof Error ? e.message : 'Remove failed');
|
||||
}
|
||||
}}
|
||||
>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<span className="muted small">No material uploaded yet.</span>
|
||||
)}
|
||||
<input
|
||||
className="input"
|
||||
type="file"
|
||||
onChange={(e) => setMaterial(e.target.files?.[0] ?? null)}
|
||||
/>
|
||||
{material && <span className="muted small">Will upload: {material.name}</span>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{session && session.ai_generated_feedback && (
|
||||
<div className="field">
|
||||
<label>AI feedback</label>
|
||||
<div className="ai-box">{session.ai_generated_feedback}</div>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user