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
This commit is contained in:
Lago committed 2026-10-16 16:11:12 +02:00
1 parent 3d4dc207ff
commit ef0446dcdf
10 files changed
+442 -177

No files matched your search

+1 -1
View File
@@ -156,7 +156,7 @@ function Shell() {
return (
<div className="app">
{tab === 'home' && <Home go={go} onEventFeedback={() => setEventFeedbackOpen(true)} />}
{tab === 'home' && <Home go={go} onEventFeedback={() => setEventFeedbackOpen(true)} openFeedback={(id) => setFeedbackSession(id)} />}
{tab === 'agenda' && <Agenda openFeedback={(id) => setFeedbackSession(id)} />}
{tab === 'scan' && <Scan />}
{tab === 'connections' && <Connections initialTab={connectionsTab} />}
@@ -0,0 +1,198 @@
import { useRef } from 'react';
import {
clearPreference,
removeSessionMaterial,
sessionMaterialUrl,
setPreference,
uploadSessionMaterial,
} from '../lib/api';
import { fmtRange, slotStatus } from '../lib/time';
import type { Session, Slot } from '../lib/types';
import { useToast } from '../context/ToastContext';
import { Sheet } from './ui';
/**
* The session detail bottom sheet — the single source of truth for what a
* session looks like when opened. Used by the Agenda list and by Home's
* "My picks today" chips, so tapping a pick on Home shows exactly the same
* detail as tapping it in the Agenda.
*/
export function SessionDetail({
session,
slot,
now,
checkedIn,
isSpeaker,
picked,
onClose,
onPickChanged,
onGiveFeedback,
onMaterialChanged,
}: {
session: Session | null;
slot: Slot | undefined;
now: Date;
checkedIn: boolean;
isSpeaker: boolean;
picked: boolean;
onClose: () => void;
/** Persist a pick/un-pick; the parent refreshes its own preference list. */
onPickChanged: () => Promise<void> | void;
onGiveFeedback?: (sessionId: string) => void;
/** Refresh the agenda after a material upload/remove. */
onMaterialChanged?: () => void;
}) {
const { toast } = useToast();
const fileRef = useRef<HTMLInputElement>(null);
if (!session || !slot) return null;
const status = slotStatus(slot, now);
const isService = slot.type === 'service_session';
// Service sessions have no material requirement (and no mic), so the
// pending-material notice never applies to them.
const needsMaterial = isSpeaker && !session.material_path && !isService;
async function togglePick() {
try {
if (picked) {
await clearPreference(slot!.id);
toast('Pick removed');
} else {
await setPreference(session!.id);
toast('Pick saved ✓', 'ok');
}
await onPickChanged();
} catch (e) {
toast(e instanceof Error ? e.message : 'Could not update pick', 'err');
}
}
async function handleUpload(e: React.ChangeEvent<HTMLInputElement>) {
const file = e.target.files?.[0];
if (!file || !session) return;
try {
await uploadSessionMaterial(session.id, file);
toast('Material uploaded ✓', 'ok');
onClose();
onMaterialChanged?.();
} catch (err) {
toast(err instanceof Error ? err.message : 'Upload failed', 'err');
} finally {
if (fileRef.current) fileRef.current.value = '';
}
}
async function handleDeleteMaterial() {
if (!session) return;
if (!confirm('Remove this material? You can upload a new one.')) return;
try {
await removeSessionMaterial(session.id);
toast('Material removed', 'ok');
onClose();
onMaterialChanged?.();
} catch (err) {
toast(err instanceof Error ? err.message : 'Could not remove material', 'err');
}
}
const range = fmtRange(slot);
// Talk slots are auto-named "Slot 10:15–11:00", which merely repeats the
// time range shown next to it, and service slots are often named exactly
// like their session (the title is already the heading). Show the slot name
// only when it actually adds information.
const showSlotName = slot.name !== `Slot ${range}` && slot.name !== session.title;
return (
<Sheet open onClose={onClose}>
<div className="row between">
<div>
<h3>{session.title}</h3>
<div className="sub">
{showSlotName && <>{slot.name} · </>}{range} · {session.room}
</div>
</div>
<button className="btn ghost small" onClick={onClose}>✕</button>
</div>
<div className="muted small" id="sd-desc" style={{ margin: '12px 0', lineHeight: 1.55 }}>
{session.description}
</div>
<div className="row" style={{ gap: 8, marginBottom: 14, flexWrap: 'wrap' }}>
<span className="pill">{isService ? '' : '🎤 '}{session.speakers}</span>
{session.level && <span className="pill violet">📶 {session.level}</span>}
{session.area && <span className="pill cyan">🗂 {session.area}</span>}
{session.capacity && <span className="pill">👥 {session.capacity}</span>}
{checkedIn && <span className="pill green">✓ Checked in</span>}
</div>
{/* Speaker material: non-dismissible notification until uploaded. */}
{needsMaterial && (
<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. */}
{isSpeaker && status === 'done' && (
<div className="feedback-review">
<div className="fr-title">⭐ Your session feedback</div>
{session.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(session.average_feedback!) ? 'on' : ''}>★</span>
))}
</span>
<span className="fr-num">{session.average_feedback.toFixed(1)}</span>
</div>
) : (
<div className="muted small">No feedback yet.</div>
)}
{session.ai_generated_feedback && (
<div className="fr-summary">
<div className="muted small" style={{ fontWeight: 700, marginBottom: 4 }}>AI summary</div>
<div style={{ lineHeight: 1.5 }}>{session.ai_generated_feedback}</div>
</div>
)}
</div>
)}
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{status === 'done' && checkedIn && onGiveFeedback && (
<button className="btn primary" data-testid="give-feedback" onClick={() => onGiveFeedback(session.id)}>
Give feedback ⭐
</button>
)}
{status === 'done' && !checkedIn && (
<div className="muted small" style={{ textAlign: 'center' }}>
You weren’t checked in to this session.
</div>
)}
{isService ? (
<div className="muted small" style={{ textAlign: 'center' }}>
No pick needed for this slot.
</div>
) : (
<button className={`btn ${picked ? 'danger' : 'primary'}`} onClick={togglePick}>
{picked ? 'Remove my pick' : 'Pick this session'}
</button>
)}
{/* Material download (all attendees) — pinned to the bottom. */}
{session.material_path && (
<a className="btn primary" href={sessionMaterialUrl(session.material_path)} target="_blank" rel="noreferrer">
📎 Download material
</a>
)}
{/* Speakers can remove their own material to re-upload. */}
{isSpeaker && session.material_path && (
<button className="btn danger" onClick={handleDeleteMaterial}>
🗑 Remove material
</button>
)}
</div>
</Sheet>
);
}
+9 -1
View File
@@ -83,7 +83,15 @@ export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[
});
}
}
return [...map.values()].sort((first, second) =>
// A service slot is only meaningful with a session behind it (break / lunch /
// closing …). An orphan service slot — left over from an earlier feed or a
// manual edit with no session row — would render as a header-only card,
// inconsistent with every other service card. Drop those (mirroring how the
// agenda already hides empty talk slots) so the list, its slot count, and
// Home's Now/Next all agree.
return [...map.values()]
.filter(({ slot, sessions }) => slot.type !== 'service_session' || sessions.length > 0)
.sort((first, second) =>
first.slot.slot_date.localeCompare(second.slot.slot_date)
|| first.slot.start_time.localeCompare(second.slot.start_time)
|| first.slot.end_time.localeCompare(second.slot.end_time)
+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>
);
}