fix: correct field mapping in child mode onboarding for phone, country and guardian relation#216
Conversation
…y and guardian relation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated child-mode mappings and validations in the Personal Details screen: Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect child-mode field mapping in the Personal Details onboarding flow to prevent corrupt personal info being saved during child registrations (issue #215).
Changes:
- Corrects
phoneNo,guardianRelation, andcountrymappings ingetPersonalInfofor child mode. - Adds manual pre-submit checks in the Continue handler for child
RelationandPatient Genderdropdown selections.
Comments suppressed due to low confidence (1)
patient/lib/presentation/auth/personal_details_screen.dart:130
_validationErrors['country']is rendered in both adult and child country pickers, but this file never sets_validationErrors['country']when the user submits with no country selected. Since this handler is where you’re adding extra validation for dropdowns, it’s a good place to also enforce country selection (and set/clear thecountryvalidation error) so empty countries can’t be submitted silently.
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
if (isAssessmentForChild && selectedRelation.isEmpty) {
setState(() {
_validationErrors['relation'] = 'Please select your relation with the patient';
});
return;
}
if (isAssessmentForChild && (selectedChildGender == null || selectedChildGender!.isEmpty)) {
setState(() {
_validationErrors['gender'] = 'Please select patient gender';
});
return;
}
final personalInfoModel = getPersonalInfo;
final authProvider = context.read<AuthProvider>();
authProvider.storePatientPersonalInfo(personalInfoModel);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@patient/lib/presentation/auth/personal_details_screen.dart`:
- Around line 115-126: The form sets validation entries
_validationErrors['relation'] and _validationErrors['gender'] but the UI only
displays _validationErrors['country'], so users see no feedback when Continue
returns early; update the child-relation dropdown widget and the child-gender
dropdown widget to render their respective error messages from
_validationErrors['relation'] and _validationErrors['gender'] (same style as
country), and in the dropdowns' onSelected/onChanged handlers clear the
corresponding keys from _validationErrors (remove or set to null) and call
setState so the message disappears when the user picks a value; locate
references to selectedRelation, selectedChildGender, and _validationErrors to
apply these changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6ebd823c-c678-4f32-b42b-1a29446fa858
📒 Files selected for processing (1)
patient/lib/presentation/auth/personal_details_screen.dart
Closes #215
📝 Description
In child mode on the Personal Details onboarding screen, three fields in the
getPersonalInfogetter were incorrectly mapped, causing corrupted data to be saved to Supabase on every child-mode registration. Additionally, the Relation and Patient Gender dropdowns were not part of the form validation pipeline, allowing silent submission with empty required fields.🔧 Changes Made
phoneNoto read fromguardianPhoneControllerin child mode instead of always reading the adult form'sphoneControllerguardianRelationto read fromselectedRelation(the dropdown value) instead ofguardianPhoneController.textcountryto read fromselectedChildCountryin child mode instead of always readingselectedCountryfrom the adult formselectedRelationandselectedChildGenderin theonPressedhandler since these areDropdownMenuwidgets and are skipped by_formKey.currentState?.validate()📷 Screenshots or Visual Changes (if applicable)
Not applicable. The bug was in data written to Supabase, not visible in the UI.
🤝 Collaboration
Collaborated with: NONE
✅ Checklist
Summary by CodeRabbit