Edit Contact Record via Step-by-Step Form
The Edit Contact Screen provides a guided, step-by-step reactive form built with Flutter's Form widget and custom AppTextField components. The form is broken into logical sections to minimise cognitive load — particularly important for peer mentors who may have accessibility needs or low digital literacy. Each section is validated before advancing. Organisation-specific custom fields are dynamically injected by the Custom Fields Table Widget, fetching field definitions (text, select, date types) from the organisation labels system in Supabase at load time. The Contact Management Service enforces RLS-aware data access and field-level validation rules before persisting any changes. Draft state is auto-saved locally in SQLite to prevent data loss on interruption.
User Story
Acceptance Criteria
- Given a user opens the edit contact screen, when the screen loads, then organisation-specific custom fields are fetched from Supabase and rendered with the correct input type (text, select, or date) within 2 seconds
- Given a user enters an invalid value in a field (e.g., malformed phone number), when they attempt to advance to the next step, then an inline error message is shown on the invalid field and progression is blocked
- Given a user partially completes the edit form and navigates away, when they return to the edit screen for the same contact, then their draft data is restored from local SQLite storage
- Given a user completes all steps and submits the form, when the Contact Management Service persists the record, then a success confirmation is shown and the contact detail screen is refreshed
- Given a coordinator edits a contact, when they modify a coordinator-only field, then the field is visible and editable; when a peer mentor edits the same contact, then that field is hidden based on RLS policy
- Given any user is on the edit screen, when a screen reader is active, then each form field has a descriptive label and error messages are announced immediately
Business Value
Accurate, up-to-date contact records are foundational to the quality and continuity of peer mentor support. Without a reliable edit flow, outdated contact information (wrong phone numbers, incorrect health notes, missing custom fields) leads to failed contact attempts and degraded service quality. The step-by-step form design specifically addresses the cognitive accessibility requirement raised by NHF for users with stroke-related cognitive challenges, making the feature inclusive across the full user population.