Skip to content

Conversation

@glad-adyen
Copy link
Contributor

@glad-adyen glad-adyen commented Nov 6, 2025

Summary

This PR introduces the following changes to the functionality for getting and rendering account balances.

  • Add new useAccountBalances hook to encapsulate the entire logic for fetching account balances.
  • Update the <Balances /> component to use the new useAccountBalances hook.
  • Update mock data to include the reservedValue field indicating the reserved balance amount.

In addition, this PR also reverts the useBalanceAccountSelection hook to its previous state before the addition of analytics tracking. This was done to remove a tracking event that was wrongly being sent from the hook. In the near future, this event will be reintroduced, but in more appropriate location(s).

Fixed issue: IEX-1220: Update mock data for account balances endpoint

@glad-adyen glad-adyen self-assigned this Nov 6, 2025
@glad-adyen glad-adyen requested a review from a team as a code owner November 6, 2025 10:51
@gemini-code-assist
Copy link
Contributor

Summary of Changes

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!

This pull request significantly refactors the handling of account balances by introducing a dedicated useAccountBalances hook. This change centralizes the data fetching and processing logic, making the <Balances /> component cleaner and more maintainable. It also prepares the system for displaying reserved balance amounts by updating mock data and API type definitions, ensuring consistency and future expandability.

Highlights

  • New useAccountBalances Hook: Introduced a new custom hook, useAccountBalances, to centralize and encapsulate all logic related to fetching, processing, and managing account balances, including available and reserved values, and loading states.
  • Refactored <Balances /> Component: The <Balances /> component has been updated to utilize the new useAccountBalances hook, significantly simplifying its internal logic by removing direct data fetching and state management concerns.
  • Mock Data and Type Definition Updates: Mock data for balances (mocks/mock-data/balances.ts) now includes a reservedValue field, and the IBalance interface in src/types/api/resources/BalanceAccountsResource.ts has been extended to support this new property.
  • Simplified useBalanceAccountSelection Hook: The useBalanceAccountSelection hook has been refactored to remove analytics context and related state management, streamlining its functionality.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

Footnotes

  1. 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.

@glad-adyen glad-adyen changed the title Reserved account balances and the useAccountBalances hook Reserved balance and the useAccountBalances hook Nov 6, 2025
@glad-adyen glad-adyen changed the title Reserved balance and the useAccountBalances hook Provision reserved balances and the useAccountBalances hook Nov 6, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new useAccountBalances hook to encapsulate the logic for fetching account balances, which is a great improvement for code organization and reusability. The Balances component is refactored to use this new hook, and mock data is updated to include reserved balances. My review includes a few points to improve the implementation. In Balances.tsx, there's an issue with using non-stable keys for list items, and the reservedValue for balances seems to be dropped, preventing it from being displayed. Additionally, the new useAccountBalances hook is missing unit tests, and some analytics tracking logic has been removed in useBalanceAccountSelection.ts, which might be unintentional. Overall, the changes are positive, and addressing these points will make the PR even better.

@glad-adyen glad-adyen marked this pull request as draft November 6, 2025 12:16
@glad-adyen glad-adyen force-pushed the feature/account-balances branch 8 times, most recently from 4f8f0de to fba493c Compare November 7, 2025 17:08
@glad-adyen glad-adyen marked this pull request as ready for review November 7, 2025 17:09
@glad-adyen glad-adyen force-pushed the feature/account-balances branch from fba493c to d173eff Compare November 7, 2025 23:37
@glad-adyen glad-adyen force-pushed the feature/account-balances branch from 88e992f to 1dfc0b3 Compare November 11, 2025 12:27
@glad-adyen glad-adyen force-pushed the feature/account-balances branch from 1dfc0b3 to ed22549 Compare November 11, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants