Integrate template pre-fill into registration screen
epic-coordinator-proxy-registration-core-task-007 — Add the RecurringTemplateSelector as an optional pre-fill affordance at the top of ProxyRegistrationScreen. When the coordinator selects a template, map RecurringTemplate fields onto the form state (activity type, duration, notes). Ensure manual edits after pre-fill are fully preserved and do not re-trigger template overwrite.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Add `applyTemplate(RecurringTemplate template)` method to `ProxyRegistrationFormCubit`: emit a new state via `copyWith(activityTypeId: template.activityTypeId, durationMinutes: template.defaultDurationMinutes, notes: template.notesTemplate, isDirty: true)`. This is a pure state update — no conditional logic needed because `copyWith` only updates the specified fields. The key correctness property is that `applyTemplate` only touches the three template-derived fields, leaving all other fields unchanged. In the screen, pass `onTemplateSelected: context.read
Wrap the RecurringTemplateSelector in an `AnimatedSize` widget to smoothly handle the transition between loading/empty/populated states without layout jumps.
Testing Requirements
Widget tests extending the ProxyRegistrationScreen test file from task-006. Add test cases: (1) RecurringTemplateSelector is present in the widget tree, (2) selecting a template updates the activity type dropdown and duration field to match the template, (3) editing the duration field after template selection retains the edited value on next rebuild, (4) selecting a second template does not overwrite a manually set date. Also add a cubit unit test for `applyTemplate()`: verify all three fields (activityTypeId, durationMinutes, notes) are updated and date/startTime/selectedMentorId are unchanged.
The 2-hour window duplicate detection logic requires querying existing proxy records with compound key matching (mentor + date + activity type within time range). If the query is too broad it produces false positives that frustrate coordinators; if too narrow it misses genuine duplicates that corrupt Bufdir data.
Mitigation & Contingency
Mitigation: Define the duplicate detection window as a configurable parameter from the start. Prototype the Supabase query with representative data covering edge cases (midnight boundaries, different activity types same day, same activity type different mentors) before finalising the implementation.
Contingency: If the detection produces excessive false positives in UAT, allow coordinators to explicitly acknowledge and bypass the duplicate warning with a reason field, preserving safety while reducing friction.
If the proxy registration form does not clearly distinguish between the acting coordinator and the attributed mentor, coordinators may submit records attributing activities to themselves, causing inaccurate Bufdir reporting and potential funding issues.
Mitigation & Contingency
Mitigation: Conduct UAT with at least one real coordinator via TestFlight before release. Use distinct visual treatment (different card colours, explicit 'Registering on behalf of:' label) and require the confirmation screen to show both identities prominently.
Contingency: Add a mandatory confirmation checkbox on the confirmation screen that explicitly names the attributed mentor, preventing accidental self-attribution from slipping through.
Coordinators with multi-chapter access must select an active chapter context before the mentor list is filtered correctly. If chapter scope resolution fails or is bypassed, cross-org proxy registrations could occur, violating data isolation between chapters.
Mitigation & Contingency
Mitigation: Reuse the existing active-chapter-state and hierarchy-service components established by the org hierarchy feature. Add a guard that blocks entry to the proxy flow if no chapter context is active, prompting chapter selection first.
Contingency: If the chapter resolution service is unavailable, default to the most restrictive scope (no mentors visible) and surface a clear error message rather than showing an unfiltered mentor list.