Skip to content

Commit

Permalink
Issue 868: Mobile App feature: Add Successor in the case of death to …
Browse files Browse the repository at this point in the history
…profile page (#893)
  • Loading branch information
KarinBerg authored Aug 26, 2024
1 parent cee848c commit d9ce5cf
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 13 deletions.
8 changes: 7 additions & 1 deletion recipients_app/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
"java.configuration.updateBuildConfiguration": "automatic",
"dart.lineLength": 120,
"[dart]": {
"editor.rulers": [
120
],
}
}
13 changes: 11 additions & 2 deletions recipients_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Open `recipients_app` project folder in your development environment of
choice. Building flavor should work seamlessly for Android Studio and VS
Code with predefined build configs.

We have two build flavors:
We have three build flavors:

- `dev` -> Connecting with Firebase Emulators (Firestore and Auth)
- `stage` -> Connecting with staging online firebase project
- `prod` -> Connecting with production online firebase project and need
real Firebase configuration json / plist file

Expand All @@ -31,7 +32,15 @@ setup.

## Rebuilding JSON Serialization

flutter pub run build_runner watch --delete-conflicting-outputs
```
dart run build_runner watch --delete-conflicting-outputs
```

or

```
dart run build_runner build --delete-conflicting-outputs
```

# Testing

Expand Down
1 change: 1 addition & 0 deletions recipients_app/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ linter:
prefer_double_quotes: true
prefer_const_constructors: true
prefer_const_constructors_in_immutables: true
lines_longer_than_80_chars: false

dart_code_metrics:
rules:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion recipients_app/lib/data/models/phone.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions recipients_app/lib/data/models/recipient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class Recipient extends Equatable {
@JsonKey(name: "last_updated_by")
final String? updatedBy;

@JsonKey(name: "successor")
final String? successorName;

// this should be got from `/recipients/<recipient.id>/payments` collection
@JsonKey(includeFromJson: false, includeToJson: false)
final List<SocialIncomePayment>? payments;
Expand All @@ -101,6 +104,7 @@ class Recipient extends Equatable {
this.organizationRef,
this.payments = const [],
this.updatedBy,
this.successorName,
});

@override
Expand All @@ -127,6 +131,7 @@ class Recipient extends Equatable {
organizationRef,
payments,
updatedBy,
successorName,
];
}

Expand All @@ -152,6 +157,7 @@ class Recipient extends Equatable {
DocumentReference? organizationRef,
List<SocialIncomePayment>? payments,
String? updatedBy,
String? successorName,
}) {
return Recipient(
userId: userId ?? this.userId,
Expand All @@ -176,6 +182,7 @@ class Recipient extends Equatable {
organizationRef: organizationRef ?? this.organizationRef,
payments: payments ?? this.payments,
updatedBy: updatedBy ?? this.updatedBy,
successorName: successorName ?? this.successorName,
);
}

Expand Down
2 changes: 2 additions & 0 deletions recipients_app/lib/data/models/recipient.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions recipients_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"@@locale": "en",
"profileUpdateSuccess": "Profile updated successfully",
"profileUpdateError": "Failed to update profile. Please try again or contact our support",
"profile": "Profile",
Expand Down Expand Up @@ -30,6 +31,9 @@
"contactNumber": "Contact Number",
"contactNumberError": "Please enter your contact phone number",
"contactNumberError2": "Please enter a valid phone number. Only numbers are allowed",
"inCaseOfDeathTitle": "⁠In Case of Death",
"inCaseOfDeathDescription": "Who should be the recipient of your Social Income payments if you pass away during the program?",
"successorName": "Successor Name",
"support": "Support",
"supportInfo": "In case you have any questions or problems, please contact us.",
"getInTouch": "Get in touch with us",
Expand Down Expand Up @@ -60,7 +64,6 @@
"call": "Call",
"supportTeam": "Support Team",
"phone": "Phone",
"email": "Email",
"close": "Close",
"whatsappError": "WhatsApp not installed",
"paymentsConfirmedCount": "payments received",
Expand Down Expand Up @@ -160,7 +163,7 @@
"placeholders": {
"done": {
"type": "int"
},
},
"all": {
"type": "int"
}
Expand Down Expand Up @@ -250,7 +253,7 @@
"secondFactorAlreadyEnrolled": "Second factor already enrolled",
"secondFactorLimitExceeded": "Maximum second factor count exceeded",
"tenantIdMismatch": "Tenant ID mismatch",
"timeoutError": "Timeout",
"timeoutError": "Timeout",
"tokenExpired": "User token expired",
"tooManyAttemptsTryLater": "Too many requests, try again later",
"unauthorizedDomain": "Unauthorized domain for resource",
Expand Down
6 changes: 4 additions & 2 deletions recipients_app/lib/l10n/app_kri.arb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"contactNumber": "Nɔmba we fɔ kɔl yu",
"contactNumberError": "Duya put yu fon nɔmba ya",
"contactNumberError2": "Put di fon nɔmba prɔpa wan ɛn tayp di nɔmba dɛm nɔmɔ.",
"inCaseOfDeathTitle": "⁠If yu day",
"inCaseOfDeathDescription": "Udat na di pɔsin we wi fɔ gi yu Social Income pemɛnt if yu day we di program nɔ dɔn yet? Yu wɛf, pikin, mama, papa, brɔda ɔ sista",
"successorName": "Wetin na in nem?",
"support": "Yu want ɛp",
"supportInfo": "If yu get ɛni kwɛstyɔn ɔ di fesin prɔblɛm, duya rich awt to wi.",
"getInTouch": "Mek wi no aw yu fil",
Expand Down Expand Up @@ -61,7 +64,6 @@
"call": "Kɔl",
"supportTeam": "Sɔpɔt Tim",
"phone": "Fon",
"email": "Imel",
"close": "Lɔk am",
"whatsappError": "Wasap nɔ go insay yu fon yet",
"paymentsConfirmedCount": "Pemɛnt dɛn we yu dɔn gɛt",
Expand Down Expand Up @@ -162,7 +164,7 @@
"placeholders": {
"done": {
"type": "int"
},
},
"all": {
"type": "int"
}
Expand Down
34 changes: 31 additions & 3 deletions recipients_app/lib/view/pages/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AccountPageState extends State<AccountPage> {
late final TextEditingController _callingNameController;
late final TextEditingController _paymentNumberController;
late final TextEditingController _contactNumberController;
late final TextEditingController _successorNameController;
late final TextEditingController _emailController;

PackageInfo _packageInfo = PackageInfo(
Expand Down Expand Up @@ -74,6 +75,9 @@ class AccountPageState extends State<AccountPage> {
_contactNumberController = TextEditingController(
text: widget.recipient.communicationMobilePhone?.phoneNumber.toString() ?? "",
);
_successorNameController = TextEditingController(
text: widget.recipient.successorName ?? "",
);

_initAppVersionInfo();

Expand Down Expand Up @@ -301,7 +305,9 @@ class AccountPageState extends State<AccountPage> {
final emailRegex = RegExp(
r"^[\w-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,})$",
);
if (!emailRegex.hasMatch(value)) return localizations.errorEmailInvalid;
if (!emailRegex.hasMatch(value)) {
return localizations.errorEmailInvalid;
}

return null;
},
Expand Down Expand Up @@ -397,6 +403,7 @@ class AccountPageState extends State<AccountPage> {
}
},
),
const SizedBox(height: 24),
// TODO add later
/*const SizedBox(height: 8),
DropdownButtonFormField<String>(
Expand All @@ -416,9 +423,30 @@ class AccountPageState extends State<AccountPage> {
: null,
), */

/// SUCCESSOR IN THE CASE OF DEATH
Text(
localizations.inCaseOfDeathTitle,
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(height: 16),
Text(
localizations.inCaseOfDeathDescription,
style: Theme.of(context).textTheme.bodySmall,
),
const SizedBox(height: 16),
InputText(
hintText: localizations.successorName,
controller: _successorNameController,
keyboardType: TextInputType.name,
onSubmitted: (value) {
context.read<AuthCubit>().updateRecipient(
recipient.copyWith(successorName: value),
);
},
),

/// RECOMMENDING ORGA
if (widget.organization != null)
OrganizationInfo(organization: widget.organization!),
if (widget.organization != null) OrganizationInfo(organization: widget.organization!),
const SizedBox(height: 24),
Text(
localizations.support,
Expand Down

0 comments on commit d9ce5cf

Please sign in to comment.