Implement NotificationDetailView — peer mentor layout
epic-certificate-expiry-notifications-user-interface-task-009 — Build the NotificationDetailView screen for the peer mentor role. Display certificate name, expiry date, and the ExpiryStatusIndicator in full mode. Include a view-certification-status action button that navigates to the certification status screen. The view reads data from the BLoC state and is role-gated so coordinators are not rendered this layout.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Structure the screen as a composition of: NotificationDetailView (route shell with BlocBuilder) → _PeerMentorDetailLayout (stateless child) and _CoordinatorDetailLayout (stateless child from task-010). The parent screen selects the correct layout based on role before building. This keeps each layout independently testable. For the expiry date formatting, use the intl package (already likely in pubspec for Flutter) with DateFormat('dd.MM.yyyy') or equivalent.
The 'View certification status' route name/path must match the router configuration — do not hardcode path strings; use a route constants file. Confirm with the team whether the certification status screen already exists or is a future task, and use a placeholder route if needed.
Testing Requirements
Widget tests using flutter_test. Cover: (1) peer mentor role renders certificate name, expiry date, and full-mode ExpiryStatusIndicator, (2) coordinator role does NOT render the peer mentor layout (assert widget absent from tree), (3) tapping 'View certification status' triggers the correct navigation action (use NavigatorObserver or GoRouter override), (4) Loading BLoC state shows loading indicator, (5) Error BLoC state shows error message and retry button, (6) Semantics check on navigation button and status indicator. Also write one integration-level test (using flutter_test with a faked router) to verify the full navigation flow from NotificationDetailView to the certification status screen.
The persistent banner must remain visible across app sessions and only disappear when a specific backend condition is met (renewal or coordinator acknowledgement). If the BLoC state is not properly sourced from the notification record repository on every app launch, the banner may disappear prematurely or fail to reappear after a session restart.
Mitigation & Contingency
Mitigation: Drive the banner's visibility exclusively from a Supabase real-time subscription on the notification records table filtered by mentor_id and acknowledged_at IS NULL. Never persist banner visibility state locally. Write an integration test that restarts the BLoC and verifies the banner reappears from the database source.
Contingency: If real-time subscriptions introduce latency or connection reliability issues in offline-first scenarios, add a local cache flag that is only cleared when the repository confirms the acknowledgement write succeeded, with a cache TTL of 24 hours as a fallback.
The notification detail view must conditionally render coordinator-specific actions based on the authenticated user's role. Incorrect role resolution could expose the 'Acknowledge Lapse' action to peer mentors or hide it from coordinators, breaking the workflow and potentially allowing unauthorised state changes.
Mitigation & Contingency
Mitigation: Source the role check from the existing role_state_manager BLoC that is already authenticated against Supabase role claims. Do not rely on a local flag. The coordinator acknowledgement service backend also validates role server-side, providing defence in depth. Add widget tests that render the detail view with mentor and coordinator role fixtures and assert the presence or absence of coordinator actions.
Contingency: If a role resolution bug is found in production, immediately disable the acknowledge action via a feature flag and patch the role check in a hotfix release. The server-side validation in the coordinator acknowledgement service ensures no actual state change can occur even if the button is incorrectly rendered.