Wire dialog to consent service and handle decision
epic-geographic-peer-mentor-map-consent-privacy-task-007 — Connect the location-consent-dialog to location-consent-service so that tapping Opt In calls grantConsent and tapping Opt Out calls a denial record write, then navigates the mentor to the appropriate next screen. Integrate Riverpod state so downstream widgets reactively observe ConsentStatus. Ensure the dialog is shown only once per mentor per organisation unless consent is revoked and re-prompted.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 4 - 323 tasks
Can start after Tier 3 completes
Implementation Notes
Create a ConsentStatusNotifier extending AsyncNotifier
Avoid storing consent status in flutter_secure_storage — the Supabase database is the authoritative store; the Riverpod provider is just a runtime cache. For the loading state inside buttons, use a local ValueNotifier
Testing Requirements
Unit tests using ProviderContainer: mock location-consent-service, simulate Opt In tap → assert grantConsent called with correct args, assert provider transitions to granted. Simulate Opt Out → assert recordDenial called, provider transitions to denied. Simulate service failure → assert provider stays in previous state, error is surfaced. Widget integration test: render the parent screen with a mock provider, assert dialog is shown when status is pending, assert dialog is NOT shown when status is granted.
Test navigation: use a NavigatorObserver mock to assert correct route pushed after each decision. Test double-tap prevention: simulate rapid double-tap on Opt In and assert grantConsent called exactly once.
If the privacy policy text or consent terms change after mentors have already opted in, existing consent records may become legally insufficient, requiring re-consent from all opted-in mentors which could temporarily reduce map coverage.
Mitigation & Contingency
Mitigation: Store a consent_version field on every consent record. Implement a consent version check in location-consent-service that compares the stored version against the current policy version from location-privacy-config and flags stale consents for re-consent prompting.
Contingency: If a policy update invalidates existing consents, suppress affected mentors from the map, queue them for re-consent notification via the existing in-app notification system, and restore map visibility only after new consent is recorded.
A poorly designed consent dialog may lead to low opt-in rates, reducing map utility for coordinators to the point where the feature delivers insufficient value to justify maintenance cost.
Mitigation & Contingency
Mitigation: Follow plain-language writing guidelines from the cognitive accessibility feature. User-test the dialog with 2-3 peer mentors from Blindeforbundet before implementation is finalised. Ensure the dialog explains the benefit to the mentor, not just the data collection facts.
Contingency: If opt-in rate after launch is below 40%, conduct a targeted usability study and iterate on dialog copy and layout. The coordinator can also send a bulk opt-in invitation notification (per the user story) to non-consenting mentors.