Role Switch Between Coordinator and Peer Mentor
Some users hold both a coordinator and a peer mentor role within an organization. The role switch widget—accessible from the hamburger menu in Settings—allows these dual-role users to toggle their active role. When a switch is triggered, the role state manager updates the active role, the role-aware bottom nav re-renders with the appropriate tabs, and the home screen transitions to the role-specific variant. The role resolution service re-validates the user's available roles from Supabase before presenting switch options, ensuring only genuinely assigned roles are selectable.
User Story
Audience Summaries
Many chapters rely on a small pool of committed volunteers who simultaneously serve as both peer mentors and coordinators. Forcing these dual-role users to log out and back in to switch their working context creates direct friction that leads to underreporting of activities—a core metric the platform exists to capture. This high-priority story eliminates that friction by providing a seamless, in-app role switch accessible from the Settings menu. By reducing the effort required to operate in either role, the platform directly supports its primary mission of maximizing participation data completeness.
Improved reporting accuracy enables better resource allocation decisions and strengthens the case for continued organizational investment in the platform.
This story depends on story-role-based-access-control-coordinator-001 and -003 and requires coordination across three functional areas: the role resolution service (Supabase integration), the role state manager, and the role-aware bottom navigation and home screen components. Delivery complexity is moderate-to-high due to the number of UI surfaces that must react to a role switch event—any component that reads the active role must re-render correctly without full navigation. Acceptance criteria include a clean rollback if the user navigates away mid-switch, which requires careful state transition design. Accessibility testing is explicitly required for the role switch widget, adding QA scope.
Stakeholder review should include a UX walkthrough to validate the single-role no-switch message and focus management behavior.
The role switch widget triggers a coordinated state update across multiple layers. First, the role resolution service must query Supabase to confirm which roles the current user actually holds before rendering switch options—cached role state must not be trusted here. On selection, the role state manager updates the global active role, which should propagate via a reactive state mechanism (context, store, or observable) to all consumers. The role-aware bottom navigation must re-render its tab set based on the new active role, and the home screen must swap to its role-specific variant without a full page reload.
The mid-switch navigation edge case requires the state transition to be atomic or cancellable—no intermediate UI state should persist. All interactive elements in the widget need ARIA labels and correct focus management, which must be verified with automated accessibility tooling as part of the test suite.
Acceptance Criteria
- Given a user holds both coordinator and peer mentor roles, When they open the role switch widget, Then both roles are listed as selectable options
- Given a user selects the peer mentor role from the switch widget, When the switch completes, Then the home screen, bottom nav, and all role-gated UI elements update to peer mentor context
- Given a user holds only one role, When they open the role switch widget, Then no switch option is shown and the widget informs them of their single role
- Given a role switch is in progress, When the user navigates away, Then the switch completes or rolls back cleanly without leaving the UI in an inconsistent state
- Given a user with accessibility needs uses the role switch widget, When it renders, Then all interactive elements have proper semantic labels and focus management is correct
Business Value
In smaller chapters, the same volunteer often acts as both peer mentor and coordinator. Requiring them to log out and back in to switch context creates friction that leads to underreporting. Seamless role switching directly addresses the organizations' top priority of minimizing registration effort.
Components
- Role Switch Widget ui
- Role Resolution Service service
- Role State Manager service
- Role Repository data
- Supabase Role Data Provider infrastructure
- Role-Based Home Screen ui
- Role-Aware Bottom Navigation ui
Dependencies
- Role-Specific Home Screen After Login critical
- Role-Aware Bottom Navigation Tabs critical