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

Added ts-reset to apps and services #2146

Closed
wants to merge 35 commits into from
Closed

Conversation

Omri-Levy
Copy link
Contributor

@Omri-Levy Omri-Levy commented Mar 2, 2024

User description

  • feat: ongoing monitoring
  • chore(package.json): update db:reset:dev:with-data script to use db:reset:dev script before running db:data-migration:migrate
  • refactor(backoffice-v2): moved aml cells to a re-usable hook
  • refactor(backoffice-v2): added an on-going blocks variant
  • feat(backoffice-v2): added an actions variant for on-going
  • chore(package.json): update db:reset:dev:with-data script to use db:reset:dev script before running db:data-migration:migrate
  • chore(package.json): update db:reset:dev:with-data script to use db:reset:dev script before running db:data-migration:migrate
  • feat: more work
  • feat: test fix
  • chore(workflows-service): update subproject commit hash in data-migrations refactor(business.controller.internal): remove unused import of ProjectScopeService fix(customer.repository): fix import path for PrismaService test(workflow-definition.service.intg.test): update filterService.getById calls to pass correct project id argument
  • chore(workflows-service): update subproject commit hash in data-migrations refactor(business.controller.internal): remove unused import of ProjectScopeService fix(customer.repository): fix import path for PrismaService test(workflow-definition.service.intg.test): update filterService.getById calls to pass correct project id parameter
  • chore(workflows-service): update subproject commit hash in data-migrations refactor(business.controller.internal): remove unused import of ProjectScopeService fix(customer.repository): fix import path for PrismaService test(workflow-definition.service.intg.test): update filterService.getById calls to pass correct project id argument
  • service
  • service
  • feat(backoffice-v2): added temporary mocks
  • feat: small fixes
  • refactor(backoffice-v2): moved mocks position
  • feat: small fix
  • fix(backoffice-v2): fixed flagged badge variant
  • refactor(backoffice-v2): removed aml mocks
  • added ts-reset to apps and services

Description

Elaborate on the subject, motivation, and context.

Related issues

  • Provide a link to each related issue.

Breaking changes

  • Describe the breaking changes that this pull request introduces.

How these changes were tested

  • Describe the tests that you ran to verify your changes, including devices, operating systems, browsers and versions.

Examples and references

  • Links, screenshots, and other resources related to this change.

Checklist

  • [] I have read the contribution guidelines of this project
  • [] I have read the style guidelines of this project
  • [] I have performed a self-review of my own code
  • [] I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • [] My changes generate no new warnings and errors
  • [] New and existing tests pass locally with my changes

Type

enhancement


Changes walkthrough

Relevant files
Enhancement
10 files
useKycBlock.tsx
Refactor useKycBlock hook in KycBlock component                   

apps/backoffice-v2/src/lib/blocks/components/KycBlock/hooks/useKycBlock/useKycBlock.tsx

  • Removed unused imports and variables
  • Refactored code to improve readability
  • Extracted AML related logic to a separate hook
  • +12/-432
    useAmlBlock.tsx
    Extract AML block logic to useAmlBlock hook                           

    apps/backoffice-v2/src/lib/blocks/components/AmlBlock/hooks/useAmlBlock/useAmlBlock.tsx

  • Extracted AML block logic to a separate hook
  • Refactored code to improve readability
  • +377/-0 
    useCaseActionsLogic.tsx
    Refactor useCaseActionsLogic hook in Case component           

    apps/backoffice-v2/src/pages/Entity/components/Case/hooks/useCaseActionsLogic/useCaseActionsLogic.tsx

  • Refactored code to improve readability
  • Removed unused imports and variables
  • Extracted dialog components to separate files
  • +1/-45   
    Case.Actions.tsx
    Refactor Case.Actions component in Case                                   

    apps/backoffice-v2/src/pages/Entity/components/Case/Case.Actions.tsx

  • Refactored code to improve readability
  • Removed unused imports and variables
  • Extracted dialog components to separate files
  • +10/-88 
    OnGoingActions.tsx
    Add OnGoingActions component in Case                                         

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/OnGoingActions/OnGoingActions.tsx

  • Added OnGoingActions component
  • Extracted dialog components to separate files
  • +110/-0 
    useDefaultActionsLogic.tsx
    Add useDefaultActionsLogic hook in DefaultActions               

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/DefaultActions/hooks/useDefaultActionsLogic/useDefaultActionsLogic.tsx

  • Added useDefaultActionsLogic hook
  • Refactored code to improve readability
  • +82/-0   
    DefaultActions.tsx
    Add DefaultActions component in Case                                         

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/DefaultActions/DefaultActions.tsx

  • Added DefaultActions component
  • Extracted dialog components to separate files
  • +98/-0   
    useOnGoingActionsLogic.tsx
    Add useOnGoingActionsLogic hook in OnGoingActions               

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/OnGoingActions/hooks/useOnGoingActionsLogic/useOnGoingActionsLogic.tsx

  • Added useOnGoingActionsLogic hook
  • Refactored code to improve readability
  • +64/-0   
    useOnGoingBlocksLogic.tsx
    Add useOnGoingBlocksLogic hook in OnGoingBlocks                   

    apps/backoffice-v2/src/lib/blocks/variants/OnGoingBlocks/hooks/useOnGoingBlocksLogic/useOnGoingBlocksLogic.tsx

  • Added useOnGoingBlocksLogic hook
  • Refactored code to improve readability
  • +42/-0   
    webhooks.module.ts
    Add WebhooksModule in workflows-service                                   

    services/workflows-service/src/webhooks/webhooks.module.ts

    • Added WebhooksModule
    +70/-0   

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    tomer-shvadron and others added 30 commits February 27, 2024 00:05
    …eset:dev script before running db:data-migration:migrate
    
    fix(prisma): update subproject commit hash in data-migrations
    
    feat(prisma): add config column to Customer table
    
    feat(app.module): import WebhooksModule
    
    feat(zod-schemas): add CustomerConfigSchema and TCustomerConfig types
    
    fix(end-user.repository): update import path for PrismaService
    
    feat(end-user.service): add missing line break
    
    fix(filter.repository): update scopeService.scopeFindFirst method call
    
    fix(global.d.ts): add config and subscriptions fields to Customer type
    
    feat(webhooks): add AmlWebhookInput and IndividualAmlWebhookInput DTOs
    
    feat(webhooks): add webhooks controller, module, and service
    
    - Add a new file `webhooks.controller.ts` to handle webhooks related requests.
    - Add a new file `webhooks.module.ts` to define the webhooks module and its dependencies.
    - Add a new file `webhooks.service.ts` to handle webhook events.
    - Implement the `amlHook` method in the `WebhooksController` to handle AML webhook events.
    - Implement the `handleAmlHit` method in the `WebhooksService` to handle AML_HIT events.
    - Update the imports and dependencies in the existing files to include the newly added files.
    
    The purpose of these changes is to introduce a new feature that allows handling AML webhook events in the application. This feature will enable the application to respond to AML_HIT events and perform necessary actions based on the event data.
    …eset:dev script before running db:data-migration:migrate
    
    chore(package.json): add new migration script for adding a config column to the Customer table
    
    chore(schema.prisma): add config field to the Customer model
    
    chore(app.module.ts): import and add WebhooksModule to the AppModule
    
    chore(zod-schemas.ts): add CustomerConfigSchema and TCustomerConfig types
    
    chore(end-user.repository.ts): update import path for PrismaService
    
    chore(end-user.repository.ts): add new method findByIdUnscoped to retrieve end user by id without applying project scope
    
    chore(end-user.service.ts): add missing line break
    
    chore(filter.repository.ts): update scopeService.scopeFindFirst to scopeService.scopeFindFirst with projectIds parameter
    
    chore(global.d.ts): add config field to the Customer type
    
    chore(webhooks/dtos/aml-webhook-input.ts): create AmlWebhookInput class
    
    chore(webhooks/dtos/individual-aml-webhook-input.ts): create IndividualAmlWebhookInput class
    
    feat(webhooks): add webhooks controller, module, and service
    
    - Add a new file `webhooks.controller.ts` to handle webhooks related requests.
    - Add a new file `webhooks.module.ts` to define the webhooks module and its dependencies.
    - Add a new file `webhooks.service.ts` to handle webhook events.
    - Implement the `amlHook` method in the `WebhooksController` to handle AML webhook events.
    - Implement the `handleAmlHit` method in the `WebhooksService` to handle AML_HIT events.
    - Update the imports and dependencies in the existing files to include the newly added files.
    
    The purpose of these changes is to introduce a new feature that allows handling AML webhook events in the application. This feature will enable the application to respond to AML_HIT events and perform necessary actions based on the event data.
    …eset:dev script before running db:data-migration:migrate
    
    fix(prisma): update subproject commit hash in data-migrations
    
    feat(prisma): add config column to Customer table
    
    feat(app.module): import WebhooksModule
    
    feat(zod-schemas): add CustomerConfigSchema and TCustomerConfig types
    
    fix(end-user.repository): update import path for PrismaService
    
    feat(end-user.service): add missing line break
    
    fix(filter.repository): update scopeService.scopeFindFirst method call
    
    fix(global.d.ts): add config and subscriptions fields to Customer type
    
    feat(webhooks): add AmlWebhookInput and IndividualAmlWebhookInput DTOs
    
    feat(webhooks): add webhooks controller, module, and service
    
    - Add a new file `webhooks.controller.ts` to handle webhooks related requests.
    - Add a new file `webhooks.module.ts` to define the webhooks module and its dependencies.
    - Add a new file `webhooks.service.ts` to handle webhook events.
    - Implement the `amlHook` method in the `WebhooksController` to handle AML webhook events.
    - Implement the `handleAmlHit` method in the `WebhooksService` to handle AML_HIT events.
    - Update the imports and dependencies in the existing files to include the newly added files.
    
    The purpose of these changes is to introduce a new feature that allows handling AML webhook events in the application. This feature will enable the application to respond to AML_HIT events and perform necessary actions based on the event data.
    …tions
    
    refactor(business.controller.internal): remove unused import of ProjectScopeService
    fix(customer.repository): fix import path for PrismaService
    test(workflow-definition.service.intg.test): update filterService.getById calls to pass correct project id argument
    …tions
    
    refactor(business.controller.internal): remove unused import of ProjectScopeService
    fix(customer.repository): fix import path for PrismaService
    test(workflow-definition.service.intg.test): update filterService.getById calls to pass correct project id parameter
    …tions
    
    refactor(business.controller.internal): remove unused import of ProjectScopeService
    fix(customer.repository): fix import path for PrismaService
    test(workflow-definition.service.intg.test): update filterService.getById calls to pass correct project id argument
    Copy link

    changeset-bot bot commented Mar 2, 2024

    ⚠️ No Changeset found

    Latest commit: 428af02

    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

    @github-actions github-actions bot added the enhancement New feature or request label Mar 2, 2024
    Copy link
    Contributor

    github-actions bot commented Mar 2, 2024

    PR Description updated to latest commit (428af02)

    Copy link
    Contributor

    github-actions bot commented Mar 2, 2024

    PR Review

    ⏱️ Estimated effort to review [1-5]

    4, because the PR includes a wide range of changes across multiple files, including backend and frontend modifications, database schema updates, and the introduction of new features and refactoring. The complexity and breadth of the changes require a thorough review to ensure quality and consistency.

    🧪 Relevant tests

    No

    🔍 Possible issues

    The removal of db:reset:dev:with-data script in package.json might affect existing workflows that rely on this script for database seeding and migrations.

    The addition of @total-typescript/ts-reset in multiple package.json files without a clear explanation or usage within the PR might introduce unnecessary dependencies.

    The extensive changes to workflow and entity handling logic could potentially introduce regressions if not properly tested, especially in areas related to case mutations and webhook handling.

    The refactor and feature additions in the useKycBlock and useAmlBlock hooks introduce significant changes to the logic that could affect the application's behavior in unforeseen ways.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileapps/backoffice-v2/src/domains/entities/hooks/mutations/useDismissCaseMutation/useDismissCaseMutation.tsx
    suggestion      

    Consider adding error handling within the mutationFn to gracefully handle API failures and provide more detailed feedback to the user. [important]

    relevant linefetchWorkflowEvent({

    relevant fileservices/workflows-service/src/webhooks/webhooks.controller.ts
    suggestion      

    Implement verification of webhook signatures to ensure that incoming webhook requests are from trusted sources. This is crucial for security, especially when handling sensitive data in webhooks. [important]

    relevant line// @VerifyUnifiedApiSignatureDecorator()

    relevant fileservices/workflows-service/src/webhooks/webhooks.service.ts
    suggestion      

    Validate the data field in IndividualAmlWebhookInput to ensure it contains the expected structure and types before processing. This validation can prevent potential runtime errors and ensure data integrity. [important]

    relevant lineasync handleIndividualAmlHit({ entityId, data }: IndividualAmlWebhookInput) {

    relevant fileapps/backoffice-v2/src/lib/blocks/components/KycBlock/hooks/useKycBlock/useKycBlock.tsx
    suggestion      

    Refactor the large useKycBlock hook to smaller, more focused hooks or functions to improve readability and maintainability. The current implementation is quite large and does a lot, which could make it harder to understand and debug. [medium]

    relevant lineexport const useKycBlock = ({


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    github-actions bot commented Mar 2, 2024

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Convert enum keys to uppercase for consistency.

    Consider using uppercase for enum keys to maintain consistency and improve readability.

    apps/backoffice-v2/src/common/enums.ts [42-43]

    -DISMISS: 'dismiss',
    -FLAG: 'flag',
    +DISMISS: 'DISMISS',
    +FLAG: 'FLAG',
     
    Extract inline styles into a CSS module or styled component.

    Extract the inline styles into a CSS module or styled component for better maintainability
    and to avoid potential specificity issues with global styles.

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/DefaultActions/DefaultActions.tsx [44]

    -<DialogContent className={`mb-96`}>
    +<DialogContent className={styles.dialogContent}>
     
    Use optional chaining for safer property access.

    Use optional chaining when accessing properties on objects that might be undefined to
    prevent runtime errors.

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/DefaultActions/hooks/useDefaultActionsLogic/useDefaultActionsLogic.tsx [29]

    -workflowId: workflow?.id,
    +workflowId: workflow?.id ?? '',
     
    Use TypeScript's Readonly utility type for constants.

    Since the tagToBadgeData object is a constant, consider using TypeScript's Readonly
    utility type to enforce immutability at the type level.

    apps/backoffice-v2/src/pages/Entity/components/Case/consts.ts [10-14]

    -export const tagToBadgeData = {
    +export const tagToBadgeData: Readonly<{ [key in StateTag]: { variant: string; text: string } }> = {
     
    Use a named constant instead of a magic number for the debounce delay.

    Replace the magic number 300 with a named constant to improve code readability and
    maintainability.

    apps/backoffice-v2/src/pages/Entity/components/Case/hooks/useCaseActionsLogic/useCaseActionsLogic.tsx [34]

    -const debouncedIsLoadingAssignEntity = useDebounce(isLoadingAssignWorkflow, 300);
    +const DEBOUNCE_DELAY_MS = 300;
    +const debouncedIsLoadingAssignEntity = useDebounce(isLoadingAssignWorkflow, DEBOUNCE_DELAY_MS);
     
    Add a return type to the function for better type safety.

    Consider adding a return type to the useCaseActionsLogic function to improve type safety
    and readability.

    apps/backoffice-v2/src/pages/Entity/components/Case/hooks/useCaseActionsLogic/useCaseActionsLogic.tsx [14]

    -export const useCaseActionsLogic = ({ workflowId, fullName }: IUseActions) => {
    +interface UseCaseActionsLogicReturn {
    +    isActionButtonDisabled: boolean;
    +    onMutateAssignWorkflow: (assigneeId: string, isAssignedToMe: boolean) => void;
    +    debouncedIsLoadingAssignEntity: boolean;
    +    initials: string;
    +    canReject: boolean;
    +    canApprove: boolean;
    +    assignedUser: { id: string } | undefined;
    +    hasDecision: boolean;
    +    isLoadingCase: boolean;
    +    tag: string;
    +    workflowDefinition?: WorkflowDefinition;
    +}
     
    +export const useCaseActionsLogic = ({ workflowId, fullName }: IUseActions): UseCaseActionsLogicReturn => {
    +
    Enhancement
    Call onSelectNextCase in the mutation's onSuccess method.

    Ensure that onSelectNextCase is called within the mutation's onSuccess method to handle
    case selection after approval.

    apps/backoffice-v2/src/domains/entities/hooks/mutations/useApproveCaseMutation/useApproveCaseMutation.tsx [14]

    -onSelectNextCase?: VoidFunction;
    +onSuccess: () => {
    +  onSelectNextCase?.();
    +},
     
    Add a key prop to components returned in conditional rendering.

    Consider adding a key prop to the returned components in the conditional rendering to
    ensure that React can handle the re-rendering process efficiently, especially if these
    components could be swapped dynamically.

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/ActionsVariant/ActionsVariant.tsx [12-16]

     if (isOnGoingVariant) {
    -  return <OnGoingActions />;
    +  return <OnGoingActions key="onGoingActions" />;
     }
    -return <DefaultActions />;
    +return <DefaultActions key="defaultActions" />;
     
    Improve code readability by destructuring objects.

    Consider destructuring workflow object to improve code readability.

    apps/backoffice-v2/src/pages/Entity/components/Case/hooks/useCaseActionsLogic/useCaseActionsLogic.tsx [52-54]

    -const assignedUser = workflow?.assignee
    +const { assignee } = workflow;
    +const assignedUser = assignee
         ? {
    -        id: workflow?.assignee?.id,
    +        id: assignee?.id,
     
    Simplify object property assignment with optional chaining and nullish coalescing.

    Use optional chaining and nullish coalescing together to simplify the assignment of
    assignedUser.

    apps/backoffice-v2/src/pages/Entity/components/Case/hooks/useCaseActionsLogic/useCaseActionsLogic.tsx [52-54]

    -const assignedUser = workflow?.assignee
    -    ? {
    -        id: workflow?.assignee?.id,
    +const assignedUser = {
    +    id: workflow?.assignee?.id ?? undefined,
     
    Add error handling and user feedback to the mutation function.

    Ensure that mutateAssignWorkflow function is properly handling errors and providing
    feedback to the user.

    apps/backoffice-v2/src/pages/Entity/components/Case/hooks/useCaseActionsLogic/useCaseActionsLogic.tsx [37-39]

     const onMutateAssignWorkflow = useCallback(
    -    (assigneeId: string, isAssignedToMe: boolean) =>
    -    mutateAssignWorkflow({
    +    async (assigneeId: string, isAssignedToMe: boolean) => {
    +        try {
    +            await mutateAssignWorkflow({
    +                assigneeId,
    +                isAssignedToMe,
    +            });
    +            // Handle success (e.g., show a success message)
    +        } catch (error) {
    +            // Handle error (e.g., show an error message)
    +        }
    +    },
     
    Possible issue
    Implement onSelectNextCase call in onSuccess.

    Replace the comment with the actual implementation of onSelectNextCase to ensure
    functionality is complete.

    apps/backoffice-v2/src/domains/entities/hooks/mutations/useDismissCaseMutation/useDismissCaseMutation.tsx [31-32]

    -// TODO: Re-implement
    -// onSelectNextEntity();
    +onSelectNextCase?.();
     
    Implement useSelectNextCase functionality.

    Implement the logic for useSelectNextCase instead of throwing an error to ensure the
    functionality is available.

    apps/backoffice-v2/src/domains/entities/hooks/useSelectNextCase/useSelectNextCase.tsx [6]

    -throw new Error('Not implemented');
    +// Example implementation
    +return useCallback(() => {
    +  console.log('Select next case logic goes here');
    +}, []);
     
    Handle potential undefined workflowId from useParams appropriately.

    Ensure that useParams is used correctly by checking if workflowId is possibly undefined
    and handling the case appropriately. This can prevent potential runtime errors.

    apps/backoffice-v2/src/lib/blocks/variants/OnGoingBlocks/hooks/useOnGoingBlocksLogic/useOnGoingBlocksLogic.tsx [9-14]

     const { entityId: workflowId } = useParams();
    +if (!workflowId) {
    +  // Handle the case where workflowId is undefined
    +}
     const { data: workflow, isLoading } = useWorkflowByIdQuery({
    -  workflowId: workflowId ?? '',
    +  workflowId,
       filterId: filterId ?? '',
     });
     
    Check for conflicts with @total-typescript/ts-reset and other global styles.

    Ensure that importing @total-typescript/ts-reset does not conflict with other global
    styles or resets that might be in use, to prevent unexpected styling issues.

    apps/backoffice-v2/src/main.tsx [4]

    +// Ensure no conflicts with other global styles
     import '@total-typescript/ts-reset';
     
    Performance
    Memoize the amlBlock component to improve performance.

    Consider memoizing the amlBlock component using useMemo to avoid unnecessary re-renders.
    This is particularly useful if the amlBlock component does not change often and is based
    on kycSessionKeys and getAmlData which are already memoized.

    apps/backoffice-v2/src/lib/blocks/components/KycBlock/hooks/useKycBlock/useKycBlock.tsx [107-110]

    -const amlBlock = useAmlBlock({
    +const amlBlock = useMemo(() => useAmlBlock({
       sessionKeys: kycSessionKeys,
       getAmlData,
    -});
    +}), [kycSessionKeys, getAmlData]);
     
    Maintainability
    Use a predefined CSS class instead of inline styles for the border.

    Replace inline style border-[1px] with a predefined CSS class for consistency and better
    maintainability. If a suitable class does not exist, consider adding one to your
    stylesheet.

    apps/backoffice-v2/src/lib/blocks/components/NoBlocks/NoBlocks.tsx [5]

    -<div className="flex items-center justify-center border-l-[1px] p-4 pb-72">
    +<div className="flex items-center justify-center border-l custom-border-class p-4 pb-72">
     
    Use a mapping object or factory pattern for variant component rendering.

    To ensure scalability and maintainability, consider implementing a factory pattern or a
    mapping object to handle the variant checks and component rendering. This approach can
    simplify adding new variants in the future.

    apps/backoffice-v2/src/lib/blocks/variants/BlocksVariant/BlocksVariant.tsx [20-32]

    -if (isKybExampleVariant) {
    -  return <KybExampleBlocks />;
    -}
    -if (isManualReviewVariant) {
    -  return <ManualReviewBlocks />;
    -}
    -if (isOnGoingVariant) {
    -  return <OnGoingBlocks />;
    -}
    -return <DefaultBlocks />;
    +const variantComponentMap = {
    +  [WorkflowDefinitionVariant.KYB_EXAMPLE]: KybExampleBlocks,
    +  [WorkflowDefinitionVariant.MANUAL_REVIEW]: ManualReviewBlocks,
    +  [WorkflowDefinitionVariant.ONGOING]: OnGoingBlocks,
    +  default: DefaultBlocks,
    +};
    +const VariantComponent = variantComponentMap[workflowDefinition.variant] || variantComponentMap.default;
    +return <VariantComponent />;
     
    Accessibility
    Add aria-label attributes to buttons for improved accessibility.

    To improve accessibility, add aria-label attributes to buttons for better screen reader
    support.

    apps/backoffice-v2/src/pages/Entity/components/Case/actions-variants/OnGoingActions/OnGoingActions.tsx [30-37]

     <Button
       size="md"
       variant="destructive"
       disabled={isLoadingActions || !canFlag}
       className={ctw({
         loading: debouncedIsLoadingFlagCase,
       })}
    +  aria-label="Flag case for review"
     >
       Flag
     </Button>
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @Omri-Levy Omri-Levy deleted the omri-levy/feat/ts-reset branch March 2, 2024 13:19
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants