Skip to content

Conversation

@jonathan-shemer
Copy link
Contributor

@jonathan-shemer jonathan-shemer commented Jun 24, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a warning banner on the KYB and Ownership Assessment page to display warning flags with visual severity indicators.
    • Added structured warning flags for assessment errors and high-risk jurisdictions.
  • Improvements

    • Enhanced the assessment schema to include additional fields for error reporting and jurisdiction risk.
    • Updated assessment checks to use dynamic risk levels and streamlined error detection.
    • Improved page layout for better visibility of key assessment information and warnings.
  • Bug Fixes

    • Adjusted API endpoints for assessments to improve consistency and reliability.

@changeset-bot
Copy link

changeset-bot bot commented Jun 24, 2025

⚠️ No Changeset found

Latest commit: 872088b

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

This update expands the KYB and Ownership assessment schema to include new error and risk fields, refactors frontend type usage to infer from the schema, introduces a warning flag system with a new WarningBanner UI component, and updates API client endpoints to use query parameters and payload fields instead of path parameters for assessment type.

Changes

File(s) Change Summary
apps/backoffice-v2/src/domains/assessments/fetchers.ts Expanded KybAndOwnershipAssessmentSchema with optional errors and new companyJurisdictionRisk fields.
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/KybAndOwnershipAssessmentPage.tsx Added WarningBanner component; integrated warning flags display; updated layout and imports.
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useAssessmentChecks.tsx Refactored assessment checks; introduced warning flag system and related hooks/types.
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useKybAndOwnershipAssessmentPageLogic.tsx Hook now provides warningFlags from new warning flag system.
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/types.ts Replaced manual Assessment interface with schema-inferred type alias.
services/workflows-service/src/common/utils/unified-api-client/unified-api-client.ts Modified assessment API endpoints to use query parameters/payload fields for assessment type instead of path parameters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant KybAndOwnershipAssessmentPage
    participant useKybAndOwnershipAssessmentPageLogic
    participant useAssessmentWarningFlags
    participant WarningBanner

    User->>KybAndOwnershipAssessmentPage: Visit assessment page
    KybAndOwnershipAssessmentPage->>useKybAndOwnershipAssessmentPageLogic: Invoke logic hook
    useKybAndOwnershipAssessmentPageLogic->>useAssessmentWarningFlags: Generate warning flags from assessment
    useAssessmentWarningFlags-->>useKybAndOwnershipAssessmentPageLogic: Return warningFlags
    useKybAndOwnershipAssessmentPageLogic-->>KybAndOwnershipAssessmentPage: Return warningFlags and other data
    KybAndOwnershipAssessmentPage->>WarningBanner: Render if warningFlags present
Loading

Possibly related PRs

  • ballerine-io/ballerine#3302: Adds backend assessments module, which the current PR builds upon by expanding the schema and frontend logic for assessments.

Suggested reviewers

  • Omri-Levy

Poem

🐇
In the warren, warnings glow,
New banners wave and errors show.
Schemas grow with nested care,
Types inferred from what we share.
Endpoints shift, the queries sing—
Assessments now do everything!
Hopping forward, code in spring.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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

🧹 Nitpick comments (1)
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useAssessmentChecks.tsx (1)

133-187: Well-implemented warning flag system with minor improvement opportunities.

The warning flag implementation is solid with proper TypeScript types and React patterns. However, consider these refinements:

  1. Potential string fragility: The severity mapping logic uses hardcoded string checks that could break if error message formats change.
  2. Code duplication: Similar error checking pattern is repeated for registry and structure.

Consider extracting the error checking logic into a reusable function:

+const createWarningFlag = (
+  status: string | undefined,
+  error: string | undefined,
+  defaultTitle: string,
+  errorSeverityMap: Record<string, 'info' | 'warning' | 'error'> = {}
+): WarningFlag | null => {
+  if (status === 'failed' || error) {
+    const severity = error 
+      ? Object.entries(errorSeverityMap).find(([key]) => 
+          error.toLowerCase().includes(key)
+        )?.[1] || 'info'
+      : 'info';
+      
+    return {
+      title: error ?? defaultTitle,
+      severity,
+    };
+  }
+  return null;
+};

export const getWarningFlags = (assessment: Assessment | undefined): WarningFlag[] => {
  if (!assessment) {
    return [];
  }

  const flags: WarningFlag[] = [];

+  const registryFlag = createWarningFlag(
+    assessment.companyRegistryInformation?.status,
+    assessment.companyRegistryInformation?.errors,
+    'Registry Information Not Available At The Moment',
+    { 'not supported': 'error', 'does not exist': 'error' }
+  );
+  if (registryFlag) flags.push(registryFlag);

+  const structureFlag = createWarningFlag(
+    assessment.companyStructure?.status,
+    assessment.companyStructure?.errors,
+    'Ownership Information Not Available At The Moment',
+    { 'not supported': 'error' }
+  );
+  if (structureFlag) flags.push(structureFlag);

  const isHighRiskJurisdiction = assessment.companyJurisdictionRisk?.output?.level === 'HIGH';

  if (isHighRiskJurisdiction) {
    flags.push({
      title: 'High Risk Company Jurisdiction',
      severity: 'error',
    });
  }

  return flags;
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b8d1a2 and 872088b.

📒 Files selected for processing (6)
  • apps/backoffice-v2/src/domains/assessments/fetchers.ts (1 hunks)
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/KybAndOwnershipAssessmentPage.tsx (5 hunks)
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useAssessmentChecks.tsx (2 hunks)
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useKybAndOwnershipAssessmentPageLogic.tsx (3 hunks)
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/types.ts (1 hunks)
  • services/workflows-service/src/common/utils/unified-api-client/unified-api-client.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`apps/backoffice-v2/**/*.{ts,tsx}`: Use functional components with TypeScript. Implement smart/dumb component pattern. Place components in feature-based directories. Use compound c...

apps/backoffice-v2/**/*.{ts,tsx}: Use functional components with TypeScript.
Implement smart/dumb component pattern.
Place components in feature-based directories.
Use compound components for complex UIs.
Follow atomic design principles.
Use React Query for server state and API calls.
Use Context for shared state.
Implement state machines for complex flows.
Use local state for UI-only state.
Follow unidirectional data flow.
Use strict TypeScript configuration.
Define interfaces for all props.
Use discriminated unions for state.
Leverage type inference.
Use Radix UI for accessible components.
Implement proper ARIA attributes.
Follow consistent styling patterns.
Use composition over inheritance.
Keep components small and focused.
Use React Hook Form for forms.
Implement Zod for validation.
Handle form submission states.
Show validation feedback.
Use controlled inputs when needed.
Implement proper loading states for data fetching.
Handle error states gracefully.
Cache responses appropriately.
Type API responses.
Use error boundaries.
Implement fallback UI.
Handle async errors.
Show user-friendly error messages.
Log errors appropriately.
Use React.memo wisely.
Implement proper code splitting.
Use lazy loading for routes.
Optimize re-renders.
Profile performance regularly.
Write unit tests for components.
Use React Testing Library.
Mock external dependencies in tests.
Maintain good test coverage.
Follow feature-based organization.
Use index files for exports.
Keep related files together.
Use consistent naming.
Implement barrel exports.
Use Tailwind CSS for styling.
Follow utility-first approach for styling.
Use CSS variables for theming.
Keep styles maintainable.
Use CSS modules when needed.
Document complex logic.
Write clear component documentation.
Keep documentation up to date.
Use JSDoc when helpful.
Follow ESLint rules.
Use consistent formatting.
Write clear variable names.
Keep functions pure.
Use meaningful types.
Validate user input.
Implement proper authentication.
Handle sensitive data carefully.
Follow security best practices.
Use HTTPS for API calls.
Follow WCAG guidelines for accessibility.
Use semantic HTML.
Test with screen readers.
Ensure keyboard navigation.
Provide proper focus management.

  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/types.ts
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useKybAndOwnershipAssessmentPageLogic.tsx
  • apps/backoffice-v2/src/domains/assessments/fetchers.ts
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/KybAndOwnershipAssessmentPage.tsx
  • apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useAssessmentChecks.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test_linux
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: lint
  • GitHub Check: format
🔇 Additional comments (18)
services/workflows-service/src/common/utils/unified-api-client/unified-api-client.ts (3)

215-215: LGTM! API endpoint refactoring looks correct.

The change from path parameter to query parameter for assessment type is consistent with REST API best practices for filtering resources.


224-224: LGTM! Simplified endpoint structure.

Removing the /by-id segment simplifies the endpoint structure while maintaining the same functionality through query parameters.


237-237: LGTM! Consistent payload-based approach.

Moving the assessment type to the payload instead of the URL path is consistent with the other endpoint changes and follows REST conventions.

apps/backoffice-v2/src/domains/assessments/fetchers.ts (3)

47-47: LGTM! Error field addition follows consistent pattern.

The errors field as nullable string is appropriately typed for optional error information in the registry data.


57-57: LGTM! Consistent error field pattern.

The errors field in companyStructure maintains consistency with the pattern established in companyRegistryInformation.


62-77: LGTM! Well-structured jurisdiction risk schema.

The companyJurisdictionRisk object follows the established pattern with:

  • Optional timestamps (createdAt, updatedAt)
  • Nested output object with appropriate risk level enum
  • Proper use of .passthrough() and .nullable().optional()
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useKybAndOwnershipAssessmentPageLogic.tsx (3)

12-12: LGTM! Clean import addition.

The import correctly adds the new useAssessmentWarningFlags hook alongside the existing useAssessmentChecks.


70-70: LGTM! Proper hook usage.

The useAssessmentWarningFlags hook is correctly invoked with the assessment parameter, following React hooks best practices.


90-90: LGTM! Backward-compatible extension.

Adding warningFlags to the return object extends functionality without breaking existing consumers of this hook.

apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/types.ts (1)

2-5: LGTM! Excellent refactoring to schema-driven types.

This change eliminates type duplication by inferring the Assessment type directly from the Zod schema, ensuring consistency between validation and TypeScript types. This follows best practices for maintaining a single source of truth.

apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/KybAndOwnershipAssessmentPage.tsx (5)

3-3: LGTM! Appropriate icon imports.

The new icon imports (X, AlertTriangle, Info) align with the warning severity indicators used in the WarningBanner component.


12-13: LGTM! Clean imports for new functionality.

The imports for WarningFlag type and ctw utility are properly added to support the new warning banner functionality.


62-62: LGTM! Proper destructuring of warning flags.

The warningFlags is correctly extracted from the page logic hook and will be passed to the WarningBanner component.


96-169: LGTM! Well-structured layout improvements.

The layout restructuring with flex containers and overflow handling provides a clean foundation for the new warning banner while maintaining the existing functionality.


135-137: LGTM! Proper conditional rendering.

The conditional rendering of the WarningBanner correctly checks for both the existence and length of warning flags before displaying.

apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useAssessmentChecks.tsx (3)

39-39: LGTM: Clean data extraction.

Good practice extracting the jurisdiction risk data upfront for better readability and consistent access pattern.


117-125: Excellent improvement: Dynamic risk assessment.

Great refactor replacing hardcoded high-risk jurisdictions with dynamic risk level assessment. This makes the system more flexible and data-driven.


47-47: ```shell
#!/bin/bash

Display the beginning of useAssessmentChecks.tsx to locate createCheck definition/import

sed -n '1,200p' apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/hooks/useAssessmentChecks.tsx


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +15 to +50
type WarningBannerProps = {
warningFlags: WarningFlag[];
};

const WarningBanner = ({ warningFlags }: WarningBannerProps) => {
if (!warningFlags.length) return null;

return (
<div className="mb-6 space-y-2">
{warningFlags.map(flag => (
<div
key={flag.title}
className={ctw('flex items-center gap-3 rounded-md border p-2.5', {
'border-red-200 bg-red-100': flag.severity === 'error',
'border-warning bg-warning': flag.severity === 'warning',
'border-gray-200 bg-gray-100': flag.severity === 'info',
})}
>
<div
className={ctw(
'flex h-4 w-4 items-center justify-center rounded-full text-xs text-white',
{
'bg-red-600': flag.severity === 'error',
'bg-warning': flag.severity === 'warning',
'bg-gray-400': flag.severity === 'info',
},
)}
>
{flag.severity === 'info' ? '?' : 'X'}
</div>
<span className="text-sm text-gray-700">{flag.title}</span>
</div>
))}
</div>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve accessibility and icon usage in WarningBanner.

The component implementation is good but has some areas for improvement:

  1. Accessibility: Missing proper ARIA attributes for screen readers
  2. Icon usage: Using text characters instead of the imported icons
  3. Semantic HTML: Could benefit from using semantic elements

Apply this diff to improve the component:

 const WarningBanner = ({ warningFlags }: WarningBannerProps) => {
   if (!warningFlags.length) return null;

   return (
-    <div className="mb-6 space-y-2">
+    <div className="mb-6 space-y-2" role="alert" aria-label="Assessment warnings">
       {warningFlags.map(flag => (
         <div
           key={flag.title}
           className={ctw('flex items-center gap-3 rounded-md border p-2.5', {
             'border-red-200 bg-red-100': flag.severity === 'error',
             'border-warning bg-warning': flag.severity === 'warning',
             'border-gray-200 bg-gray-100': flag.severity === 'info',
           })}
         >
           <div
             className={ctw(
               'flex h-4 w-4 items-center justify-center rounded-full text-xs text-white',
               {
                 'bg-red-600': flag.severity === 'error',
                 'bg-warning': flag.severity === 'warning',
                 'bg-gray-400': flag.severity === 'info',
               },
             )}
+            aria-hidden="true"
           >
-            {flag.severity === 'info' ? '?' : 'X'}
+            {flag.severity === 'error' ? (
+              <X size={12} />
+            ) : flag.severity === 'warning' ? (
+              <AlertTriangle size={12} />
+            ) : (
+              <Info size={12} />
+            )}
           </div>
-          <span className="text-sm text-gray-700">{flag.title}</span>
+          <span className="text-sm text-gray-700" role="text">
+            {flag.title}
+          </span>
         </div>
       ))}
     </div>
   );
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
type WarningBannerProps = {
warningFlags: WarningFlag[];
};
const WarningBanner = ({ warningFlags }: WarningBannerProps) => {
if (!warningFlags.length) return null;
return (
<div className="mb-6 space-y-2">
{warningFlags.map(flag => (
<div
key={flag.title}
className={ctw('flex items-center gap-3 rounded-md border p-2.5', {
'border-red-200 bg-red-100': flag.severity === 'error',
'border-warning bg-warning': flag.severity === 'warning',
'border-gray-200 bg-gray-100': flag.severity === 'info',
})}
>
<div
className={ctw(
'flex h-4 w-4 items-center justify-center rounded-full text-xs text-white',
{
'bg-red-600': flag.severity === 'error',
'bg-warning': flag.severity === 'warning',
'bg-gray-400': flag.severity === 'info',
},
)}
>
{flag.severity === 'info' ? '?' : 'X'}
</div>
<span className="text-sm text-gray-700">{flag.title}</span>
</div>
))}
</div>
);
};
type WarningBannerProps = {
warningFlags: WarningFlag[];
};
const WarningBanner = ({ warningFlags }: WarningBannerProps) => {
if (!warningFlags.length) return null;
return (
<div className="mb-6 space-y-2" role="alert" aria-label="Assessment warnings">
{warningFlags.map(flag => (
<div
key={flag.title}
className={ctw('flex items-center gap-3 rounded-md border p-2.5', {
'border-red-200 bg-red-100': flag.severity === 'error',
'border-warning bg-warning': flag.severity === 'warning',
'border-gray-200 bg-gray-100': flag.severity === 'info',
})}
>
<div
className={ctw(
'flex h-4 w-4 items-center justify-center rounded-full text-xs text-white',
{
'bg-red-600': flag.severity === 'error',
'bg-warning': flag.severity === 'warning',
'bg-gray-400': flag.severity === 'info',
},
)}
aria-hidden="true"
>
{flag.severity === 'error' ? (
<X size={12} />
) : flag.severity === 'warning' ? (
<AlertTriangle size={12} />
) : (
<Info size={12} />
)}
</div>
<span className="text-sm text-gray-700" role="text">
{flag.title}
</span>
</div>
))}
</div>
);
};
🤖 Prompt for AI Agents
In
apps/backoffice-v2/src/pages/KybAndOwnershipAssessmentPage/KybAndOwnershipAssessmentPage.tsx
lines 15 to 50, improve the WarningBanner component by replacing text characters
used as icons with the appropriate imported icon components, add ARIA attributes
such as role="alert" and aria-live="assertive" to the container div for better
screen reader support, and use semantic HTML elements like <section> or <aside>
instead of generic <div> to enhance meaning and accessibility.

@thecastleltd
Copy link

Hello Guys , Can i pay someone to deploy the solution on my server , i tried my best and check a lot of developpers non was able to deploy it right .
For collaboration please contact me on [email protected]

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.

4 participants