Chapter Switcher
Component Detail
Description
Slack-style workspace-switching bottom sheet that appears for users (typically NHF peer mentors) who belong to multiple local chapters simultaneously. Allows the user to select which chapter context they are currently acting within, persisting the selection for the session.
chapter-switcher
Summaries
The Chapter Switcher solves a real-world problem specific to NHF peer mentors who serve multiple local chapters simultaneously — without it, these power users would need separate logins or manual workarounds to act within different chapter contexts, creating friction that degrades engagement and increases support burden. Modeled on the familiar Slack workspace-switching pattern, it provides an intuitive, zero-training-required interface that keeps multi-chapter users productive. As a shared component used across the platform, it also represents a single investment that benefits any future feature requiring context-switching behavior, maximizing the return on development effort.
This is a shared, medium-complexity component that will be consumed by multiple features, making its API stability and early delivery a dependency for downstream teams. The bottom-sheet presentation pattern is well-established in the mobile design system, reducing UI design risk. Key dependencies are unit-assignment-service (must provide the list of assigned units) and active-chapter-state (must expose a writable current-chapter stream). The context-change event broadcast to downstream widgets requires a clear contract to be defined and documented before integration — teams consuming this component need to know exactly which BLoCs or Cubits will be notified.
Testing must cover edge cases: a user assigned to exactly one chapter (switcher should not appear), and session persistence across app backgrounding.
ChapterSwitcherSheet is a shared mobile/frontend widget displayed as a modal bottom sheet via `show(context)`. It receives `assignedUnits` (list of OrganizationUnit), `activeUnitId`, and an `onSwitch` callback. Internally it reads from active-chapter-state to reflect the current selection and calls unit-assignment-service to validate units if the list is not pre-loaded by the caller. `getActiveChapterId()` provides a synchronous accessor for widgets that need the current context without subscribing to the state stream.
On chapter selection, the component persists the new active unit to active-chapter-state and invokes `onSwitch` to allow the parent widget tree to react. Ensure the bottom sheet is dismissed via `dismiss()` before navigating to prevent route stack issues on Android back-button handling.
Responsibilities
- List all chapters the current user is assigned to
- Mark the currently active chapter
- Persist chapter selection to local state
- Broadcast context-change event to downstream widgets
Interfaces
ChapterSwitcherSheet(assignedUnits, activeUnitId, onSwitch)
show(context)
dismiss()
getActiveChapterId()
Relationships
Dependencies (2)
Components this component depends on
Related Data Entities (2)
Data entities managed by this component