-
Notifications
You must be signed in to change notification settings - Fork 222
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
Bal 3860 split review completed status into 3 resolution outcomes #3265
Conversation
…-resolution-outcomes
|
WalkthroughThis 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
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
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
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 -B3Length 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()
orcloseDialog()
, keepingdialogState.isOpen
in sync with user actions.
🧹 Nitpick comments (8)
services/workflows-service/CHANGELOG.md (1)
3-11
: Enhance changelog entry with feature detailsThe
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.115apps/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
SinceComponentProps
is only used as a TypeScript type, switch to animport 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 betweenh-16
andw-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 forgetThe 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
⛔ 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 updateThe 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 to0.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 to0.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
Thetext-start
class setstext-align: start
, which is appropriate for logical start alignment and supports RTL languages. If this is intentional, no changes are needed; otherwise, consider usingtext-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 to0.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.
...erchantMonitoring/components/MerchantMonitoringReportStatus/helpers/get-base-note-content.ts
Outdated
Show resolved
Hide resolved
...chantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx
Show resolved
Hide resolved
…-resolution-outcomes
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
apps/backoffice-v2/src/pages/MerchantMonitoring/components/MerchantMonitoringReportStatus/MerchantMonitoringReportStatus.tsx (1)
121-123
:⚠️ Potential issueAbort the flow when monitoring toggle fails
turnOffMonitoringMutation
isawait
-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 removalThe 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
📒 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 stateCombining both loading states into a single memoized value ensures the UI remains consistent during any asynchronous operation.
227-234
: Nice UI improvement for status resolutionShowing the selected status badge in the dialog provides clear visual feedback to users before they confirm their action.
…-resolution-outcomes
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.
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 inputsWhile 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 addingtoStartCase
transformationThe 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
📒 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.
…-resolution-outcomes
cleared
,conditionally-approved
,terminated
.Summary by CodeRabbit
New Features
Improvements
Bug Fixes