import { html } from '../lib/preact.js'; import { getStatusMeta, STATUS_PRIORITY } from '../utils/status.js'; export function Sidebar({ projectGroups, selectedProject, onSelectProject, totalSessions }) { // Calculate totals for "All Projects" const allStatusCounts = { needs_attention: 0, active: 0, starting: 0, done: 0 }; for (const group of projectGroups) { for (const s of group.sessions) { allStatusCounts[s.status] = (allStatusCounts[s.status] || 0) + 1; } } // Worst status across all projects const allWorstStatus = totalSessions > 0 ? Object.keys(allStatusCounts).reduce((worst, status) => allStatusCounts[status] > 0 && (STATUS_PRIORITY[status] ?? 99) < (STATUS_PRIORITY[worst] ?? 99) ? status : worst , 'done') : 'done'; const allWorstMeta = getStatusMeta(allWorstStatus); // Tiny inline status indicator const StatusPips = ({ counts }) => html`
${counts.needs_attention > 0 && html`${counts.needs_attention}`} ${counts.active > 0 && html`${counts.active}`} ${counts.starting > 0 && html`${counts.starting}`} ${counts.done > 0 && html`${counts.done}`}
`; return html` `; }