// Screen: Command Center — the hero function CommandCenter({ scope, setScope, go, nav }) { const { useState } = React; const [period, setPeriod] = useState(30); const [compare, setCompare] = useState(true); const stores = STORES; // Period revenue per store + combined const revs = Object.fromEntries(stores.map(s => [s.id, revFor(s.id, period)])); const combined = stores.reduce((a, s) => a + revs[s.id], 0); const combinedPrev = stores.reduce((a, s) => a + revs[s.id] / (1 + deltaFor(s.id, period) / 100), 0); const combinedDelta = ((combined - combinedPrev) / combinedPrev) * 100; const active = scope === 'all' ? stores : stores.filter(s => s.id === scope); const totalScripts = active.reduce((a, s) => a + s.scriptsToday, 0); const totalQueue = active.reduce((a, s) => a + s.inQueue, 0); const series = stores.map((s, i) => ({ name: s.tag, data: s.spark, color: ['var(--moss)', '#a8652f', '#5b6b8c'][i], bold: i === 0, })); return (
{/* Period controls */}
Period
{PERIOD_OPTS.map(d => ( ))}
{compare ? `vs the ${period} days before` : 'comparison off'}
{/* Topline — combined revenue, all locations */}
Combined revenue · all locations · last {period} days
{fmtMoney(combined)} {compare ? : null} {compare ? ( prev. {fmtMoney(combinedPrev)} ) : null}
Scripts today
{totalScripts}
In queue now
{totalQueue}
Compounds in lab
7
All systems
● Reporting current · 6:58a
{/* Three stores */}
go('queue')}>
{stores.map(s => { const dimmed = scope !== 'all' && scope !== s.id; const busy = s.waitMin >= 15; return (
setScope(scope === s.id ? 'all' : s.id)} style={{ cursor: 'pointer' }}>
{s.name} {busy ? Queue {s.waitMin} min : On pace}
{s.sub}
{fmtMoney(revs[s.id])} {compare ? : null}
revenue · last {period} days
{s.scriptsToday}
scripts today
{s.inQueue}
in queue
{Math.round(s.compShare * 100)}%
compounding
); })}
{/* Trend + margin story */}
Compounding
{pct(MARGIN_STORY.compounding.margin)}
gross margin · {fmtK(MARGIN_STORY.compounding.gp)} GP MTD
Retail
{pct(MARGIN_STORY.retail.margin)}
gross margin · {fmtK(MARGIN_STORY.retail.gp)} GP MTD
The lab is 18% of revenue and 42% of gross profit. Every point of compounding share you add at Anacortes is worth three of retail.
{/* Alerts */}
go('insights')}>
{ALERTS.map((a, i) => (
nav.goQueue(a.link) : undefined}> {a.store} {a.text} {a.link ? View → : null} {a.time}
))}
); } Object.assign(window, { CommandCenter });