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: browser back button functionality in merchant report page (BAL-3296) #2927

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

r4zendev
Copy link
Collaborator

@r4zendev r4zendev commented Jan 1, 2025

Changes

  • Makes use of recently added optional replace property in the useZodSearchParams function to be passed to the corresponding react-router-dom function, which eliminates non-user-friendly history rewrites.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue with the browser back button functionality on the merchant report page
  • Version Update

    • Updated application version to 0.7.90

@r4zendev r4zendev self-assigned this Jan 1, 2025
Copy link

changeset-bot bot commented Jan 1, 2025

⚠️ No Changeset found

Latest commit: bf91fc3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jan 1, 2025

Walkthrough

This pull request introduces version 0.7.90 of the @ballerine/backoffice-v2 application, focusing on resolving an issue with the browser back button functionality on the merchant report page. The change involves updating the useMerchantMonitoringBusinessReportLogic hook to modify how search parameters are handled in the URL, ensuring a smoother navigation experience.

Changes

File Change Summary
apps/backoffice-v2/CHANGELOG.md Added version 0.7.90, noting fix for browser back button on merchant report page
apps/backoffice-v2/package.json Updated version from 0.7.89 to 0.7.90
apps/backoffice-v2/src/pages/MerchantMonitoringBusinessReport/hooks/useMerchantMonitoringBusinessReportLogic/useMerchantMonitoringBusinessReportLogic.tsx Added { replace: true } option to useZodSearchParams to modify URL handling

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant MerchantReportPage
    participant URLHandler

    User->>MerchantReportPage: Navigate to page
    MerchantReportPage->>URLHandler: Update search params
    URLHandler->>Browser: Replace URL state
    Browser-->>User: Smooth back button navigation
Loading

Possibly related PRs

Suggested reviewers

  • Omri-Levy
  • MatanYadaev

Poem

🐰 Hop, hop, through the browser's maze,
Back button now dances with grace,
Search params replaced with care,
No more history's tangled snare,
Merchant reports now smoothly trace! 🌐


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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: 0

🧹 Nitpick comments (2)
apps/backoffice-v2/src/pages/MerchantMonitoringBusinessReport/hooks/useMerchantMonitoringBusinessReportLogic/useMerchantMonitoringBusinessReportLogic.tsx (2)

Line range hint 28-32: Consider removing the @ts-expect-error comment.

You're creating an enum from values derived at runtime (tabs.map(tab => tab.value)), which naturally conflicts with the static nature of z.enum(). While the @ts-expect-error directive suppresses the type error, consider a more type-safe approach to define the valid tabs. For example, you can create a literal type array for tabsValues or handle it more explicitly.


Line range hint 10-16: Optional improvement to avoid fetching on undefined ID.

When businessReportId is undefined, you’re passing an empty string ('') as the fetch ID. Even though the hook gracefully handles the case, consider conditionally skipping the fetch if businessReportId is undefined to avoid unnecessary calls.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9024c and bf91fc3.

📒 Files selected for processing (3)
  • apps/backoffice-v2/CHANGELOG.md (1 hunks)
  • apps/backoffice-v2/package.json (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoringBusinessReport/hooks/useMerchantMonitoringBusinessReportLogic/useMerchantMonitoringBusinessReportLogic.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/backoffice-v2/package.json
🔇 Additional comments (3)
apps/backoffice-v2/CHANGELOG.md (1)

3-8: LGTM! The changelog entry is well-formatted and accurately describes the changes.

The changelog entry:

  • Follows the conventional commit format
  • Correctly categorizes the change as a patch
  • Provides a clear and concise description that matches the PR objectives
apps/backoffice-v2/src/pages/MerchantMonitoringBusinessReport/hooks/useMerchantMonitoringBusinessReportLogic/useMerchantMonitoringBusinessReportLogic.tsx (2)

Line range hint 35-41: Validate the navigation fallback logic.

The onNavigateBack logic navigates to '../' if the session storage doesn't contain a previous-path. This may cause unexpected behavior if your directory structure changes or if the user expects a more context-specific fallback. Consider a more explicit fallback route or a default behavior that's consistent with your overall application routing.


42-42: Great use of replace: true for improved browser back button behavior.

Using { replace: true } ensures the URL search parameters are updated without adding another entry to the browser’s history stack, aligning perfectly with the PR objective to enhance back button functionality. This change looks solid and should help avoid confusing history rewrites.

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