/* global React, AppShell, Tag, Eyebrow, useFoyerData, leadBucket, fmtRelative, fmtClock, foyerGoToSession */
// /#/sessions — index page. The agent lands here when they click "Sessions"
// in the sidebar; only after picking one do we route into the detail view.
// Sortable by recency, filterable by recorded vs manual, with a per-card
// preview so they can spot the right session without drilling in.
const SessionsList = () => {
const { summaries, sessionsById, loading, error } = useFoyerData();
const [kindFilter, setKindFilter] = React.useState('all'); // all | recorded | manual
const [search, setSearch] = React.useState('');
const sortedSummaries = React.useMemo(() => {
return [...summaries].sort((a, b) => (b.created_at || '').localeCompare(a.created_at || ''));
}, [summaries]);
const filtered = sortedSummaries.filter(s => {
const kind = s.kind || 'recorded';
if (kindFilter !== 'all' && kind !== kindFilter) return false;
const q = search.trim().toLowerCase();
if (!q) return true;
if ((s.address || '').toLowerCase().includes(q)) return true;
const visitors = sessionsById[s.id]?.result?.visitors || [];
return visitors.some(v => (v.visitor?.name || '').toLowerCase().includes(q));
});
return (
Library
Sessions · {summaries.length}
Every recording and manual lead, newest first. Pick one to dive in.
{summaries.length === 0
? 'Record an open house from the iOS app, or add a lead manually below.'
: 'Try clearing the search or switching kind filter.'}