Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create kids with a single topup instead of rga (kids-857 & kids-858) #847

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class AddMemberCubit extends Cubit<AddMemberState> {

emit(state.copyWith(status: AddMemberStateStatus.loading));
try {
await _addMemberRepository.addMembers(members);
await _addMemberRepository.addMembers(members, isRGA: false);

emit(state.copyWith(status: AddMemberStateStatus.success));
unawaited(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:givt_app/core/network/api_service.dart';
import 'package:givt_app/features/children/add_member/models/member.dart';

mixin AddMemberRepository {
Future<void> addMembers(List<Member> members);
Future<void> addMembers(List<Member> members, {required bool isRGA});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

Update addMembers method call to include isRGA parameter

The method call to addMembers in generosity_challenge_vpc_setup_cubit.dart is missing the isRGA parameter. Please update this call to include the isRGA parameter as required by the new method signature.

  • lib/features/children/generosity_challenge/cubit/generosity_challenge_vpc_setup_cubit.dart: Update the addMembers call to include the isRGA parameter.
Analysis chain

Updated method signature to include isRGA parameter.

This change aligns with the PR's objective to differentiate member creation processes. Ensure that all calls to this method within the codebase are updated to pass the isRGA argument.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `addMembers` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type dart $'addMembers'

Length of output: 1037



Script:

#!/bin/bash
# Description: Verify if the `addMembers` calls in the specified files include the `isRGA` parameter.

# Check the `addMembers` calls in `generosity_challenge_vpc_repository.dart`.
rg --type dart 'addMembers' lib/features/children/generosity_challenge/repositories/generosity_challenge_vpc_repository.dart

# Check the `addMembers` calls in `generosity_challenge_vpc_setup_cubit.dart`.
rg --type dart 'addMembers' lib/features/children/generosity_challenge/cubit/generosity_challenge_vpc_setup_cubit.dart

Length of output: 409


Stream<void> memberAddedStream();
}
Expand All @@ -18,10 +18,11 @@ class AddMemberRepositoryImpl with AddMemberRepository {
StreamController<void>.broadcast();

@override
Future<void> addMembers(List<Member> members) async {
Future<void> addMembers(List<Member> members, {required bool isRGA}) async {
final profilesJsonList = members.map((member) => member.toJson()).toList();
final body = {
'profiles': profilesJsonList,
'allowanceType': isRGA ? 0 : 1,
};

await apiService.addMember(body);
Expand Down
14 changes: 11 additions & 3 deletions lib/features/children/add_member/widgets/add_member_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:givt_app/features/children/add_member/models/member.dart';
import 'package:givt_app/features/children/add_member/utils/member_utils.dart';
import 'package:givt_app/features/children/add_member/widgets/allowance_counter.dart';
import 'package:givt_app/features/children/add_member/widgets/family_text_form_field.dart';
import 'package:givt_app/features/children/edit_child/widgets/giving_allowance_info_button.dart';
import 'package:givt_app/features/children/shared/profile_type.dart';
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/utils/utils.dart';
Expand Down Expand Up @@ -328,10 +327,19 @@ class _AddMemberFormState extends State<AddMemberForm> {
focusNode: widget.ageFocusNode,
),
const SizedBox(height: 10),
const GivingAllowanceInfoButton(),
Padding(
padding: const EdgeInsets.symmetric(vertical: 24),
child: Text(
"Start your child's giving journey by adding funds to their Wallet",
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 16,
),
),
),
AllowanceCounter(
currency: currency,
initialAllowance: _allowance,
initialAllowance: 5,
onAllowanceChanged: (allowance) => _allowance = allowance,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CachedMembersCubit extends Cubit<CachedMembersState> {
emit(state.copyWith(status: CachedMembersStateStatus.noFundsRetrying));
try {
final members = state.members;
await _addMemberRepository.addMembers(members);
await _addMemberRepository.addMembers(members, isRGA: false);

emit(state.copyWith(status: CachedMembersStateStatus.noFundsSuccess));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:givt_app/core/enums/enums.dart';
import 'package:givt_app/features/children/add_member/widgets/giving_allowance_info_bottom_sheet.dart';
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/utils/utils.dart';

class GivingAllowanceInfoButton extends StatelessWidget {
const GivingAllowanceInfoButton({super.key,});
const GivingAllowanceInfoButton({
super.key,
});

@override
Widget build(BuildContext context) {
Expand All @@ -33,7 +34,7 @@ class GivingAllowanceInfoButton extends StatelessWidget {
),
const SizedBox(width: 10),
Text(
context.l10n.createChildGivingAllowanceTitle,
"Start your child's giving journey by addingfunds to their Wallet",
style: Theme.of(context).textTheme.titleMedium!.copyWith(
fontSize: 16,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GenerosityChallengeVpcRepository {
);
}
if (true == session?.isLoggedIn) {
await _addMemberRepository.addMembers(list);
await _addMemberRepository.addMembers(list, isRGA: true);
} else {
throw const NotLoggedInException();
}
Expand Down