Map internal activity category IDs to Bufdir field labels
epic-bufdir-report-preview-foundation-task-006 — Implement the mapping table in BufdirReportStructureMapper that converts the app's internal activity category IDs (as stored in Supabase) to the official Bufdir field labels and section positions. Cover all active activity categories across NHF, Blindeforbundet, and HLF. Include explicit handling for unmapped or unknown category IDs — log a warning and render a placeholder rather than crashing. Expose a pure function `mapCategoryToField(String categoryId) -> BufdirFieldDefinition?`.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
Declare the mapping as `const Map
Consider a script or test that reads category IDs from Supabase and asserts 100% mapping coverage to prevent future regressions when new categories are added.
Testing Requirements
Unit tests: parametrised test covering every known category ID → assert non-null result with correct fieldKey and section. Test one unknown ID → assert null return and no exception. Test that the mapping Map contains no duplicate keys. Integration check: query Supabase activity_categories in a test environment and assert every active category_id has a mapping entry (catches drift between DB and code).
The preview repository depends on aggregated data produced by the Bufdir Data Aggregation feature. If the aggregation RPC schema or Supabase view columns change during parallel development, the repository's typed Dart models will break, causing compile errors or runtime null-dereference failures.
Mitigation & Contingency
Mitigation: Define a shared Dart interface (abstract class) for the aggregated data contract early and have both features code against it. Use Supabase typed generated clients so schema mismatches surface at code generation time rather than runtime.
Contingency: If the aggregation schema changes after the repository is complete, run `supabase gen types dart` immediately, update the repository model, and run repository unit tests before unblocking UI development. Keep a mock data fixture so UI work can continue during the fix.
The BufdirReportStructureMapper must map internal activity category IDs to the exact label strings used on the official Bufdir reporting form. If the mapping is incomplete or uses outdated labels, coordinators will see mismatches when cross-referencing the preview with the paper form, potentially leading to incorrect submissions.
Mitigation & Contingency
Mitigation: Obtain the current Bufdir reporting form PDF directly from Bufdir (Norse Digital Products has an existing Bufdir dialogue). Extract all field labels and section names into a static constants file reviewed by at least one coordinator from NHF or HLF before implementation begins.
Contingency: If incorrect labels are discovered during UAT on TestFlight, update the static constants file and redeploy. Because the mapper is a pure Dart class with no database storage, corrections require no migration — only a new build.