AOSSIE-Org / AOSSIE-Org/NeuroTrack
BUG: Child mode onboarding saves wrong data to Supabase for phone, country, and guardian relation fields
- 主要语言
- Dart
- 星标
- 29
- 派生
- 50
- PR 合并指标
- 30 天内没有已合并 PR
描述
### 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
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。