Org Hierarchy Navigator: Tree Widget and Expansion State
epic-admin-portal-core-services-task-013 — Build the OrgHierarchyNavigator Flutter widget with an expandable/collapsible tree view. Each node renders name and type (national/regional/chapter). Expansion state is managed locally. Nodes emit a selected-node event consumed by parent BLoC for data scoping. Uses OrgHierarchyService for tree data.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Use a recursive widget pattern: OrgHierarchyNavigator holds a Map
The BLoC integration point is a single onNodeSelected(OrgNode node) callback injected by the parent screen; the widget itself must remain BLoC-agnostic to maximise reusability. Ensure the OrgHierarchyService call is initiated once in initState and result cached in widget state; do not re-fetch on every expansion event.
Testing Requirements
Write widget tests (flutter_test) covering: (1) tree renders correct node count for a 3-level mock hierarchy; (2) tapping chevron toggles child visibility and persists state across rebuilds; (3) tapping a node fires onNodeSelected with the correct node ID; (4) loading state shows shimmer; (5) error state shows retry button and re-fetches on tap. Performance smoke test: render a 200-node flat list and assert no overflow errors in debugCheckHasNoOverflow. All tests must pass on both iOS (Simulator) and Android (Emulator) CI runners.
OrgHierarchyNavigator rendering NHF's full 1,400-chapter tree in a single widget may cause Flutter frame-rate drops below 60 fps on mid-range devices, making the navigator unusable for NHF national admins.
Mitigation & Contingency
Mitigation: Implement lazy expansion: only load immediate children on node expand rather than the full tree upfront. Use virtual scrolling for long sibling lists. Test with a synthetic 1,400-node dataset on a low-end Android device during development.
Contingency: If lazy expansion is insufficient, replace the tree widget with a paginated drill-down navigator (select level → select child) that avoids rendering more than 50 nodes at a time.
Bufdir may update their required export column structure or file format during or after development. If the AdminExportService hardcodes the current Bufdir schema, any format change requires a code release rather than a config update.
Mitigation & Contingency
Mitigation: Drive the Bufdir column mapping from a configuration repository rather than hardcoded constants. Abstract column definitions into a named schema config so that format changes require only a config update and re-deployment without service logic changes.
Contingency: If Bufdir format changes post-launch, release a config update within one sprint. If the change is structural (new required sections), scope a targeted service update and communicate timeline to partner organisations.
Role transition side-effects in UserManagementService (e.g., certification expiry removing mentor from chapter listing, pause triggering coordinator notification) may interact with external services like HLF's website sync. Incomplete side-effect handling could leave the system in an inconsistent state.
Mitigation & Contingency
Mitigation: Model side-effects as explicit domain events published after the primary state change is persisted. Implement event handlers as idempotent operations so re-processing is safe. Write integration tests that assert all side-effects fire correctly for each role transition type.
Contingency: If a side-effect fails after the primary change is persisted, log the failure with full context and trigger a manual reconciliation alert to the on-call team. Provide an admin-accessible re-trigger action for failed side-effects.
If AdminStatisticsService cache TTL is set too long, org_admin may see significantly stale KPI values (e.g., a mentor newly paused an hour ago still appears as active), undermining trust in the dashboard.
Mitigation & Contingency
Mitigation: Default cache TTL to 5 minutes with a manual refresh action on the dashboard. Implement cache invalidation triggered by UserManagementService write operations that affect counted entities.
Contingency: If staleness causes org admin complaints post-launch, reduce TTL to 60 seconds and introduce a real-time Supabase subscription for high-impact counters (paused mentors, expiring certifications).