fix(convivo): consistent service cards, in-place pick details, no duplicated slot time

- groupAgenda drops orphan service slots (no session row), so every Service Session card consistently shows header + session row; list, slot count and Home Now/Next agree
- Extract the session detail bottom sheet into shared components/SessionDetail.tsx; Home's My-picks chips now open it in place instead of routing to the Agenda (App passes openFeedback so Give-feedback works there too)
- Sheet subtitle shows the slot name only when it adds information: auto-named 'Slot 10:15-11:00' no longer repeats the time range, and service names equal to the session title are skipped
- e2e: orphan-slot test + Home session picks test (exact subtitle assertion) in convivo-admin-entry.spec.ts, 41/41 green; speaker-portal 19/19; docs + release record 2026-10-16.md

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:
committed 2026-10-16 16:11:12 +02:00
1 parent 8e38052f4c
commit 84d39224ba
10 files changed
+442 -177

No files matched your search

+16 -166
View File
@@ -1,21 +1,12 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useAuth } from '../context/AuthContext';
import { useEvent } from '../lib/useEvent';
import { mergeAgendaPlaceholders } from '../lib/agendaBlocks';
import {
clearPreference,
getMyCheckins,
getMyPreferences,
getMySpeakerSessions,
removeSessionMaterial,
sessionMaterialUrl,
setPreference,
uploadSessionMaterial,
} from '../lib/api';
import { getMyCheckins, getMyPreferences, getMySpeakerSessions } from '../lib/api';
import { capWords, fmtRange, slotStatus } from '../lib/time';
import type { Preference, Session } from '../lib/types';
import { Sheet, Spinner } from '../components/ui';
import { useToast } from '../context/ToastContext';
import { Spinner } from '../components/ui';
import { SessionDetail } from '../components/SessionDetail';
export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) => void }) {
const { contact } = useAuth();
@@ -24,8 +15,6 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
const [checkins, setCheckins] = useState<string[]>([]);
const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]);
const [selected, setSelected] = useState<Session | null>(null);
const fileRef = useRef<HTMLInputElement>(null);
const { toast } = useToast();
// Agenda filters: level + area (free-text, dynamic — built from the distinct
// values actually present in the agenda, so it works for numeric levels
@@ -99,60 +88,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
const pickFor = (slotId: number) => prefs.find((p) => p.slot_id === slotId)?.session_id;
async function togglePick(slotId: number, sessionId: string) {
const current = pickFor(slotId);
try {
if (current === sessionId) {
await clearPreference(slotId);
toast('Pick removed');
} else {
await setPreference(sessionId);
toast('Pick saved ✓', 'ok');
}
const p = await getMyPreferences();
setPrefs(p);
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not update pick', 'err');
}
}
const selSlot = selected ? slots.find((s) => s.slot.id === selected.slot_id)?.slot : undefined;
const selStatus = selSlot ? slotStatus(selSlot, now) : 'next';
const selCheckedIn = selected ? checkins.includes(selected.id) : false;
const selISpeaker = selected ? mySpeakerSessions.includes(selected.id) : false;
const selIsService = selSlot?.type === 'service_session';
// Service sessions have no material requirement (and no mic), so the
// pending-material notice never applies to them.
const selNeedsMaterial = selISpeaker && !selected?.material_path && !selIsService;
async function handleUpload(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0];
if (!file || !selected) return;
try {
await uploadSessionMaterial(selected.id, file);
toast('Material uploaded ✓', 'ok');
setSelected(null);
// Refresh agenda so material_path updates.
reload();
} catch (err) {
toast(err instanceof Error ? err.message : 'Upload failed', 'err');
} finally {
if (fileRef.current) fileRef.current.value = '';
}
}
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">
@@ -259,104 +195,18 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
})}
</div>
<Sheet open={!!selected} onClose={() => setSelected(null)}>
{selected && selSlot && (
<>
<div className="row between">
<div>
<h3>{selected.title}</h3>
<div className="sub">
{selSlot.name} · {fmtRange(selSlot)} · {selected.room}
</div>
</div>
<button className="btn ghost small" onClick={() => setSelected(null)}>✕</button>
</div>
<div className="muted small" id="sd-desc" style={{ margin: '12px 0', lineHeight: 1.55 }}>
{selected.description}
</div>
<div className="row" style={{ gap: 8, marginBottom: 14, flexWrap: 'wrap' }}>
<span className="pill">{selIsService ? '' : '🎤 '}{selected.speakers}</span>
{selected.level && <span className="pill violet">📶 {selected.level}</span>}
{selected.area && <span className="pill cyan">🗂 {selected.area}</span>}
{selected.capacity && <span className="pill">👥 {selected.capacity}</span>}
{selCheckedIn && <span className="pill green">✓ Checked in</span>}
</div>
{/* Speaker material: non-dismissible notification until uploaded. */}
{selNeedsMaterial && (
<div className="material-notice" data-testid="material-upload-notice">
<div className="mn-title">📎 Upload your session material</div>
<div className="muted small" style={{ marginBottom: 10 }}>
Attendees can download your slides/notes from this session.
</div>
<input ref={fileRef} type="file" data-testid="material-upload" className="input" onChange={handleUpload} />
</div>
)}
{/* Speaker feedback: visible only after the session is over. */}
{selISpeaker && selStatus === 'done' && (
<div className="feedback-review">
<div className="fr-title">⭐ Your session feedback</div>
{selected.average_feedback != null ? (
<div className="fr-rating">
<span className="fr-stars">
{[1, 2, 3, 4, 5].map((n) => (
<span key={n} className={n <= Math.round(selected.average_feedback!) ? 'on' : ''}>★</span>
))}
</span>
<span className="fr-num">{selected.average_feedback.toFixed(1)}</span>
</div>
) : (
<div className="muted small">No feedback yet.</div>
)}
{selected.ai_generated_feedback && (
<div className="fr-summary">
<div className="muted small" style={{ fontWeight: 700, marginBottom: 4 }}>AI summary</div>
<div style={{ lineHeight: 1.5 }}>{selected.ai_generated_feedback}</div>
</div>
)}
</div>
)}
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{selStatus === 'done' && selCheckedIn && (
<button className="btn primary" data-testid="give-feedback" onClick={() => openFeedback(selected.id)}>
Give feedback ⭐
</button>
)}
{selStatus === 'done' && !selCheckedIn && (
<div className="muted small" style={{ textAlign: 'center' }}>
You weren’t checked in to this session.
</div>
)}
{selSlot.type === 'service_session' ? (
<div className="muted small" style={{ textAlign: 'center' }}>
No pick needed for this slot.
</div>
) : (
<button
className={`btn ${pickFor(selected.slot_id) === selected.id ? 'danger' : 'primary'}`}
onClick={() => togglePick(selected.slot_id, selected.id)}
>
{pickFor(selected.slot_id) === selected.id ? 'Remove my pick' : 'Pick this session'}
</button>
)}
{/* Material download (all attendees) — pinned to the bottom. */}
{selected.material_path && (
<a className="btn primary" href={sessionMaterialUrl(selected.material_path)} target="_blank" rel="noreferrer">
📎 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>
</>
)}
</Sheet>
<SessionDetail
session={selected}
slot={selSlot}
now={now}
checkedIn={!!selected && checkins.includes(selected.id)}
isSpeaker={!!selected && mySpeakerSessions.includes(selected.id)}
picked={!!selected && pickFor(selected.slot_id) === selected.id}
onClose={() => setSelected(null)}
onPickChanged={async () => setPrefs(await getMyPreferences())}
onGiveFeedback={openFeedback}
onMaterialChanged={reload}
/>
</section>
);
}
+28 -3
View File
@@ -5,6 +5,7 @@ import { getMyCheckins, getMyFeedback, getMyPreferences, getMySpeakerSessions }
import { fmtRange, greeting, slotStatus } from '../lib/time';
import type { Feedback, Preference, Session } from '../lib/types';
import { Sheet, Spinner } from '../components/ui';
import { SessionDetail } from '../components/SessionDetail';
/** A single session block inside the Now/Next card (title + room + speaker). */
function SessionBlock({ session, checkedIn }: { session: Session; checkedIn?: boolean }) {
@@ -42,14 +43,18 @@ function ConcurrentList({ sessions }: { sessions: Session[] }) {
);
}
export function Home({ go, onEventFeedback }: { go: (tab: string) => void; onEventFeedback?: () => void }) {
export function Home({ go, onEventFeedback, openFeedback }: { go: (tab: string) => void; onEventFeedback?: () => void; openFeedback?: (sessionId: string) => void }) {
const { contact, registration } = useAuth();
const { event, slots, sessionById, slotById, now, clockMode, loading } = useEvent();
const { event, slots, sessionById, slotById, now, clockMode, loading, reload } = useEvent();
const [prefs, setPrefs] = useState<Preference[]>([]);
const [checkins, setCheckins] = useState<string[]>([]);
const [mySpeakerSessions, setMySpeakerSessions] = useState<string[]>([]);
const [myFeedback, setMyFeedback] = useState<Feedback[]>([]);
const [materialSheetOpen, setMaterialSheetOpen] = useState(false);
// The pick the user tapped in "My picks today" — opened in the same detail
// sheet the Agenda uses, so a pick shows the full session info in place
// instead of bouncing to the Agenda tab.
const [selected, setSelected] = useState<Session | null>(null);
const email = contact?.email ?? '';
@@ -207,7 +212,12 @@ export function Home({ go, onEventFeedback }: { go: (tab: string) => void; onEve
{picks.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column' }}>
{picks.map((r) => (
<button key={r.session.id} className="pick-chip" onClick={() => go('agenda')}>
<button
key={r.session.id}
className="pick-chip"
data-testid="home-pick"
onClick={() => setSelected(r.session)}
>
<span className="t">{fmtRange(r.slot)}</span>
<span className="grow" style={{ fontWeight: 600, textAlign: 'left' }}>
{r.session.title}
@@ -283,6 +293,21 @@ export function Home({ go, onEventFeedback }: { go: (tab: string) => void; onEve
Got it
</button>
</Sheet>
{/* Tapping one of "My picks today" opens the same session detail sheet the
Agenda shows — no round trip to the Agenda tab. */}
<SessionDetail
session={selected}
slot={selected ? slotById.get(selected.slot_id) : undefined}
now={now}
checkedIn={!!selected && checkins.includes(selected.id)}
isSpeaker={!!selected && mySpeakerSessions.includes(selected.id)}
picked={!!selected && pickFor(selected.slot_id) === selected.id}
onClose={() => setSelected(null)}
onPickChanged={async () => setPrefs(await getMyPreferences())}
onGiveFeedback={openFeedback}
onMaterialChanged={reload}
/>
</section>
);
}