AOSSIE-Org / AOSSIE-Org/NeuroTrack
BUG: Child mode onboarding saves wrong data to Supabase for phone, country, and guardian relation fields
- Ngôn ngữ chính
- Dart
- Star
- 29
- Fork
- 50
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Is there an existing issue for this?
- [x] I have searched the existing issues
### What happened?
## 📌 Issue Overview
In the Patient App's Personal Details screen, selecting "For my child" mode causes three fields to be incorrectly mapped in the `getPersonalInfo` getter, silently corrupting every child-mode registration saved to Supabase.
- `guardianRelation` is assigned `guardianPhoneController.text` instead of `selectedRelation`. The dropdown value is captured but never read.
- `phoneNo` is hardcoded to `phoneController.text` (the adult controller), which is always empty in child mode.
- `country` always reads `selectedCountry` (adult picker). `selectedChildCountry` is set correctly by the child form but ignored in the getter.
Additionally, the Relation and Patient Gender dropdowns are plain `DropdownMenu` widgets, so `_formKey.currentState?.validate()` skips them entirely. A user can submit with no relation or gender selected and it passes silently.
## 🔍 Steps to Reproduce
1. Open the Patient App and sign in
2. On the Personal Details screen, select **For my child** from the "Assessment is for?" dropdown
3. Fill in child name, child age, select relation "Guardian", select gender "Male", enter guardian phone `+911234567890`, and pick a country e.g. India
4. Tap **Continue**
5. Check the `patient` table row in Supabase
## 🎯 Expected Behavior
| Field | Expected |
|---|---|
| `guardian_relation` | `"Guardian"` |
| `phone` | `"+911234567890"` |
| `country` | `"India"` |
| `gender` | `"Male"` |
## 🚨 Actual Behavior
| Field | Actual |
|---|---|
| `guardian_relation` | `"+911234567890"` (phone stored as relation) |
| `phone` | `""` (always empty in child mode) |
| `country` | `""` (always empty, child picker ignored) |
| `gender` | `""` (dropdown bypasses form validation) |
Root cause in `patient/lib/presentation/auth/personal_details_screen.dart`:
```dart
// guardianRelation gets the phone number, selectedRelation is never read
guardianRelation: isAssessmentForChild ? guardianPhoneController.text : phoneController.text,
// phoneNo always reads the adult controller, empty in child mode
phoneNo: phoneController.text,
// always reads adult country picker, selectedChildCountry is ignored
country: selectedCountry?.displayName ?? '',
```
## 📷 Screenshot
Not applicable. The corruption is in the data written to Supabase, not visible in the UI.
## 💡 Suggested Improvements
Fix the `getPersonalInfo` getter to branch correctly on `isAssessmentForChild`:
```dart
phoneNo: isAssessmentForChild ? guardianPhoneController.text : phoneController.text,
guardianRelation: isAssessmentForChild ? selectedRelation : '',
country: isAssessmentForChild
? selectedChildCountry?.displayName ?? ''
: selectedCountry?.displayName ?? '',
```
Add pre-submission checks for `selectedRelation` and `selectedChildGender` in the `onPressed` handler since they are `DropdownMenu` widgets and are skipped by `_formKey.currentState?.validate()`.
### Record
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.