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

Revisions and UBOs documents fixes #2989

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Revisions and UBOs documents fixes #2989

merged 3 commits into from
Jan 23, 2025

Conversation

Omri-Levy
Copy link
Contributor

@Omri-Levy Omri-Levy commented Jan 23, 2025

  • fix(*): fixed director properties updating
  • fix(workflows-service): no longer overriding documents with kyc documents
  • chore(*): data migrations conflict

Summary by CodeRabbit

  • New Features

    • Added optional directorId parameter to several components and services
    • Enhanced document update functionality with director-specific context
  • Improvements

    • Refined document handling in workflow management
    • Improved data transformation for document properties
    • Updated data models to support more flexible document updates
  • Technical Updates

    • Updated method signatures across multiple services and components
    • Modified document processing logic to exclude unnecessary image URLs

Copy link

changeset-bot bot commented Jan 23, 2025

⚠️ No Changeset found

Latest commit: e6379c5

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 23, 2025

Walkthrough

The pull request introduces a new optional directorId parameter across multiple components in the backoffice and workflows service. This change spans several files in the application, primarily focusing on document update and management processes. The modifications enable passing a director identifier through various layers of the application, from the frontend components to the backend services, without fundamentally altering the existing logic or functionality.

Changes

File Path Change Summary
apps/backoffice-v2/src/domains/workflows/hooks/mutations/useUpdateDocumentByIdMutation Added optional directorId parameter to mutation hook
apps/backoffice-v2/src/lib/blocks/components/Details/Details.tsx Introduced directorId prop to component
apps/backoffice-v2/src/lib/blocks/components/EditableDetails Updated component and interface to include directorId
services/workflows-service/src/workflow/dtos/document-update-update-input.ts Added optional directorId to DocumentUpdateInput
services/workflows-service/src/workflow/workflow.controller.internal.ts Modified method to accept directorId in update process

Suggested Reviewers

  • tomer-shvadron

Poem

🐰 A Rabbit's Ode to Director's ID

Through code's winding warren, a new path unfurls,
directorId dances, its purpose now twirls
From frontend to backend, a parameter so neat
Connecting the dots, making workflows complete!

🔍✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 (3)
apps/backoffice-v2/src/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/helpers.ts (1)

7-7: Consider type safety with spread operator.

While using spread operator simplifies the code, it might include unwanted properties. Consider explicitly typing the expected document properties or implementing a sanitization function.

Example type definition:

type DirectorDocument = {
  id: string;
  category: string;
  type: string;
  // ... other expected properties
};

// Then use type assertion or sanitization
const sanitizeDocument = (doc: unknown): DirectorDocument => {
  // Implementation to ensure only expected properties are included
};

Also applies to: 11-14

apps/backoffice-v2/src/lib/blocks/components/EditableDetails/EditableDetails.tsx (1)

103-103: LGTM! Consider adding TypeScript type annotations.

The addition of directorId prop and its integration with the mutation hook looks good. However, consider adding explicit type annotations:

-  directorId,
+  directorId?: string,

Also applies to: 137-137

services/workflows-service/src/workflow/hook-callback-handler.service.ts (1)

366-370: LGTM! Consider adding type safety.

The spread operator usage correctly preserves existing documents while adding new ones, effectively preventing KYC documents from being overridden. However, consider adding type safety:

-    context.documents = [
-      // @ts-expect-error - we don't validate `context` is an object
-      ...context.documents,
-      ...persistedDocuments,
-    ];
+    context.documents = [
+      ...(Array.isArray(context.documents) ? context.documents : []),
+      ...persistedDocuments,
+    ];
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d02335d and e6379c5.

📒 Files selected for processing (11)
  • apps/backoffice-v2/src/domains/workflows/hooks/mutations/useUpdateDocumentByIdMutation/useUpdateDocumentByIdMutation.tsx (2 hunks)
  • apps/backoffice-v2/src/lib/blocks/components/Details/Details.tsx (2 hunks)
  • apps/backoffice-v2/src/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/helpers.ts (1 hunks)
  • apps/backoffice-v2/src/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/useDirectorBlock.tsx (5 hunks)
  • apps/backoffice-v2/src/lib/blocks/components/EditableDetails/EditableDetails.tsx (2 hunks)
  • apps/backoffice-v2/src/lib/blocks/components/EditableDetails/interfaces.ts (1 hunks)
  • apps/backoffice-v2/src/lib/blocks/create-blocks-typed/types.ts (1 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/src/workflow/dtos/document-update-update-input.ts (2 hunks)
  • services/workflows-service/src/workflow/hook-callback-handler.service.ts (1 hunks)
  • services/workflows-service/src/workflow/workflow.controller.internal.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • services/workflows-service/prisma/data-migrations
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: lint
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (8)
services/workflows-service/src/workflow/dtos/document-update-update-input.ts (1)

12-18: LGTM! Properly validated optional directorId.

The addition of directorId with proper validation and API documentation aligns with the PR objectives.

Let's verify consistent usage of this new parameter across the codebase:

✅ Verification successful

Verified: directorId is consistently implemented across the codebase

The optional directorId parameter is properly integrated throughout the application:

  • Validated in backend DTOs
  • Correctly handled in workflow service and controller
  • Consistently used in frontend components and mutations
  • Proper typing and error handling in place
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for directorId usage in TypeScript files
rg -t typescript "directorId.*?:" --multiline

Length of output: 82


Script:

#!/bin/bash
# Search for directorId in all files
rg "directorId" -A 2 -B 2

# Find property definitions containing directorId
ast-grep --pattern 'directorId: $_'

Length of output: 39017

apps/backoffice-v2/src/lib/blocks/components/EditableDetails/interfaces.ts (1)

25-25: LGTM! Interface updated consistently.

The addition of optional directorId matches the DTO changes and maintains type consistency.

apps/backoffice-v2/src/lib/blocks/components/Details/Details.tsx (1)

13-13: LGTM! Proper prop handling.

The directorId is correctly passed through to EditableDetails component, maintaining consistency with the interface changes.

Also applies to: 38-38

apps/backoffice-v2/src/domains/workflows/hooks/mutations/useUpdateDocumentByIdMutation/useUpdateDocumentByIdMutation.tsx (1)

10-10: LGTM! Clean implementation of the director ID parameter.

The changes correctly introduce the optional directorId parameter and properly integrate it into the mutation payload, aligning with the PR objectives to fix issues with updating director properties.

Also applies to: 14-14, 34-34

apps/backoffice-v2/src/lib/blocks/create-blocks-typed/types.ts (1)

116-116: LGTM! Type definition aligns with the feature requirements.

The optional directorId property is correctly added to the TDetailsCell type, maintaining consistency with the changes across other files.

services/workflows-service/src/workflow/workflow.controller.internal.ts (1)

248-248: LGTM! Backend integration of the director ID parameter.

The directorId is correctly extracted from the input data and properly passed to the service method, completing the end-to-end integration of the feature.

apps/backoffice-v2/src/lib/blocks/components/DirectorBlock/hooks/useDirectorBlock/useDirectorBlock.tsx (2)

99-102: Good optimization: Removing unnecessary imageUrl from document data.

The transformation efficiently removes the imageUrl property while preserving all other document data, preventing unnecessary data from being saved.


119-119: LGTM! Consistent integration of director context and document optimization.

The changes properly:

  1. Add the director context through directorId
  2. Use the optimized document data without imageUrl
  3. Include clear comments explaining the optimization

Also applies to: 132-133, 335-335, 376-377

@Omri-Levy Omri-Levy merged commit aee578b into dev Jan 23, 2025
10 checks passed
@Omri-Levy Omri-Levy deleted the bal-3441 branch January 23, 2025 17:34
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