Implement Export History Panel widget
epic-accounting-system-export-ui-task-003 — Build the ExportHistoryPanel widget that fetches and displays past export runs for the current organisation. Each row shows: export date, period covered, exporter type (Xledger/Dynamics), claim count, status (success/partial/failed), and a download button that triggers file download. Panel must support pull-to-refresh and an empty-state illustration when no exports exist. Depends on the ExportRunRepository (323) being available via Riverpod provider.
Acceptance Criteria
Technical Requirements
Implementation Notes
Define an ExportRun data class (id, orgId, exportDate, periodStart, periodEnd, exporterType enum, claimCount, status enum, fileKey) β do not reuse a database model directly in the UI layer. Riverpod provider should be a family provider keyed by orgId to support multi-org scenarios. The download flow: (1) set row-level loading state, (2) call repository.getSignedDownloadUrl(exportRun.fileKey), (3) call launchUrl(), (4) reset loading state. Handle PlatformException from url_launcher gracefully with a snackbar.
Avoid nested ListView inside a parent scroll β use CustomScrollView with SliverList or pass physics: NeverScrollableScrollPhysics() with shrinkWrap if embedded inside a Column. The RefreshIndicator must wrap the outermost scrollable to work correctly.
Testing Requirements
Unit tests: mock ExportRunRepository and verify provider emits correct AsyncValue states (loading, data, error). Widget tests: pump panel with mock data containing all three status types and verify correct chip colors; test empty state renders when list is empty; test error state shows retry button; test download button disabled for failed status. Integration test: stub Supabase Storage signed-URL call and verify url_launcher is invoked with the correct URL on download tap. Pull-to-refresh: widget test triggering RefreshIndicator and verifying repository.getExportHistory() is called again.
Accessibility: verify Semantics descriptors on rows and download button using the semantics tester. Target 85%+ widget test coverage.
Export operations may take several seconds, and the UI must handle all intermediate states (loading, partial success, failure, duplicate warning) without leaving the coordinator on a blank or unresponsive screen. Missing state handling causes confusion and potentially double-submissions.
Mitigation & Contingency
Mitigation: Design the BLoC state machine with explicit states for each transition before writing any widget code: ExportIdle, ExportDuplicateWarning, ExportInProgress, ExportSuccess, ExportPartialSuccess, ExportFailed. Each state maps to a distinct UI. Widget tests cover all states.
Contingency: If a loading state is missed in production, surface a generic error state with a retry action rather than leaving the UI stuck. Add a timeout on the Edge Function call (default 30 seconds) that transitions to ExportFailed with a user-readable message.
The custom Export Date Range Picker may not be fully navigable with VoiceOver if the underlying Flutter date widgets do not expose the correct semantic tree. This is a critical accessibility failure for Blindeforbundet users who rely on screen readers.
Mitigation & Contingency
Mitigation: Use Flutter's built-in DateRangePicker as the base and wrap with explicit Semantics nodes for start and end labels. Test with VoiceOver on a physical iOS device as part of the definition of done for this component. Reference the existing AccessibilityTestHarness pattern used elsewhere in the app.
Contingency: If the custom picker fails accessibility audit, replace it with two independent DatePicker fields (start and end) using Flutter's standard accessible date input, which has broader VoiceOver support than range variants.