Skip to content

[FE-06] Build Live Occupancy Counter Widget with WebSocket connection #985

@devwums

Description

@devwums

Problem

Members viewing a workspace detail page cannot see real-time occupancy — the count only updates on page refresh. There is no live connection to the backend WebSocket.

Proposed Solution

Create frontend/cntr/LiveOccupancy/LiveOccupancyWidget.tsx and frontend/cntr/LiveOccupancy/useWebSocket.ts. The hook connects to a WebSocket URL and exposes { data, status: 'connecting' | 'open' | 'closed' }. The widget listens for occupancy_update events. Props: wsUrl: string, capacity: number. All implementation must live inside frontend/cntr/.

Acceptance Criteria

  • Files: LiveOccupancyWidget.tsx and useWebSocket.ts in frontend/cntr/LiveOccupancy/
  • Displays "{current} / {capacity} occupied"
  • Green when < 70% full, yellow 70–89%, red ≥ 90%
  • Shows "Connecting…" while WebSocket is in connecting state
  • useWebSocket calls ws.close() on component unmount
  • Test in LiveOccupancyWidget.test.tsx with a mocked WebSocket

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions