-
Notifications
You must be signed in to change notification settings - Fork 1
Enable users to select all balance accounts #670
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @glad-adyen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Hello team, gemini-code-assist here with a summary of this pull request. This PR addresses issue CXP-3646
by introducing an "All accounts" option to the balance account selector within the DisputesOverview
component. Previously, users could only filter disputes by individual balance accounts. With this change, users can now view disputes across all their associated balance accounts by selecting this new option.
Highlights
- Feature Implementation: Adds an "All accounts" option to the balance account selection dropdown in the Disputes Overview component.
- Hook Logic Update: Modifies the
useBalanceAccountSelection
hook to optionally include the "All accounts" item in the list of selectable options and handle its selection. - API Call Filtering: Updates the logic in
DisputesOverview
to omit thebalanceAccountId
query parameter when the "All accounts" option is selected, allowing the backend to return results for all accounts. - UI Adjustment: Adjusts the
BalanceAccountSelector
component to not display the unique ID for the "All accounts" option in the dropdown list. - Mock Server Update: Updates the mock server to correctly filter disputes when the "All accounts" ID (or
null
) is provided as the balance account filter. - Localization: Adds necessary translation keys and values for the new "All accounts" label.
Changelog
Click here to see the changelog
- mocks/mock-server/disputes.ts
- Updated the mock dispute filtering logic to include the new 'All accounts' selection ID (or null) when determining which disputes to return.
- src/components/external/DisputesOverview/components/DisputesOverview/DisputesOverview.tsx
- Imported the
ALL_BALANCE_ACCOUNTS_SELECTION_ID
constant. - Enabled the 'All accounts' option by passing
true
as the second argument touseBalanceAccountSelection
. - Modified the
getDisputesCall
query parameters to conditionally includebalanceAccountId
only when the selected account is not the 'All accounts' ID.
- Imported the
- src/components/internal/FormFields/Select/BalanceAccountSelector/BalanceAccountSelector.tsx
- Imported the
ALL_BALANCE_ACCOUNTS_SELECTION_ID
constant. - Updated the rendering logic for select items to hide the balance account ID span when the item's ID matches
ALL_BALANCE_ACCOUNTS_SELECTION_ID
.
- Imported the
- src/hooks/useBalanceAccountSelection.ts
- Defined
ALL_BALANCE_ACCOUNTS_SELECTION_ID
usinguniqueId()
. - Added an optional
allowAllSelection
parameter to the hook. - Modified the
allBalanceAccounts
memoized value to include the 'All accounts' item conditionally based onallowAllSelection
. - Updated the
balanceAccountSelectionOptions
memoized value to map the 'All accounts' item to the correct translated label. - Adjusted the
onBalanceAccountSelection
callback to find the index within the potentially largerallBalanceAccounts
list.
- Defined
- src/translations/en-US.instructions.json
- Added a new translation key
balanceAccounts.all
with an instruction describing its usage.
- Added a new translation key
- src/translations/en-US.json
- Added a new translation key
balanceAccounts.all
with the value "All accounts".
- Added a new translation key
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A dropdown list appears,
Accounts shown, calming fears.
Now 'All' is an option,
For wider adoption,
Filtering disputes, it clears.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR effectively introduces the "All accounts" option to the balance account selector, enhancing the filtering capabilities of the DisputesOverview
component. The use of ALL_BALANCE_ACCOUNTS_SELECTION_ID
and the conditional logic to omit the balanceAccountId
parameter for the API call are well-implemented. The changes to useBalanceAccountSelection
are central to this feature and largely look good, including the cleanup of the resetBalanceAccountSelection
hook's dependencies.
I have a couple of medium-severity points for discussion, primarily concerning the mock server's alignment with the new "all accounts" API behavior and the precise conditions under which the "All accounts" option appears in the dropdown. Addressing these will ensure the feature is robust and the mocking is accurate.
Summary of Findings
- Mock Server Logic for 'All Accounts': The mock server's condition for fetching all disputes (
[MAIN_BALANCE_ACCOUNT.id, null].includes(balanceAccount)
) might not accurately reflect the frontend's behavior of omitting thebalanceAccountId
parameter. It should ideally check for the absence of the parameter. (Severity: medium) - Dropdown Options Generation Logic: In
useBalanceAccountSelection.ts
, thebalanceAccountSelectionOptions
are generated based onbalanceAccounts.length > 1
. This might prevent the "All accounts" option from appearing if there's only one or zero actual accounts, even ifallowAllSelection
is true. The condition might need to be based onallBalanceAccounts.length > 1
. (Severity: medium) - Clarity in 'All Accounts' Object Creation: In
useBalanceAccountSelection.ts
, the 'All accounts' object is created by spreadingbalanceAccounts[0] ?? {}
. While functional, explicitly defining the object could be slightly clearer. (Severity: low, not commented due to review settings)
Merge Readiness
I recommend addressing the medium-severity comments before merging. Specifically, clarifying the mock server behavior to align with the frontend's parameter omission and refining the UX logic for when the 'All accounts' option is displayed in the selector would be beneficial. Once these points are discussed and potentially adjusted, the PR should be in good shape. As an AI, I am not authorized to approve pull requests; please ensure further review and approval by team members.
Size Change: +311 B (+0.07%) Total Size: 427 kB
ℹ️ View Unchanged
|
Summary
This PR introduces "All accounts" option to the balance account selector of the
DisputesOverview
component, to allow users filter by all balance accounts.Fixed issue: CXP-3646: Enable users to select all balance accounts