Implement BulkRegistrationDefaultsProvider
epic-proxy-activity-registration-foundation-task-010 — Implement `BulkRegistrationDefaultsProvider` as a Riverpod StateNotifierProvider that pre-populates form defaults for bulk registration: today's date, 30-minute duration, the coordinator's organisation id, and the last-used activity type. Persist last-used values to SharedPreferences so they survive app restarts. Expose `reset()` and `applyDefaults(BulkRegistrationRequest)` helpers.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 2 - 518 tasks
Can start after Tier 1 completes
Implementation Notes
Use StateNotifier
The applyDefaults() method should follow a 'fill-in-blanks' pattern: iterate over BulkRegistrationRequest fields and substitute defaults only where the field is null. Keep SharedPreferences interaction behind an abstraction (e.g., DefaultsPersistence interface) so unit tests can inject a fake without platform channel overhead.
Testing Requirements
Unit tests with flutter_test and a mocked SharedPreferences instance (using shared_preferences_platform_interface test stubs). Test scenarios: (1) fresh install — verify all defaults match specification; (2) persist activity type after registration — verify correct key is written; (3) cold restart — verify activity_type is restored, date is today (not persisted date), duration is 30 min; (4) reset() — verify state reverts to spec defaults; (5) applyDefaults() with a fully populated request — verify no fields are overwritten; (6) applyDefaults() with a partially populated request — verify only null/unset fields are filled; (7) coordinator account change — verify org id updates to new coordinator's org.
The activities table migration adding registered_by and attributed_to columns may conflict with existing RLS policies or FK constraints if the user profile table structure differs from assumptions, blocking all subsequent epics.
Mitigation & Contingency
Mitigation: Review existing activities table schema and RLS policies before writing the migration. Run the migration against a staging database clone first. Write rollback scripts alongside the migration.
Contingency: If migration fails in staging, isolate the conflict with a targeted schema audit, adjust FK references or RLS policy scope, and re-run before touching production.
The RLS policy must filter proxy inserts to the coordinator's chapter scope. If the chapter-scope resolver pattern differs between organisations (multi-chapter coordinators in NHF vs single-chapter in HLF), the policy may be too broad or too restrictive.
Mitigation & Contingency
Mitigation: Design the RLS policy to accept a coordinator's full set of assigned chapter IDs (array) rather than a single chapter_id. Validate the policy against NHF multi-chapter test fixtures during the integration test phase.
Contingency: If the policy is found to be incorrect after deployment, introduce a server-side validation edge function as a safety net while the RLS policy is corrected.
The bulk_register_activities RPC function may time out or cause lock contention when inserting large participant batches (e.g. 40+ peer mentors in a single group session), degrading the user experience.
Mitigation & Contingency
Mitigation: Benchmark the RPC function with 50-participant batches during development. Use unnest-based bulk insert rather than row-by-row PL/pgSQL loops. Set a reasonable statement_timeout.
Contingency: If performance is insufficient, split the client-side submission into chunks of 20 participants with progress feedback, rather than a single RPC call.