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

Fix: Button padding and search feature for box origin (KIDS-1569) #1237

Merged
merged 5 commits into from
Nov 7, 2024

Conversation

Daniela510
Copy link
Contributor

@Daniela510 Daniela510 commented Nov 6, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced selection management in the Organisation List, allowing users to visually differentiate selected items.
    • Introduced a new callback for filter changes in the Organisation Filter Tiles, improving interaction.
    • Updated error handling with localized messages displayed via SnackBar.
    • Improved event handling for successful giving actions, enhancing data flow.
  • Bug Fixes

    • Disabled tap actions on items in the Organisation List to prevent unintended selections.
  • Refactor

    • Renamed the floating action button property to buttonText for clarity.
    • Updated the layout structure for improved user interaction and experience.
    • Clarified callback names for better readability and maintenance.

@Daniela510 Daniela510 requested a review from a team as a code owner November 6, 2024 16:33
Copy link
Contributor

coderabbitai bot commented Nov 6, 2024

Walkthrough

The changes made in this pull request primarily involve modifications to the BoxOriginSelectionPage, OrganisationListFamilyPage, and related components. Key alterations include replacing the onTap callback in OrganisationListFamilyPage with onTapListItem and onTapFunButton, renaming the fab property to buttonText, and updating the logic for organization selection to utilize the MediumCubit. Enhanced error handling and state management improvements are also evident across the affected files.

Changes

File Path Change Summary
lib/features/family/features/box_origin/box_origin_selection_page.dart - Replaced onTap with onTapListItem for OrganisationListFamilyPage.
- Renamed fab to buttonText and updated related properties.
- Modified _onTapConfirm to retrieve selected namespace from MediumCubit.
lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart - Updated constructor to include onTapListItem and onTapFunButton.
- Renamed fab to buttonText and added analyticsEvent.
- Introduced selectedCollectgroup variable and updated initState method.
- Replaced Scaffold with FunScaffold and modified error handling with SnackBar.
lib/features/family/shared/design/components/content/fun_organisation_filter_tile_bar.dart - Added import for CollectGroupType.
- Introduced onFilterChanged callback and modified onClick logic.
lib/shared/bloc/organisation/organisation_bloc.dart - Updated _onTypeChanged to prevent filtering by CollectGroupType.none.index.
- Enhanced error handling in _onOrganisationFetch and _onFilterQueryChanged.
lib/features/family/features/parent_giving_flow/presentation/pages/give_from_list_page.dart - Renamed onTap to onTapListItem in OrganisationListFamilyPage and updated listener for BlocConsumer.

Assessment against linked issues

Objective Addressed Explanation
Add behaviour tracking to Amplitude (KIDS-1569) No changes related to behaviour tracking were made.
Add technical logging to Logit (KIDS-1569) No logging functionality was introduced in the PR.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • TammiLion
  • MaikelStuivenberg

Poem

In the land of code where rabbits play,
Changes hop in a bright new way.
Buttons renamed, selections in sight,
User paths clearer, interactions bright.
With a tap now silent, we cheer and dance,
For every small change gives us a chance! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b0a682e and a42e2ac.

📒 Files selected for processing (1)
  • lib/features/family/features/box_origin/box_origin_selection_page.dart (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/features/family/features/box_origin/box_origin_selection_page.dart

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the bug Something isn't working label Nov 6, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 28f8162 and 4d84afb.

📒 Files selected for processing (2)
  • lib/features/family/features/box_origin/box_origin_selection_page.dart (1 hunks)
  • lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart (6 hunks)
🧰 Additional context used
📓 Learnings (1)
lib/features/family/features/box_origin/box_origin_selection_page.dart (1)
Learnt from: Daniela510
PR: givtnl/givt-app#1234
File: lib/features/family/features/box_origin/box_origin_selection_page.dart:60-98
Timestamp: 2024-11-05T17:30:27.414Z
Learning: In the `BoxOriginSelectionPage` (`lib/features/family/features/box_origin/box_origin_selection_page.dart`), error handling and state management are handled within the cubit's methods, so adding try-catch blocks in the UI layer is unnecessary.
🔇 Additional comments (6)
lib/features/family/features/box_origin/box_origin_selection_page.dart (2)

Line range hint 43-52: LGTM! Improved naming from 'fab' to 'button'.

The button configuration is properly maintained with all necessary properties:

  • Disabled state tied to selection
  • Loading state
  • Analytics tracking
  • Clear action handler

Line range hint 48-52: Analytics implementation aligns with PR objectives.

The code successfully implements behavior tracking using Amplitude as required:

  1. Tracks button clicks with boxOriginConfirmClicked
  2. Tracks selections with boxOriginSelected including relevant properties (namespace and organization name)

Also applies to: 61-67

lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart (4)

23-23: LGTM: Property renaming improves clarity

The renaming from fab to button better reflects its purpose and maintains consistency across components.

Also applies to: 29-29


38-38: LGTM: Selection state management

The selectedIndex state variable properly manages the selected item state.


Line range hint 59-82: LGTM: UI improvements enhance consistency

The changes improve the UI by:

  • Using FunScaffold for consistent styling
  • Explicit dependency injection with getIt
  • Better button placement at the bottom

Also applies to: 94-96, 125-126


138-138: LGTM: Selection styling implementation

The selection styling is well-implemented with:

  • Clear visual feedback using selectedTileColor
  • Proper type-based color handling

Also applies to: 144-146

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
lib/features/family/shared/design/components/content/fun_organisation_filter_tile_bar.dart (1)

41-43: Improve code readability with explicit variables

The ternary operation could be more readable with explicit variable names to clarify the toggle behavior.

Consider this refactoring:

-state.selectedType == e.index
-    ? CollectGroupType.none.index
-    : e.index,
+final isAlreadySelected = state.selectedType == e.index;
+final newTypeIndex = isAlreadySelected 
+    ? CollectGroupType.none.index 
+    : e.index;
+newTypeIndex,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4d84afb and 2eea910.

📒 Files selected for processing (4)
  • lib/features/family/features/box_origin/box_origin_selection_page.dart (1 hunks)
  • lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart (6 hunks)
  • lib/features/family/shared/design/components/content/fun_organisation_filter_tile_bar.dart (2 hunks)
  • lib/shared/bloc/organisation/organisation_bloc.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/features/family/features/box_origin/box_origin_selection_page.dart
🔇 Additional comments (6)
lib/features/family/shared/design/components/content/fun_organisation_filter_tile_bar.dart (1)

3-3: LGTM: Import addition is appropriate

The new import for CollectGroupType is necessary for the type deselection functionality.

lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart (4)

23-29: LGTM! Property changes improve flexibility and clarity.

The renaming of fab to button and making onTap nullable enhances the component's reusability and clarity.


94-96: LGTM! Good use of dependency injection.

The change to use getIt for accessing the OrganisationBloc is a good practice.


139-147: LGTM! Good visual feedback implementation.

The selection state and type-specific colors provide clear visual feedback to users.


43-46: ⚠️ Potential issue

Add analytics tracking for organization fetching.

As per PR objectives, Amplitude tracking should be implemented. Consider adding analytics when organizations are fetched.

Add this after the OrganisationFetch event:

 getIt<OrganisationBloc>().add(
   OrganisationFetch(
     Country.fromCode(context.read<AuthCubit>().state.user.country),
     type: CollectGroupType.none.index,
   ),
 );
+getIt<AmplitudeAnalytics>().logEvent(
+  'organization_list_viewed',
+  eventProperties: {
+    'country': context.read<AuthCubit>().state.user.country,
+    'type': CollectGroupType.none.name,
+  },
+);

Likely invalid or redundant comment.

lib/shared/bloc/organisation/organisation_bloc.dart (1)

202-206: LGTM! Improved type filtering logic.

The conditional check ensures that organizations are only filtered by type when a specific type is selected, allowing for proper clearing of type filters.

Let's verify the integration with UI components:

✅ Verification successful

Based on the shell script results, I can now generate the final response:

✅ Type filtering implementation is correctly integrated with UI components

The code changes are well integrated across the application:

  • fun_organisation_filter_tile_bar.dart correctly toggles between selected type and CollectGroupType.none.index
  • organization_list_page.dart properly handles all organization types and none state
  • The bloc's filtering logic aligns with UI state management needs
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for UI components dispatching OrganisationTypeChanged events
# and handling CollectGroupType.none.index

# Search for UI components dispatching OrganisationTypeChanged events
rg "OrganisationTypeChanged" -A 3

# Search for usages of CollectGroupType.none
rg "CollectGroupType\.none" -A 3

Length of output: 10650

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (4)
lib/features/family/features/parent_giving_flow/presentation/pages/give_from_list_page.dart (1)

Line range hint 42-54: Add technical logging for error states.

While the error is shown to the user via SnackBar, we should also log it through Logit for debugging purposes, as mentioned in the PR objectives.

        if (state.status == GiveStatus.error) {
+         final error = state.error ?? 'Unknown error';
+         LogitHelper.error(
+           'Error in GiveFromListPage',
+           error: error,
+           properties: {'status': state.status},
+         );
          ScaffoldMessenger.of(context).showSnackBar(
            SnackBar(
              content: Text(locals.somethingWentWrong),
            ),
          );
        }
lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart (3)

22-23: Consider renaming onTapListItem for clarity.

The callback name could be more descriptive to indicate its purpose. Consider renaming it to onOrganisationSelected or onCollectGroupSelected to better reflect its functionality.

-  final void Function(CollectGroup)? onTapListItem;
+  final void Function(CollectGroup)? onOrganisationSelected;

Also applies to: 30-31


95-95: Fix typo in property name.

There's a typo in the property name stratPadding. It should be startPadding.

-  stratPadding: 0,
+  startPadding: 0,

Line range hint 73-82: Enhance error handling in BlocConsumer.

The current error handling only shows a generic error message. Consider:

  1. Adding different error messages based on the error type
  2. Adding a retry action
 if (state.status == OrganisationStatus.error) {
   ScaffoldMessenger.of(context).showSnackBar(
     SnackBar(
-      content: Text(locals.somethingWentWrong),
+      content: Row(
+        children: [
+          Expanded(
+            child: Text(state.error?.message ?? locals.somethingWentWrong),
+          ),
+          TextButton(
+            onPressed: () => getIt<OrganisationBloc>().add(
+              OrganisationFetch(
+                Country.fromCode(
+                  context.read<AuthCubit>().state.user.country,
+                ),
+                type: CollectGroupType.none.index,
+              ),
+            ),
+            child: Text(locals.retry),
+          ),
+        ],
+      ),
     ),
   );
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2eea910 and 543a2ba.

📒 Files selected for processing (4)
  • lib/features/family/features/box_origin/box_origin_selection_page.dart (2 hunks)
  • lib/features/family/features/parent_giving_flow/presentation/pages/give_from_list_page.dart (1 hunks)
  • lib/features/family/features/parent_giving_flow/presentation/pages/organisation_list_family_page.dart (6 hunks)
  • lib/features/family/shared/design/components/content/fun_organisation_filter_tile_bar.dart (2 hunks)
🧰 Additional context used
📓 Learnings (1)
lib/features/family/features/box_origin/box_origin_selection_page.dart (1)
Learnt from: Daniela510
PR: givtnl/givt-app#1234
File: lib/features/family/features/box_origin/box_origin_selection_page.dart:60-98
Timestamp: 2024-11-05T17:30:27.414Z
Learning: In the `BoxOriginSelectionPage` (`lib/features/family/features/box_origin/box_origin_selection_page.dart`), error handling and state management are handled within the cubit's methods, so adding try-catch blocks in the UI layer is unnecessary.
🔇 Additional comments (7)
lib/features/family/shared/design/components/content/fun_organisation_filter_tile_bar.dart (5)

3-3: LGTM: Import statement is correctly placed and necessary.


9-14: LGTM: Constructor is well-structured with proper parameter organization.


17-17: LGTM: Callback property is properly typed and documented.


41-52: LGTM: Filter tile implementation is logically sound.

The type switching logic and state management are implemented correctly.


44-52: Add analytics tracking for filter interactions.

The PR objectives mention implementing behavior tracking using Amplitude, but the filter interactions are not being tracked.

Note: This issue was previously identified in an earlier review. Please refer to the existing comment for the suggested implementation.

lib/features/family/features/box_origin/box_origin_selection_page.dart (1)

51-57: LGTM! Analytics implementation aligns with requirements.

The Amplitude event tracking is well-implemented with appropriate event properties, fulfilling the PR objective of implementing behavior tracking.

lib/features/family/features/parent_giving_flow/presentation/pages/give_from_list_page.dart (1)

Line range hint 74-103: LGTM: Analytics tracking is properly implemented.

The analytics tracking for the parent giving flow is well implemented using Amplitude events, capturing relevant properties such as organization name, amount, and medium ID.

@Daniela510 Daniela510 merged commit cebab2e into develop Nov 7, 2024
1 check passed
@Daniela510 Daniela510 deleted the fix/kids-1569-padding-and-search branch November 7, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants