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

Illiar/feat/kyb v1 cleanup #3004

Merged
merged 5 commits into from
Jan 29, 2025
Merged

Illiar/feat/kyb v1 cleanup #3004

merged 5 commits into from
Jan 29, 2025

Conversation

chesterkmr
Copy link
Collaborator

@chesterkmr chesterkmr commented Jan 29, 2025

  • Fixed crash caused by documents destination parser
  • Fixed multiselect options mapping caused by conflict with v2
  • removed ts tags

Summary by CodeRabbit

  • Dependency Updates

    • Updated @ballerine/ui from version 0.5.68 to 0.5.69 across multiple packages
    • Updated package versions for kyb-app and react-pdf-toolkit
  • Code Quality

    • Removed TypeScript ignore comments in multiple files, enabling stricter type checking
    • Improved type safety in various components
  • Component Improvements

    • Modified MultiSelect component to use title instead of label for option display
    • Introduced a new interface for options in the MultiselectField component, enhancing type safety and structure

Copy link

changeset-bot bot commented Jan 29, 2025

⚠️ No Changeset found

Latest commit: 25556f0

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

Walkthrough

This pull request involves updates across multiple packages, with a primary focus on the @ballerine/ui package. Key changes include the renaming of the label property to title in MultiSelect components, the removal of TypeScript ignore comments to enforce stricter type checking, and the updating of package versions. The modifications span several files in the kyb-app, react-pdf-toolkit, and ui packages, ensuring consistency in component implementations and type definitions.

Changes

File Change Summary
apps/kyb-app/CHANGELOG.md Added version 0.3.118, updated dependency @ballerine/ui to 0.5.69
apps/kyb-app/package.json Version updated to 0.3.118, @ballerine/ui updated to 0.5.69
apps/kyb-app/src/components/.../usePageErrors.ts Removed // @ts-nocheck directive
apps/kyb-app/src/components/.../CheckboxList.tsx Removed // @ts-nocheck directive
apps/kyb-app/src/components/.../DocumentField.tsx Added import for DocumentValueDestinationParser, improved type handling
apps/kyb-app/src/components/.../Multiselect.tsx Removed // @ts-nocheck directive
apps/kyb-app/src/components/.../json-form.fields.ts Removed // @ts-nocheck directive
apps/kyb-app/src/components/.../helpers.ts Removed // @ts-nocheck directive
packages/react-pdf-toolkit/CHANGELOG.md Added version 1.2.69, updated dependency @ballerine/ui to 0.5.69
packages/react-pdf-toolkit/package.json Version updated to 1.2.69, @ballerine/ui updated to 0.5.69
packages/ui/CHANGELOG.md Added version 0.5.69, fixed options mapping in the Multiselect component
packages/ui/package.json Version updated to 0.5.69
packages/ui/src/components/.../MultiSelect.stories.tsx Changed label property to title in options
packages/ui/src/components/.../MultiSelect.tsx Renamed label to title in interface and logic
packages/ui/src/components/.../MultiselectInputAdapter.tsx Changed option.label to option.title in rendering
packages/ui/src/components/.../MultiselectField.tsx Introduced MultiselectFieldOption interface, updated options handling
packages/ui/src/components/.../MultiselectField.unit.test.tsx Updated mock options to use MultiselectFieldOption
packages/ui/src/components/.../MultiselectFieldSelectedItem.tsx Changed option.label to option.title in rendering
services/workflows-service/prisma/data-migrations Updated subproject commit reference

Possibly related PRs

Suggested reviewers

  • alonp99
  • tomer-shvadron

Poem

🐰 A Rabbit's Ode to Type Safety
Goodbye, @ts-nocheck, farewell ignore!
Labels transform to titles galore
MultiSelect dances with type-checked might
Refactoring code with pure delight
A version bump, a rabbit's cheer! 🎉


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 341e1f7 and 25556f0.

📒 Files selected for processing (1)
  • services/workflows-service/prisma/data-migrations (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • services/workflows-service/prisma/data-migrations
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: test_windows
  • GitHub Check: test_linux
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: lint
  • GitHub Check: Analyze (javascript)
  • GitHub Check: spell_check

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

🔭 Outside diff range comments (5)
apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/DocumentField/DocumentField.tsx (2)

Line range hint 37-37: Remove remaining ts-ignore comments and add proper type definitions.

Several ts-ignore comments remain in the code, which contradicts the PR objective of removing TypeScript tags. Consider adding proper type definitions instead.

For example, for the props destructuring:

- //@ts-ignore
- const { definition, formData, inputIndex, onBlur, ...restProps } = props;
+ const { definition, formData, inputIndex, onBlur, ...restProps }: {
+   definition: UIElement<DocumentFieldParams>;
+   formData: any;
+   inputIndex: number | null;
+   onBlur: () => void;
+ } = props;

Also applies to: 49-49


Line range hint 97-146: Add proper TypeScript types to file upload handler.

The file upload handler contains multiple ts-ignore comments. Consider adding proper type definitions:

- //@ts-ignore
- const fileUploader: UploadFileFn = useCallback(
+ const fileUploader: UploadFileFn = useCallback<UploadFileFn>(
   async (file: File) => {
-    //@ts-ignore
     const parser = new DocumentValueDestinationParser(definition.valueDestination);
     // ... rest of the function
   },
   [stateApi, options, inputIndex, definition.valueDestination, toggleElementLoading],
 );
packages/ui/src/components/organisms/DynamicForm/components/RSJVInputAdaters/MultiselectInputAdapter/MultiselectInputAdapter.tsx (1)

Line range hint 28-28: Remove @ts-ignore comment.

Per PR objectives to remove TypeScript tags, this @ts-ignore comment should be addressed. Consider properly typing the onBlur callback or handling the type mismatch.

packages/ui/src/components/molecules/inputs/MultiSelect/MultiSelect.tsx (1)

Line range hint 71-77: Remove TypeScript ignore comments.

Several TypeScript ignore comments are present in the code. These should be properly typed instead of ignored.

Replace the @ts-ignore comments with proper type assertions:

 onChange(
   value ? [...value, option.value] : [option.value],
-  // @ts-ignore
-  name,
+  name as string,
 );
packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectField.unit.test.tsx (1)

Line range hint 84-88: Update mock options to use consistent property names.

The mock options are using label while the interface and component expect title.

Update the mock options to use title:

 const mockOptions: MultiselectFieldOption[] = [
-  { label: 'Option 1', value: 'opt1' },
-  { label: 'Option 2', value: 'opt2' },
-  { label: 'Option 3', value: 'opt3' },
+  { title: 'Option 1', value: 'opt1' },
+  { title: 'Option 2', value: 'opt2' },
+  { title: 'Option 3', value: 'opt3' },
 ];
🧹 Nitpick comments (5)
apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/DocumentField/DocumentField.tsx (2)

Line range hint 91-106: Add cleanup to useLayoutEffect hook.

The useLayoutEffect hook should cleanup the fetch operation to prevent memory leaks:

 useLayoutEffect(() => {
   if (!fileId) return;
   const persistedFile = collectionFlowFileStorage.getFileById(fileId);
   if (persistedFile) return;
-  void fetchFile(fileId).then(file => {
+  let isSubscribed = true;
+  void fetchFile(fileId).then(file => {
+    if (!isSubscribed) return;
     const createdFile = new File([''], file.fileNameInBucket || file.fileNameOnDisk || '', {
       type: 'text/plain',
     });
     collectionFlowFileStorage.registerFile(fileId, createdFile);
   });
+  return () => {
+    isSubscribed = false;
+  };
 }, [fileId, toggleElementLoading]);

Line range hint 30-214: Consider breaking down the DocumentField component.

The component has grown quite complex with multiple responsibilities (file upload, state management, error handling). Consider breaking it down into smaller, more focused components:

  • DocumentUploader (handling file upload logic)
  • DocumentStateManager (managing document state)
  • DocumentErrorHandler (managing error states)

This would improve maintainability and make it easier to add proper TypeScript types.

packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectFieldSelectedItem.unit.test.tsx (1)

1-1: Consider keeping specific import path.

The import path has been made more generic (@/components/molecules instead of .../MultiSelect). While this works, specific imports can make dependencies clearer and help with tree-shaking.

-import { MultiSelectOption } from '@/components/molecules';
+import { MultiSelectOption } from '@/components/molecules/inputs/MultiSelect';
packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectField.tsx (1)

34-38: Optimize options transformation.

The useMemo hook is correctly used to prevent unnecessary re-computations, but the transformation could be simplified if the interface used title directly.

If you apply the previous suggestion to use title in the interface, you can simplify this to:

 const multiselectOptions = useMemo(() => {
-  return (
-    element.params?.options?.map(option => ({ title: option.label, value: option.value })) || []
-  );
+  return element.params?.options || [];
 }, [element.params?.options]);
packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectField.unit.test.tsx (1)

148-150: Remove unnecessary transformation in test.

The options transformation in the test will become unnecessary once the mock options are updated to use title.

After updating the mock options, simplify the assertion:

-expect(multiselect.options).toEqual(
-  mockOptions.map(option => ({ title: option.label, value: option.value })),
-);
+expect(multiselect.options).toEqual(mockOptions);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f12145e and 341e1f7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (20)
  • apps/kyb-app/CHANGELOG.md (1 hunks)
  • apps/kyb-app/package.json (2 hunks)
  • apps/kyb-app/src/components/organisms/DynamicUI/Page/hooks/usePageErrors/usePageErrors.ts (0 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/CheckboxList/CheckboxList.tsx (0 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/DocumentField/DocumentField.tsx (2 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/Multiselect/Multiselect.tsx (0 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/json-form.fields.ts (0 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/helpers.ts (0 hunks)
  • packages/react-pdf-toolkit/CHANGELOG.md (1 hunks)
  • packages/react-pdf-toolkit/package.json (2 hunks)
  • packages/ui/CHANGELOG.md (1 hunks)
  • packages/ui/package.json (1 hunks)
  • packages/ui/src/components/molecules/inputs/MultiSelect/MultiSelect.stories.tsx (2 hunks)
  • packages/ui/src/components/molecules/inputs/MultiSelect/MultiSelect.tsx (3 hunks)
  • packages/ui/src/components/organisms/DynamicForm/components/RSJVInputAdaters/MultiselectInputAdapter/MultiselectInputAdapter.tsx (1 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectField.tsx (4 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectField.unit.test.tsx (4 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectFieldSelectedItem.tsx (1 hunks)
  • packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectFieldSelectedItem.unit.test.tsx (1 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
💤 Files with no reviewable changes (5)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/Multiselect/Multiselect.tsx
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/helpers.ts
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/CheckboxList/CheckboxList.tsx
  • apps/kyb-app/src/components/organisms/DynamicUI/Page/hooks/usePageErrors/usePageErrors.ts
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/json-form.fields.ts
✅ Files skipped from review due to trivial changes (6)
  • services/workflows-service/prisma/data-migrations
  • apps/kyb-app/package.json
  • packages/react-pdf-toolkit/package.json
  • apps/kyb-app/CHANGELOG.md
  • packages/react-pdf-toolkit/CHANGELOG.md
  • packages/ui/package.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
packages/ui/CHANGELOG.md (1)

3-7: LGTM! Version bump and changelog entry are properly documented.

The changelog entry correctly documents:

  • Version increment to 0.5.69
  • Patch change fixing the Multiselect options mapping issue
apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/DocumentField/DocumentField.tsx (1)

20-20: LGTM: Clean import addition for document value parsing.

The addition of DocumentValueDestinationParser import aligns with the enhanced document value parsing functionality.

packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectFieldSelectedItem.tsx (1)

16-16: Verify consistent usage of option.title across the codebase.

The change from option.label to option.title aligns with the PR objective to fix multiselect options mapping.

Let's verify this change is consistent across the codebase:

✅ Verification successful

The change to option.title is consistent within the UI package

The usage of option.title is consistent across all files within the packages/ui MultiSelect implementation. The instances of option.label found in backoffice-v2 belong to a separate, independent MultiSelect implementation and do not need to be modified.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of option.label in MultiSelect related files
rg "option\.label" --type ts --type tsx

# Search for option.title usage to confirm the new pattern
rg "option\.title" --type ts --type tsx

Length of output: 139


Script:

#!/bin/bash
# Search for MultiSelect-related files containing option.label
rg -B2 -A2 "option\.label" --glob '*MultiSelect*.{ts,tsx}'

# Search for MultiSelect-related files containing option.title
rg -B2 -A2 "option\.title" --glob '*MultiSelect*.{ts,tsx}'

# List all MultiSelect-related files to ensure we're not missing anything
fd "MultiSelect" --extension ts --extension tsx

Length of output: 4398

packages/ui/src/components/molecules/inputs/MultiSelect/MultiSelect.stories.tsx (1)

12-12: LGTM! Story file correctly demonstrates the new MultiSelect API.

The changes consistently use title instead of label across all examples, which helps document the correct usage of the component.

Also applies to: 20-20, 49-49

packages/ui/src/components/organisms/DynamicForm/components/RSJVInputAdaters/MultiselectInputAdapter/MultiselectInputAdapter.tsx (1)

48-48: LGTM! Change is consistent with the new MultiSelect API.

The defaultRenderer correctly uses option.title instead of option.label.

packages/ui/src/components/organisms/Form/DynamicForm/fields/MultiselectField/MultiselectFieldSelectedItem.unit.test.tsx (1)

9-11: LGTM! Test data correctly reflects the new API.

The mock option correctly uses the title property instead of label.

@chesterkmr chesterkmr merged commit 42ceb11 into dev Jan 29, 2025
18 checks passed
@chesterkmr chesterkmr deleted the illiar/feat/kyb_v1_cleanup branch January 29, 2025 10:18
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