diff --git a/frontend/src/pages/Summary.tsx b/frontend/src/pages/Summary.tsx index eea8e2d..2471633 100644 --- a/frontend/src/pages/Summary.tsx +++ b/frontend/src/pages/Summary.tsx @@ -102,8 +102,9 @@ export default function Summary() { status: OPEN_STATUSES.join(','), assigned_to: mineOnly ? user.email : undefined, }) - // When rooms-view is on, also fetch live occupancy to mark occupied tasks - const occFetch = roomsView ? fetchOccupancy().catch(() => null) : Promise.resolve(null) + // Always fetch live occupancy — bedroom-type tasks show occupancy badges on + // every view, not just the rooms-view filter. + const occFetch = fetchOccupancy().catch(() => null) Promise.all([taskFetch, occFetch]) .then(([t, occ]) => { @@ -115,7 +116,7 @@ export default function Summary() { }) .catch(err => setError(err.message)) .finally(() => setLoading(false)) - }, [mineOnly, roomsView, user.email]) + }, [mineOnly, user.email]) useEffect(() => { load() }, [load]) useEffect(() => { @@ -346,20 +347,25 @@ export default function Summary() { {(() => { const renderTask = (t: Task) => { + // Bedroom-type locations are the ones synced from NewBook (they carry a + // site id) — manual Rooms-category locations like corridors/stores never + // get an occupancy badge, in either view. const sid = t.newbook_site_id ? String(t.newbook_site_id) : null - const isOccupied = roomsView && !!sid && occupiedSiteIds.has(sid) - const isDeparting = roomsView && !!sid && !isOccupied && departingSiteIds.has(sid) + const isOccupied = !!sid && occupiedSiteIds.has(sid) + const isDeparting = !!sid && !isOccupied && departingSiteIds.has(sid) // Not exclusive with isDeparting — a departing room can also have a same-day // incoming booking (back-to-back turnover), and both badges should show. - const isArriving = roomsView && !!sid && !isOccupied && arrivingSiteIds.has(sid) + const isArriving = !!sid && !isOccupied && arrivingSiteIds.has(sid) + const isUnoccupied = !!sid && !isOccupied && !isDeparting && !isArriving return (