View Personal Statistics as a Peer Mentor Role
The personal stats view is a role-specific view of the statistics dashboard that shows only the authenticated peer mentor's data. It must use role-based access validation to ensure peer mentors cannot access coordinator-level aggregation data or other mentors' statistics. The view should present data in an encouraging, motivating manner aligned with the gamification goals outlined in the requirements. Access is controlled by the role-access-validator component which checks Supabase RLS policies.
User Story
Acceptance Criteria
- Given I am logged in as a peer mentor, When I navigate to the statistics screen, Then I see my personal statistics view and there is no option to view other mentors' data or organizational aggregations
- Given I am viewing my personal stats, When I pull to refresh, Then the data reloads from Supabase and the cache is invalidated and updated
- Given a coordinator is logged in and switches to the statistics tab, When they view the screen, Then they see the coordinator dashboard rather than the personal stats view
- Given I am a peer mentor with the org-admin role, When I view the statistics screen, Then the role-access-validator correctly routes me to the appropriate view based on my active role
- Given Supabase RLS policies are in place, When I attempt to query another mentor's stats directly, Then the query returns no data and the system does not expose unauthorized information
Business Value
Role-scoped statistics views are critical for data privacy compliance, particularly given that NHF handles sensitive information about members with disabilities and HLF processes certification and health-related data. Ensuring peer mentors only see their own data builds trust in the platform and satisfies GDPR requirements for data minimization and purpose limitation.
Components
- Personal Peer Mentor Statistics View ui
- Personal Statistics Service service
- Role Access Validator service
- Personal Statistics BLoC infrastructure
- Stats Repository data
- Supabase Stats Database Views infrastructure
- Stats Cache Invalidator infrastructure
- Statistics Cache Manager data