Skip to content

Bal 3860 split review completed status into 3 resolution outcomes #3265

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

Merged

Conversation

chesterkmr
Copy link
Collaborator

@chesterkmr chesterkmr commented Apr 27, 2025

  • Introduced new MERCHANT_REPORT_STATUSES: cleared, conditionally-approved, terminated.
  • Updated status dropdonws in backoffice
  • Updated filters
  • WF Service, Common, Backoffice bump

Summary by CodeRabbit

  • New Features

    • Added support for new merchant report statuses: "Terminated," "Conditionally Approved," and "Cleared" throughout the merchant monitoring interface.
    • Enhanced status badge visuals and descriptions for the new statuses.
    • Introduced a dialog-driven flow for updating certain statuses, including improved form validation and tailored note generation.
    • Added new toast notification for unexpected errors during report status updates.
  • Improvements

    • Updated button styling for better layout and text alignment.
    • Unified and clarified status change notes and monitoring toggle logic for terminated status.
  • Bug Fixes

    • Improved error handling and user feedback during status updates.

Copy link

changeset-bot bot commented Apr 27, 2025

⚠️ No Changeset found

Latest commit: 9b27c94

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 Apr 27, 2025

Walkthrough

This change introduces expanded support for new merchant report statuses—specifically "cleared," "conditionally-approved," and "terminated"—across the backoffice application. It updates constants, schemas, and UI components to recognize and display these statuses. The status update flow is refactored to use a dialog-driven approach for certain statuses, with enhanced form validation and new helper functions for generating status change notes. Additional logic is added to handle toggling monitoring when a report is terminated. Localization strings and visual badge representations are updated accordingly, and new React hooks and utility functions are introduced to support these features.

Changes

File(s) Change Summary
apps/backoffice-v2/CHANGELOG.md Added changelog entry for version 0.7.137 noting dependency bump.
apps/backoffice-v2/public/locales/en/toast.json Added "unexpected_error" message under "business_report_status_update".
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx Refactored status update flow to use dialog state hook; added logic for toggling monitoring on termination; improved form validation; updated UI and loading state handling.
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatusButton.tsx Simplified imports; changed button to full width and updated text alignment.
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringStatusBadge.tsx Expanded badge support for new statuses with unique visuals and text; adjusted styling.
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts Added utility function for generating base status change note HTML.
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts Added utility function for generating status change note when unsubscribing from monitoring.
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/hooks/useMerchantMonitoringStatusDialog/useMerchantMonitoringStatusDialog.ts Introduced new hook for managing dialog open state and selected status.
apps/backoffice-v2/src/pages/MerchantMonitoring/schemas.ts Added new status labels and mappings for "Terminated," "Conditionally Approved," and "Cleared".
packages/common/src/consts/index.ts Extended merchant report statuses and updateable statuses to include new options; updated type accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StatusDropdown
    participant StatusDialog
    participant Form
    participant ToggleMonitoringMutation
    participant UpdateStatusMutation
    participant Toast

    User->>StatusDropdown: Selects new status (e.g., "terminated")
    StatusDropdown->>StatusDialog: Opens dialog with selected status
    StatusDialog->>Form: User fills additional details and submits
    Form->>Form: Validate required fields
    alt Status is "terminated"
        Form->>ToggleMonitoringMutation: Turn off monitoring
        ToggleMonitoringMutation-->>Form: Success/Error
        Form->>UpdateStatusMutation: Update report status
    else Other statuses
        Form->>UpdateStatusMutation: Update report status
    end
    UpdateStatusMutation-->>Toast: Show success/error notification
    UpdateStatusMutation-->>StatusDialog: Close dialog and reset form
Loading

Suggested reviewers

  • jonathan-shemer

Poem

In the fields of code, new statuses bloom,
"Cleared," "Terminated," and more dispel the gloom.
Dialogs now guide with a gentle hop,
Notes and badges—oh, how they pop!
Monitoring toggles with a single click,
The merchant's journey, now smooth and slick.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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 comments (1)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (1)

154-159: 💡 Verification agent

🧩 Analysis chain

onOpenChange toggles blindly – can desynchronise dialog state

<Dialog open={dialogState.isOpen} onOpenChange={() => toggleDialogOpenState()}>

onOpenChange receives the desired state (boolean). Ignoring it and just toggling means:

  • opening the dialog from code that already set isOpen to true flips it back to false
  • ESC or outside-click triggers a double-toggle producing flicker

Forward the value instead:

-<Dialog open={dialogState.isOpen} onOpenChange={() => toggleDialogOpenState()}>
+<Dialog open={dialogState.isOpen} onOpenChange={open => (open ? toggleDialogOpenState() : closeDialog())}>

(or expose a dedicated setter inside useMerchantMonitoringStatusDialog).


🏁 Script executed:

#!/bin/bash
# Locate the hook definition to inspect how toggleDialogOpenState and closeDialog are implemented
rg "function useMerchantMonitoringStatusDialog" -n -A5 -B5

# Find where toggleDialogOpenState is defined
rg "toggleDialogOpenState" -n -A3 -B3

# Check if a closeDialog or similar setter exists within the hook
rg "closeDialog" -n -A3 -B3

Length of output: 12608


Synchronize Dialog’s open state with onOpenChange

The onOpenChange handler receives the desired boolean but you’re currently calling the toggle blindly, which can lead to flicker or desync (e.g. Escape/outside click and programmatic opens). Instead, use the hook’s explicit setters:

• In
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx
around line 154, change:

- <Dialog open={dialogState.isOpen} onOpenChange={() => toggleDialogOpenState()}>
+ <Dialog
+   open={dialogState.isOpen}
+   onOpenChange={open => (open ? openDialog() : closeDialog())}
+ >

This forwards the incoming boolean to openDialog() or closeDialog(), keeping dialogState.isOpen in sync with user actions.

🧹 Nitpick comments (8)
services/workflows-service/CHANGELOG.md (1)

3-11: Enhance changelog entry with feature details

The 0.7.122 entry currently only lists dependency bumps. Please include a concise summary of the new merchant report statuses (cleared, conditionally-approved, terminated) and related UI/filter updates to clarify the purpose of this release.

Proposed diff:

### Patch Changes
+- Add new merchant report statuses: `cleared`, `conditionally-approved`, `terminated`
+- Update backoffice status dropdowns and filters to support new statuses
  - Bump
  - Updated dependencies
    - @ballerine/common@0.9.92
    - @ballerine/workflow-core@0.6.115
    - @ballerine/workflow-node-sdk@0.6.115
apps/backoffice-v2/public/locales/en/toast.json (1)

110-110: Consistency in localization terminology
The new "unexpected_error" key uses “report” while the surrounding messages refer to “merchant check”. To maintain consistent terminology across the UI, consider updating it to:

- "unexpected_error": "Something went wrong while updating the status of the report.",
+ "unexpected_error": "Something went wrong while updating the status of the merchant check.",
apps/kyb-app/package.json (1)

20-21: Standardize dependency version specifiers
Here, @ballerine/common uses a caret range (^0.9.92) while @ballerine/workflow-browser-sdk is pinned exactly (0.6.115). For consistency across packages, consider using the same specifier style (e.g., caret) for both:

- "@ballerine/workflow-browser-sdk": "0.6.115",
+ "@ballerine/workflow-browser-sdk": "^0.6.115",
services/workflows-service/package.json (1)

53-55: Align dependency version specifiers with monorepo standards
The dependencies for @ballerine/common, @ballerine/workflow-core, and @ballerine/workflow-node-sdk are pinned without a caret. Verify that this matches your intended semver strategy across packages to avoid unexpected updates:

- "@ballerine/common": "0.9.92",
- "@ballerine/workflow-core": "0.6.115",
- "@ballerine/workflow-node-sdk": "0.6.115",
+ "@ballerine/common": "^0.9.92",
+ "@ballerine/workflow-core": "^0.6.115",
+ "@ballerine/workflow-node-sdk": "^0.6.115",
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatusButton.tsx (2)

2-2: Use type-only import for React types
Since ComponentProps is only used as a TypeScript type, switch to an import type to avoid emitting unnecessary imports at runtime:

- import { ComponentProps } from 'react';
+ import type { ComponentProps } from 'react';

27-27: Remove extra whitespace in Tailwind classes
There are double spaces between h-16 and w-full, which can be cleaned up for readability:

- className={ctw(`flex h-16  w-full flex-col items-start justify-center space-y-1 px-4 py-2`, {
+ className={ctw(`flex h-16 w-full flex-col items-start justify-center space-y-1 px-4 py-2`, {
apps/backoffice-v2/package.json (1)

56-60: Consistent dependency pinning
The dependencies for @ballerine/common, @ballerine/workflow-browser-sdk, and @ballerine/workflow-node-sdk are pinned exactly (without carets). Cross-reference your versioning policy to confirm whether these should be caret ranges (^) to receive patch updates:

- "@ballerine/common": "0.9.92",
- "@ballerine/workflow-browser-sdk": "0.6.115",
- "@ballerine/workflow-node-sdk": "0.6.115",
+ "@ballerine/common": "^0.9.92",
+ "@ballerine/workflow-browser-sdk": "^0.6.115",
+ "@ballerine/workflow-node-sdk": "^0.6.115",
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (1)

135-147: Hard-coded list of “non-editable” statuses is easy to forget

The disabled check repeats every status literal:

[
  MERCHANT_REPORT_STATUSES_MAP['in-progress'],
  // ...
  MERCHANT_REPORT_STATUSES_MAP['terminated'],
].includes(status)

Consider keeping the source of truth in a constant, e.g.:

const NON_EDITABLE_STATUSES = new Set([
  'in-progress',
  'quality-control',
  'completed',
  'cleared',
  'conditionally-approved',
  'terminated',
].map(s => MERCHANT_REPORT_STATUSES_MAP[s]));

Then:

disabled = isUpdatingReport || NON_EDITABLE_STATUSES.has(status)

This removes duplication and guarantees future status additions are handled in one place only.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 01acf94 and 560e6fb.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • apps/backoffice-v2/CHANGELOG.md (1 hunks)
  • apps/backoffice-v2/package.json (2 hunks)
  • apps/backoffice-v2/public/locales/en/toast.json (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (8 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatusButton.tsx (2 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringStatusBadge.tsx (2 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/hooks/useMerchantMonitoringStatusDialog/useMerchantMonitoringStatusDialog.ts (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/schemas.ts (1 hunks)
  • apps/kyb-app/CHANGELOG.md (1 hunks)
  • apps/kyb-app/package.json (2 hunks)
  • examples/headless-example/CHANGELOG.md (1 hunks)
  • examples/headless-example/package.json (2 hunks)
  • packages/common/CHANGELOG.md (1 hunks)
  • packages/common/package.json (1 hunks)
  • packages/common/src/consts/index.ts (2 hunks)
  • packages/workflow-core/CHANGELOG.md (1 hunks)
  • packages/workflow-core/package.json (2 hunks)
  • sdks/web-ui-sdk/CHANGELOG.md (1 hunks)
  • sdks/web-ui-sdk/package.json (2 hunks)
  • sdks/workflow-browser-sdk/CHANGELOG.md (1 hunks)
  • sdks/workflow-browser-sdk/package.json (2 hunks)
  • sdks/workflow-node-sdk/CHANGELOG.md (1 hunks)
  • sdks/workflow-node-sdk/package.json (2 hunks)
  • services/workflows-service/CHANGELOG.md (1 hunks)
  • services/workflows-service/package.json (2 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • websites/docs/package.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatusButton.tsx (1)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringStatusBadge.tsx (1)
  • MerchantMonitoringStatusBadge (44-94)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/hooks/useMerchantMonitoringStatusDialog/useMerchantMonitoringStatusDialog.ts (1)
packages/common/src/consts/index.ts (1)
  • UpdateableReportStatus (195-201)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringStatusBadge.tsx (1)
packages/common/src/consts/index.ts (1)
  • MERCHANT_REPORT_STATUSES_MAP (191-193)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_linux
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: lint
🔇 Additional comments (36)
services/workflows-service/prisma/data-migrations (1)

1-1: Approve submodule commit update

The subproject commit pointer has been correctly updated to 00be20b44f5ba630ca96d523b8841f687b43340f, aligning with the overall version bumps in the monorepo. No functional changes within this submodule require further review.

examples/headless-example/CHANGELOG.md (1)

3-9: Changelog entry for v0.3.114 looks good. The new header and patch changes correctly document the bumps for @ballerine/common@0.9.92 and @ballerine/workflow-browser-sdk@0.6.115, which aligns with the coordinated version updates across other packages.

apps/kyb-app/CHANGELOG.md (1)

3-9: Changelog entry for 0.3.167 is formatted correctly
The new version header, “Patch Changes” section, and the list of updated dependencies align with the style of prior entries.

packages/common/CHANGELOG.md (1)

3-7: Changelog entry is properly documented.

The addition of version 0.9.92 with the "Bump" patch change is consistent with previous entries and adequately documents the version increment.

packages/common/src/consts/index.ts (3)

183-186: New merchant report statuses added successfully.

The addition of three new statuses ('cleared', 'conditionally-approved', 'terminated') successfully implements the PR objective of splitting the review completed status into three distinct resolution outcomes.


196-198: UpdateableReportStatus type properly updated.

The type definition has been correctly extended to include the newly added statuses, maintaining type safety throughout the application.


207-209: UPDATEABLE_REPORT_STATUSES array expanded appropriately.

The constant array has been updated to include the new statuses, ensuring they can be selected as valid report status options.

packages/common/package.json (1)

5-5: Version bump aligns with changelog.

The package version has been correctly incremented to 0.9.92, matching the newly added changelog entry.

websites/docs/package.json (1)

20-20: Dependency updated to the latest version.

The dependency on @ballerine/common has been properly updated to reflect the version bump, maintaining consistency across the project.

packages/workflow-core/package.json (2)

4-4: Version bump to 0.6.115
The package version is updated consistently with the coordinated release across related packages.


34-34: Dependency bump @ballerine/common to 0.9.92
This aligns with the monorepo-wide update and matches the version specified in other packages.

sdks/web-ui-sdk/CHANGELOG.md (1)

3-9: Changelog entry for v1.5.93
The new patch version is correctly documented with the updated @ballerine/common@0.9.92 dependency. Matches coordinated monorepo bumps.

packages/workflow-core/CHANGELOG.md (1)

3-9: Changelog entry for v0.6.115
The patch version is documented with the @ballerine/common@0.9.92 dependency bump, reflecting consistent updates.

sdks/workflow-node-sdk/CHANGELOG.md (1)

3-8: Changelog entry for v0.6.115
The patch update correctly reflects the bump to @ballerine/workflow-core@0.6.115, aligning with other SDKs.

apps/backoffice-v2/CHANGELOG.md (1)

3-12: Changelog entry for v0.7.137
The patch version is documented and dependencies are updated to @ballerine/common@0.9.92, @ballerine/workflow-browser-sdk@0.6.115, and @ballerine/workflow-node-sdk@0.6.115. Matches coordinated updates.

sdks/web-ui-sdk/package.json (2)

24-24: Version bump to 1.5.93 is consistent.
This aligns with coordinated versioning across the monorepo for the web UI SDK.


99-99: Dependency bump of @ballerine/common to 0.9.92 looks good.
Ensures compatibility with the updated common package version across SDKs.

sdks/workflow-browser-sdk/package.json (2)

4-4: Version bump to 0.6.115 approved.
Matches the new patch release for the browser SDK.


36-37: Dependencies updated to 0.9.92 (@ballerine/common) and 0.6.115 (@ballerine/workflow-core).
These changes are consistent with the coordinated ecosystem version bumps.

sdks/workflow-node-sdk/package.json (2)

4-4: Version bump to 0.6.115 approved.
Reflects the new patch release for the node SDK.


31-31: Dependency bump of @ballerine/workflow-core to 0.6.115 approved.
Keeps the node SDK in sync with the core package update.

sdks/workflow-browser-sdk/CHANGELOG.md (1)

3-9: Changelog entry for 0.6.115 looks correct.

  • New version header added.
  • Patch section accurately reflects updated dependencies (@ballerine/common@0.9.92, @ballerine/workflow-core@0.6.115).
examples/headless-example/package.json (2)

4-4: Version bump to 0.3.114 approved.
Aligns the example project with the latest SDK versions.


37-38: Dependencies updated to @ballerine/common@0.9.92 and @ballerine/workflow-browser-sdk@0.6.115.
Consistent with the rest of the monorepo’s version synchronization.

apps/kyb-app/package.json (1)

4-4: Verify version bump and changelog updates
The package version was bumped to 0.3.167. Ensure this aligns with your release process and that corresponding changelog entries or release notes are updated to reflect the new merchant monitoring statuses and dependency upgrades.

services/workflows-service/package.json (1)

4-4: Ensure version bump consistency
The package version was updated to 0.7.122. Confirm that any necessary service changelogs or deployment scripts are updated to handle the new version and associated dependency changes.

apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatusButton.tsx (1)

32-32: Confirm text alignment behavior
The text-start class sets text-align: start, which is appropriate for logical start alignment and supports RTL languages. If this is intentional, no changes are needed; otherwise, consider using text-left for explicit left alignment in LTR-only contexts.

apps/backoffice-v2/package.json (1)

3-3: Validate version bump and change propagation
You've bumped the package version to 0.7.137. Ensure that release workflows, CI pipelines, and changelogs are updated to reflect this new version across the monorepo.

apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts (1)

1-11: Well-implemented helper function for consistent note formatting.

This helper function creates standardized HTML content for merchant monitoring status changes that involve unsubscription. The implementation:

  • Properly uses toStartCase for consistent status formatting
  • Handles conditional rendering based on whether additional details are provided
  • Maintains consistent styling with other note content in the system
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/hooks/useMerchantMonitoringStatusDialog/useMerchantMonitoringStatusDialog.ts (1)

1-40: Clean React hook implementation for dialog state management.

This hook follows React best practices:

  • Uses proper state management with useState
  • Implements memoized callbacks with useCallback to prevent unnecessary re-renders
  • Maintains type safety with the UpdateableReportStatus type
  • Provides a clear, intuitive API with specific functions for different dialog operations
apps/backoffice-v2/src/pages/MerchantMonitoring/schemas.ts (2)

60-62: New status labels added correctly.

The new report status labels "Terminated", "Conditionally Approved", and "Cleared" are properly added to the REPORT_STATUS_LABELS constant array, maintaining the established pattern.


70-73: Status value mappings implemented consistently.

The new status labels are correctly mapped to their kebab-case values, following the established pattern in the codebase and maintaining consistency with the type system.

apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringStatusBadge.tsx (4)

27-41: Well-defined status data mappings with appropriate variants.

The new status mappings are implemented with:

  • Appropriate semantic variants (warning, success, destructive)
  • Clear, descriptive titles
  • Helpful explanatory text that communicates the meaning of each status

71-75: Consistent styling for new status badges.

The CSS class conditionals for the new statuses follow the established pattern and use appropriate colors that align with the semantic meaning of each status (green for cleared, yellow/orange for conditionally approved, red for terminated).


82-85: Consistent styling for status indicator dots.

The status indicator dots are styled with colors that match their corresponding badge backgrounds, maintaining visual consistency throughout the UI.


89-89: Improved text container width.

Increasing the width from 90% to 100% for the status title span gives more space for the text to display, reducing the chance of unnecessary text truncation.

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

♻️ Duplicate comments (1)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (1)

121-123: ⚠️ Potential issue

Abort the flow when monitoring toggle fails

turnOffMonitoringMutation is await-ed, but even when it rejects the code still proceeds to update the report status and create the note, leaving the UI in an inconsistent state where the report looks terminated while monitoring is still on.

Apply this diff to preserve atomicity between operations:

-    if (isShouldUnsubscribe) {
-      await turnOffMonitoringMutation(businessId ?? '');
-    }
+    if (isShouldUnsubscribe) {
+      try {
+        await turnOffMonitoringMutation(businessId ?? '');
+      } catch {
+        // Toast is already shown by onError; bail-out to avoid inconsistent state
+        return;
+      }
+    }
🧹 Nitpick comments (1)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (1)

47-50: Track TODO for future removal

The TODO comment indicates this filtering is temporary until the 'completed' status is fully removed. Consider creating a ticket to track this for future cleanup.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d4c730 and 848719c.

📒 Files selected for processing (3)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (8 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_linux
  • GitHub Check: spell_check
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: format
  • GitHub Check: lint
🔇 Additional comments (2)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (2)

87-90: Good implementation of combined loading state

Combining both loading states into a single memoized value ensures the UI remains consistent during any asynchronous operation.


227-234: Nice UI improvement for status resolution

Showing the selected status badge in the dialog provides clear visual feedback to users before they confirm their action.

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/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts (2)

3-6: Consider adding fallback handling for undefined inputs

While the current implementation works well, it would be more robust to add fallback handling for cases where inputs might be undefined or null.

-export const getBaseNoteContent = (status: string, text: string) => {
-  const sanitizedStatus = DOMPurify.sanitize(status);
-  const sanitizedText = DOMPurify.sanitize(text);
+export const getBaseNoteContent = (status: string, text?: string) => {
+  const sanitizedStatus = DOMPurify.sanitize(status || '');
+  const sanitizedText = text ? DOMPurify.sanitize(text) : '';

4-5: Consider adding toStartCase transformation

The previous implementation used toStartCase on the status value to format it properly. This formatting appears to be missing in the current implementation.

import DOMPurify from 'dompurify';
+import { toStartCase } from '@/common/utils/to-start-case/to-start-case';

export const getBaseNoteContent = (status: string, text: string) => {
-  const sanitizedStatus = DOMPurify.sanitize(status);
+  const sanitizedStatus = DOMPurify.sanitize(toStartCase(status));
  const sanitizedText = DOMPurify.sanitize(text);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 682b30c and 47c4a82.

📒 Files selected for processing (2)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts (1 hunks)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-note-content-for-unsubscribe.ts
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: test_linux
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: lint
  • GitHub Check: format
  • GitHub Check: spell_check
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts (1)

1-17: Security improvement implemented correctly!

The implementation properly addresses XSS concerns by using DOMPurify to sanitize both status and text inputs before inserting them into HTML. This is a robust approach that provides better protection than simple HTML entity escaping.

@chesterkmr chesterkmr merged commit 8109c6c into dev Apr 29, 2025
17 checks passed
@chesterkmr chesterkmr deleted the bal-3860-split-review-completed-status-into-3-resolution-outcomes branch April 29, 2025 10:32
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