fix(boss-dashboard): show raw claim count + fix stale window on tab switch

"Claimed" was gated to emailed/approved/sent quotes, undercounting reps
who claim a lot but haven't pushed everything out yet (e.g. Karin showed
1 instead of her actual 4 claimed today). Swap in quotesLoaded so it
reflects total quotes processed, any status.

Also fixes tab switching (Today/Week/Month) needing a manual refresh to
show the right numbers: selectWindow() called fetchData() before the
activeWindowRef mirroring effect had run, so the fetch used the
previous tab's window. Now set synchronously in the click handler.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Dave 2026-08-31 22:38:41 +02:00
parent e1f14d9c48
commit 392a76fef7

View file

@ -111,6 +111,11 @@ export default function BossDashboardView() {
// calls setState on every render.
const selectWindow = useCallback((w: BossWindow) => {
if (w === activeWindowRef.current) return;
// Set the ref synchronously — the mirroring effect (line ~42) only
// fires after React re-renders, which is too late for the fetchData
// call below. Without this, fetchData reads the stale window and the
// tab shows the previous window's numbers until a manual refresh.
activeWindowRef.current = w;
setActiveWindow(w);
setSheetRep(null);
setSheetItems([]);
@ -317,7 +322,7 @@ export default function BossDashboardView() {
<div className="text-sm font-medium truncate">{rep.name}</div>
<div className="mt-0.5 grid grid-cols-3 gap-1 text-center">
<MiniMetric label="loaded" value={rep.quotesDoneFor} color="text-cyan-400" />
<MiniMetric label="claimed" value={rep.quotesDoneBy} color="text-emerald-400" />
<MiniMetric label="claimed" value={rep.quotesLoaded} color="text-emerald-400" />
<MiniMetric label="orders" value={rep.ordersPlaced} color="text-orange-400" />
</div>
</div>
@ -431,7 +436,7 @@ export default function BossDashboardView() {
<div className="min-w-0">
<div className="text-sm font-semibold truncate">{sheetRep.name}</div>
<div className="text-xs text-muted-foreground">
{sheetRep.quotesDoneFor} loaded · {sheetRep.quotesDoneBy} claimed
{sheetRep.quotesDoneFor} loaded · {sheetRep.quotesLoaded} claimed
· {sheetRep.ordersPlaced} orders
</div>
</div>